AmendHub

Download

jcs

/

wallops

/

chatter.h

 

(View History)

jcs   chatter: Tab bar is no longer a GrafPort, rename it Latest amendment: 48 on 2023-01-18

1 /*
2 * Copyright (c) 2021-2022 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef __CHATTER_H__
18 #define __CHATTER_H__
19
20 #include <stdio.h>
21
22 #include "focusable.h"
23 #include "irc.h"
24 #include "util.h"
25
26 #define PROGRAM_NAME "Wallops"
27
28 #define CHATTER_FONT geneva
29 #define CHATTER_FONT_SIZE 10
30
31 #define MBAR_ID 128
32
33 #define NOTIFICATION_ICON_ID 128
34
35 #define APPLE_MENU_ID 128
36 #define APPLE_MENU_ABOUT_ID 1
37
38 #define FILE_MENU_ID 129
39 #define FILE_MENU_CONNECT_ID 1
40 #define FILE_MENU_QUIT_ID 3
41
42 #define EDIT_MENU_ID 130
43 #define EDIT_MENU_CUT_ID 1
44 #define EDIT_MENU_COPY_ID 2
45 #define EDIT_MENU_PASTE_ID 3
46
47 #define CONNECT_DLOG_ID 129
48 #define CONNECT_SERVER_ID 2
49 #define CONNECT_PORT_ID 3
50 #define CONNECT_PASSWORD_ID 4
51 #define CONNECT_NICK_ID 5
52 #define CONNECT_IDENT_ID 6
53 #define CONNECT_REALNAME_ID 7
54 #define CONNECT_CHANNEL_ID 8
55
56 #define STR_SERVER_ID 1000
57 #define STR_PORT_ID 1001
58 #define STR_NICK_ID 1002
59 #define STR_IDENT_ID 1003
60 #define STR_REALNAME_ID 1004
61 #define STR_CHANNEL_ID 1005
62 #define STR_PASSWORD_ID 1006
63
64 #define DEFAULT_SERVER_NAME "irc.libera.chat"
65 #define DEFAULT_PORT "6667"
66 #define DEFAULT_IDENT "wallops"
67 #define DEFAULT_REALNAME "A Macintosh User"
68 #define DEFAULT_CHANNEL "#cyberpals"
69
70 #define WAIT_TYPE_NONE (1 << 0)
71 #define WAIT_TYPE_BACKGROUND (1 << 1)
72 #define WAIT_TYPE_FOREGROUND (1 << 2)
73 #define WAIT_TYPE_URGENT (1 << 3)
74
75 struct chatter_tab {
76 SLIST_ENTRY(chatter_tab) list;
77 struct irc_connection *conn;
78 struct irc_channel *channel;
79 short index;
80 TEHandle messages_te;
81 ControlHandle messages_scroller;
82 ListHandle nick_list;
83 Rect label_rect;
84 bool have_activity;
85 };
86 SLIST_HEAD(chatter_tabs_head, chatter_tab);
87
88 struct chatter {
89 struct focusable *focusable;
90 WindowPtr win;
91 TEHandle input_te;
92 bool quitting;
93 BitMap tab_bar;
94 short ntabs;
95 struct chatter_tabs_head tabs_list;
96 struct chatter_tab *current_tab;
97 };
98
99 void notify(void);
100 void cancel_notification(void);
101
102 struct chatter * chatter_init(const char *server,
103 const unsigned short port, const char *password, const char *nick,
104 const char *ident, const char *realname, const char *channel);
105 void chatter_update_titlebar(struct chatter *chatter);
106 size_t chatter_printf(struct chatter *chatter, struct irc_connection *conn,
107 struct irc_channel *channel, const char *format, ...);
108 void chatter_insert_to_nick_list(struct chatter *chatter,
109 struct irc_channel *channel, struct irc_channel_nick *nick, short pos);
110 void chatter_sync_nick_list(struct chatter *chatter,
111 struct irc_channel *channel, bool just_summary);
112 struct chatter_tab * chatter_add_tab(struct chatter *chatter,
113 Rect *win_bounds, struct irc_connection *conn,
114 struct irc_channel *channel);
115 void chatter_remove_channel(struct chatter *chatter,
116 struct irc_channel *channel);
117
118 #endif