/* * Copyright (c) 2021-2022 joshua stein * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __CHATTER_H__ #define __CHATTER_H__ #include #include "focusable.h" #include "irc.h" #include "util.h" #define PROGRAM_NAME "Wallops" #define HOMEPAGE "http://jcs.org/wallops" #define CHATTER_FONT geneva #define CHATTER_FONT_SIZE 10 #define MBAR_ID 128 #define NOTIFICATION_ICON_ID 128 #define ABOUT_DLOG_ID 130 #define APPLE_MENU_ID 128 #define APPLE_MENU_ABOUT_ID 1 #define FILE_MENU_ID 129 #define FILE_MENU_CONNECT_ID 1 #define FILE_MENU_SETTINGS_ID 2 #define FILE_MENU_QUIT_ID 4 #define EDIT_MENU_ID 130 #define EDIT_MENU_CUT_ID 1 #define EDIT_MENU_COPY_ID 2 #define EDIT_MENU_PASTE_ID 3 #define VIEW_MENU_ID 131 #define VIEW_MENU_PREV_TAB_ID 1 #define VIEW_MENU_NEXT_TAB_ID 2 #define VIEW_MENU_CLOSE_ID 3 #define VIEW_MENU_IGNORE_ID 4 #define IGNORE_MENU_ID 132 #define IGNORE_MENU_JOINS_ID 1 #define IGNORE_MENU_QUITS_ID 2 #define IGNORE_MENU_NICKS_ID 3 #define WINDOW_MENU_ID 133 #define WINDOW_MENU_HIDE_ID 1 #define WINDOW_MENU_N_ID 3 #define WAIT_TYPE_NONE (1 << 0) #define WAIT_TYPE_BACKGROUND (1 << 1) #define WAIT_TYPE_FOREGROUND (1 << 2) #define WAIT_TYPE_URGENT (1 << 3) #define IGNORE_NONE (1 << 0) #define IGNORE_JOINS (1 << 1) #define IGNORE_QUITS (1 << 2) #define IGNORE_NICKS (1 << 3) struct chatter_tab { SLIST_ENTRY(chatter_tab) list; struct irc_connection *conn; struct irc_channel *channel; char query_nick[member_size(struct irc_user, nick)]; TEHandle messages_te; ControlHandle messages_scroller; ListHandle nick_list; Rect label_rect; bool have_activity; bool ignore_activity; }; SLIST_HEAD(chatter_tabs_head, chatter_tab); struct chatter { struct focusable *focusable; WindowPtr win; BitMap shadow; Rect shadow_bounds; short shadow_refcnt; TEHandle input_te; char input[IRC_MAX_MSG_SIZE]; char tab_comp_input[member_size(struct irc_user, nick)]; char tab_comp_match[member_size(struct irc_user, nick)]; bool quitting; bool need_tab_bar_redraw; short ntabs; struct chatter_tabs_head tabs_list; struct chatter_tab *current_tab; }; extern MenuHandle apple_menu, file_menu, edit_menu, view_menu, ignore_menu, window_menu; void notify(struct focusable *focusable, char *msg, char *titlefmt, ...); void cancel_notification(void); struct chatter * chatter_init(const char *server, const unsigned short port, const char *password, const char *nick, const char *ident, const char *realname, bool hide_motd, const char *channel); void chatter_update_titlebar(struct chatter *chatter); size_t chatter_printf(struct chatter *chatter, struct irc_connection *conn, char *dest_tab, const char *format, ...); void chatter_insert_to_nick_list(struct chatter *chatter, struct irc_channel *channel, struct irc_channel_nick *nick, short pos); void chatter_remove_from_nick_list(struct chatter *chatter, struct irc_channel *channel, struct irc_channel_nick *nick, short pos); void chatter_sync_nick_list(struct chatter *chatter, struct irc_channel *channel); void chatter_clear_messages(struct chatter *chatter, struct chatter_tab *tab); struct chatter_tab * chatter_add_tab(struct chatter *chatter, Rect *win_bounds, struct irc_connection *conn, struct irc_channel *channel, char *query_nick); void chatter_close_tab(struct chatter *chatter, struct chatter_tab *tab); struct chatter_tab * chatter_find_tab(struct chatter *chatter, struct irc_connection *conn, char *dest_tab); #endif