26 |
|
|
27 |
#define INPUT_BUFFER_BLOCK_SIZE 256 |
#define INPUT_BUFFER_BLOCK_SIZE 256 |
28 |
|
|
29 |
#define NUM_COLORS 57 |
/* shift ncurses colors for compatibility with colors |
30 |
#define COLOR_WIN_TITLE 1 |
in IRC messages (same as other IRC clients) */ |
31 |
#define COLOR_WIN_CHAT 2 |
|
32 |
#define COLOR_WIN_CHAT_TIME 3 |
#define WEECHAT_COLOR_BLACK COLOR_BLACK |
33 |
#define COLOR_WIN_CHAT_TIME_SEP 4 |
#define WEECHAT_COLOR_RED COLOR_BLUE |
34 |
#define COLOR_WIN_CHAT_PREFIX1 5 |
#define WEECHAT_COLOR_GREEN COLOR_GREEN |
35 |
#define COLOR_WIN_CHAT_PREFIX2 6 |
#define WEECHAT_COLOR_YELLOW COLOR_CYAN |
36 |
#define COLOR_WIN_CHAT_SERVER 7 |
#define WEECHAT_COLOR_BLUE COLOR_RED |
37 |
#define COLOR_WIN_CHAT_JOIN 8 |
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA |
38 |
#define COLOR_WIN_CHAT_PART 9 |
#define WEECHAT_COLOR_CYAN COLOR_YELLOW |
39 |
#define COLOR_WIN_CHAT_NICK 10 |
#define WEECHAT_COLOR_WHITE COLOR_WHITE |
40 |
#define COLOR_WIN_CHAT_HOST 11 |
|
41 |
#define COLOR_WIN_CHAT_CHANNEL 12 |
#define COLOR_WIN_NICK_NUMBER 10 |
42 |
#define COLOR_WIN_CHAT_DARK 13 |
|
43 |
#define COLOR_WIN_CHAT_HIGHLIGHT 14 |
typedef enum t_weechat_color t_weechat_color; |
44 |
#define COLOR_WIN_STATUS 15 |
|
45 |
#define COLOR_WIN_STATUS_DELIMITERS 16 |
enum t_weechat_color |
46 |
#define COLOR_WIN_STATUS_CHANNEL 17 |
{ |
47 |
#define COLOR_WIN_STATUS_DATA_MSG 18 |
COLOR_WIN_TITLE = 0, |
48 |
#define COLOR_WIN_STATUS_DATA_PRIVATE 19 |
COLOR_WIN_CHAT, |
49 |
#define COLOR_WIN_STATUS_DATA_HIGHLIGHT 20 |
COLOR_WIN_CHAT_TIME, |
50 |
#define COLOR_WIN_STATUS_DATA_OTHER 21 |
COLOR_WIN_CHAT_TIME_SEP, |
51 |
#define COLOR_WIN_STATUS_MORE 22 |
COLOR_WIN_CHAT_PREFIX1, |
52 |
#define COLOR_WIN_INFOBAR 23 |
COLOR_WIN_CHAT_PREFIX2, |
53 |
#define COLOR_WIN_INFOBAR_DELIMITERS 24 |
COLOR_WIN_CHAT_SERVER, |
54 |
#define COLOR_WIN_INFOBAR_HIGHLIGHT 25 |
COLOR_WIN_CHAT_JOIN, |
55 |
#define COLOR_WIN_INPUT 26 |
COLOR_WIN_CHAT_PART, |
56 |
#define COLOR_WIN_INPUT_CHANNEL 27 |
COLOR_WIN_CHAT_NICK, |
57 |
#define COLOR_WIN_INPUT_NICK 28 |
COLOR_WIN_CHAT_HOST, |
58 |
#define COLOR_WIN_INPUT_DELIMITERS 29 |
COLOR_WIN_CHAT_CHANNEL, |
59 |
#define COLOR_WIN_NICK 30 |
COLOR_WIN_CHAT_DARK, |
60 |
#define COLOR_WIN_NICK_AWAY 31 |
COLOR_WIN_CHAT_HIGHLIGHT, |
61 |
#define COLOR_WIN_NICK_CHANOWNER 32 |
COLOR_WIN_STATUS, |
62 |
#define COLOR_WIN_NICK_CHANADMIN 33 |
COLOR_WIN_STATUS_DELIMITERS, |
63 |
#define COLOR_WIN_NICK_OP 34 |
COLOR_WIN_STATUS_CHANNEL, |
64 |
#define COLOR_WIN_NICK_HALFOP 35 |
COLOR_WIN_STATUS_DATA_MSG, |
65 |
#define COLOR_WIN_NICK_VOICE 36 |
COLOR_WIN_STATUS_DATA_PRIVATE, |
66 |
#define COLOR_WIN_NICK_MORE 37 |
COLOR_WIN_STATUS_DATA_HIGHLIGHT, |
67 |
#define COLOR_WIN_NICK_SEP 38 |
COLOR_WIN_STATUS_DATA_OTHER, |
68 |
#define COLOR_WIN_NICK_SELF 39 |
COLOR_WIN_STATUS_MORE, |
69 |
#define COLOR_WIN_NICK_PRIVATE 40 |
COLOR_WIN_INFOBAR, |
70 |
#define COLOR_WIN_NICK_FIRST 41 |
COLOR_WIN_INFOBAR_DELIMITERS, |
71 |
#define COLOR_WIN_NICK_LAST 50 |
COLOR_WIN_INFOBAR_HIGHLIGHT, |
72 |
#define COLOR_WIN_NICK_NUMBER (COLOR_WIN_NICK_LAST - COLOR_WIN_NICK_FIRST + 1) |
COLOR_WIN_INPUT, |
73 |
#define COLOR_DCC_SELECTED 51 |
COLOR_WIN_INPUT_CHANNEL, |
74 |
#define COLOR_DCC_WAITING 52 |
COLOR_WIN_INPUT_NICK, |
75 |
#define COLOR_DCC_CONNECTING 53 |
COLOR_WIN_INPUT_DELIMITERS, |
76 |
#define COLOR_DCC_ACTIVE 54 |
COLOR_WIN_NICK, |
77 |
#define COLOR_DCC_DONE 55 |
COLOR_WIN_NICK_AWAY, |
78 |
#define COLOR_DCC_FAILED 56 |
COLOR_WIN_NICK_CHANOWNER, |
79 |
#define COLOR_DCC_ABORTED 57 |
COLOR_WIN_NICK_CHANADMIN, |
80 |
|
COLOR_WIN_NICK_OP, |
81 |
|
COLOR_WIN_NICK_HALFOP, |
82 |
|
COLOR_WIN_NICK_VOICE, |
83 |
|
COLOR_WIN_NICK_MORE, |
84 |
|
COLOR_WIN_NICK_SEP, |
85 |
|
COLOR_WIN_NICK_SELF, |
86 |
|
COLOR_WIN_NICK_PRIVATE, |
87 |
|
COLOR_WIN_NICK_1, |
88 |
|
COLOR_WIN_NICK_2, |
89 |
|
COLOR_WIN_NICK_3, |
90 |
|
COLOR_WIN_NICK_4, |
91 |
|
COLOR_WIN_NICK_5, |
92 |
|
COLOR_WIN_NICK_6, |
93 |
|
COLOR_WIN_NICK_7, |
94 |
|
COLOR_WIN_NICK_8, |
95 |
|
COLOR_WIN_NICK_9, |
96 |
|
COLOR_WIN_NICK_10, |
97 |
|
COLOR_DCC_SELECTED, |
98 |
|
COLOR_DCC_WAITING, |
99 |
|
COLOR_DCC_CONNECTING, |
100 |
|
COLOR_DCC_ACTIVE, |
101 |
|
COLOR_DCC_DONE, |
102 |
|
COLOR_DCC_FAILED, |
103 |
|
COLOR_DCC_ABORTED, |
104 |
|
NUM_COLORS |
105 |
|
}; |
106 |
|
|
107 |
|
/* attributes in IRC messages for color & style (bold, ..) */ |
108 |
|
|
109 |
|
#define GUI_ATTR_BOLD_CHAR '\x02' |
110 |
|
#define GUI_ATTR_BOLD_STR "\x02" |
111 |
|
#define GUI_ATTR_COLOR_CHAR '\x03' |
112 |
|
#define GUI_ATTR_COLOR_STR "\x03" |
113 |
|
#define GUI_ATTR_RESET_CHAR '\x0F' |
114 |
|
#define GUI_ATTR_RESET_STR "\x0F" |
115 |
|
#define GUI_ATTR_FIXED_CHAR '\x11' |
116 |
|
#define GUI_ATTR_FIXED_STR "\x11" |
117 |
|
#define GUI_ATTR_REVERSE_CHAR '\x12' |
118 |
|
#define GUI_ATTR_REVERSE_STR "\x12" |
119 |
|
#define GUI_ATTR_REVERSE2_CHAR '\x16' |
120 |
|
#define GUI_ATTR_REVERSE2_STR "\x16" |
121 |
|
#define GUI_ATTR_ITALIC_CHAR '\x1D' |
122 |
|
#define GUI_ATTR_ITALIC_STR "\x1D" |
123 |
|
#define GUI_ATTR_UNDERLINE_CHAR '\x1F' |
124 |
|
#define GUI_ATTR_UNDERLINE_STR "\x1F" |
125 |
|
|
126 |
|
/* WeeChat internal attributes (should never be in IRC messages) */ |
127 |
|
|
128 |
|
#define GUI_ATTR_WEECHAT_COLOR_CHAR '\x19' |
129 |
|
#define GUI_ATTR_WEECHAT_COLOR_STR "\x19" |
130 |
|
#define GUI_ATTR_WEECHAT_SET_CHAR '\x1A' |
131 |
|
#define GUI_ATTR_WEECHAT_SET_STR "\x1A" |
132 |
|
#define GUI_ATTR_WEECHAT_REMOVE_CHAR '\x1B' |
133 |
|
#define GUI_ATTR_WEECHAT_REMOVE_STR "\x1B" |
134 |
|
|
135 |
|
#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "") |
136 |
|
#define GUI_NO_COLOR GUI_ATTR_RESET_STR |
137 |
|
|
138 |
#define SERVER(buffer) ((t_irc_server *)(buffer->server)) |
#define SERVER(buffer) ((t_irc_server *)(buffer->server)) |
139 |
#define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) |
#define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) |
142 |
#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHAT_CHANNEL)) |
#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHAT_CHANNEL)) |
143 |
#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHAT_PRIVATE)) |
#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHAT_PRIVATE)) |
144 |
|
|
145 |
|
#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer)) |
146 |
|
|
147 |
#define MSG_TYPE_TIME 1 |
#define MSG_TYPE_TIME 1 |
148 |
#define MSG_TYPE_PREFIX 2 |
#define MSG_TYPE_PREFIX 2 |
149 |
#define MSG_TYPE_NICK 4 |
#define MSG_TYPE_NICK 4 |
153 |
#define MSG_TYPE_NOLOG 64 |
#define MSG_TYPE_NOLOG 64 |
154 |
|
|
155 |
#define gui_printf(buffer, fmt, argz...) \ |
#define gui_printf(buffer, fmt, argz...) \ |
156 |
gui_printf_internal(buffer, 1, MSG_TYPE_INFO, -1, fmt, ##argz) |
gui_printf_internal(buffer, 1, MSG_TYPE_INFO, fmt, ##argz) |
|
|
|
|
#define gui_printf_color(buffer, color, fmt, argz...) \ |
|
|
gui_printf_internal(buffer, 1, MSG_TYPE_INFO, color, fmt, ##argz) |
|
157 |
|
|
158 |
#define gui_printf_type(buffer, type, fmt, argz...) \ |
#define gui_printf_type(buffer, type, fmt, argz...) \ |
159 |
gui_printf_internal(buffer, 1, type, -1, fmt, ##argz) |
gui_printf_internal(buffer, 1, type, fmt, ##argz) |
|
|
|
|
#define gui_printf_type_color(buffer, type, color, fmt, argz...) \ |
|
|
gui_printf_internal(buffer, 1, type, color, fmt, ##argz) |
|
160 |
|
|
161 |
#define gui_printf_nolog(buffer, fmt, argz...) \ |
#define gui_printf_nolog(buffer, fmt, argz...) \ |
162 |
gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, -1, fmt, ##argz) |
gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, fmt, ##argz) |
163 |
|
|
164 |
#define gui_printf_nolog_notime(buffer, fmt, argz...) \ |
#define gui_printf_nolog_notime(buffer, fmt, argz...) \ |
165 |
gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, -1, fmt, ##argz) |
gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, fmt, ##argz) |
166 |
|
|
167 |
#define NOTIFY_LEVEL_MIN 0 |
#define NOTIFY_LEVEL_MIN 0 |
168 |
#define NOTIFY_LEVEL_MAX 3 |
#define NOTIFY_LEVEL_MAX 3 |
171 |
#define KEY_SHOW_MODE_DISPLAY 1 |
#define KEY_SHOW_MODE_DISPLAY 1 |
172 |
#define KEY_SHOW_MODE_BIND 2 |
#define KEY_SHOW_MODE_BIND 2 |
173 |
|
|
|
typedef struct t_gui_message t_gui_message; |
|
|
|
|
|
struct t_gui_message |
|
|
{ |
|
|
int type; /* type of message (time, nick, other) */ |
|
|
int color; /* color of message */ |
|
|
char *message; /* message content */ |
|
|
t_gui_message *prev_message; /* link to previous message for line */ |
|
|
t_gui_message *next_message; /* link to next message for line */ |
|
|
}; |
|
|
|
|
|
typedef struct t_gui_line t_gui_line; |
|
|
|
|
|
struct t_gui_line |
|
|
{ |
|
|
int length; /* length of the line (in char) */ |
|
|
int length_align; /* alignment length (time or time/nick) */ |
|
|
int log_write; /* = 1 if line will be written to log */ |
|
|
int line_with_message; /* line contains a message from a user? */ |
|
|
int line_with_highlight; /* line contains highlight */ |
|
|
t_gui_message *messages; /* messages for the line */ |
|
|
t_gui_message *last_message; /* last message of the line */ |
|
|
t_gui_line *prev_line; /* link to previous line */ |
|
|
t_gui_line *next_line; /* link to next line */ |
|
|
}; |
|
|
|
|
174 |
typedef struct t_gui_color t_gui_color; |
typedef struct t_gui_color t_gui_color; |
175 |
|
|
176 |
struct t_gui_color |
struct t_gui_color |
177 |
{ |
{ |
178 |
char *name; |
int foreground; /* foreground color */ |
179 |
int color; |
int background; /* background color */ |
180 |
|
int attributes; /* attributes (bold, ..) */ |
181 |
|
char *string; /* WeeChat color: "\x19??", ?? is #color*/ |
182 |
}; |
}; |
183 |
|
|
184 |
typedef struct t_gui_infobar t_gui_infobar; |
typedef struct t_gui_infobar t_gui_infobar; |
193 |
t_gui_infobar *next_infobar; /* next message for infobar */ |
t_gui_infobar *next_infobar; /* next message for infobar */ |
194 |
}; |
}; |
195 |
|
|
196 |
|
typedef struct t_gui_line t_gui_line; |
197 |
|
|
198 |
|
struct t_gui_line |
199 |
|
{ |
200 |
|
int length; /* length of the line (in char) */ |
201 |
|
int length_align; /* alignment length (time or time/nick) */ |
202 |
|
int log_write; /* = 1 if line will be written to log */ |
203 |
|
int line_with_message; /* line contains a message from a user? */ |
204 |
|
int line_with_highlight; /* line contains highlight */ |
205 |
|
char *data; /* line content */ |
206 |
|
t_gui_line *prev_line; /* link to previous line */ |
207 |
|
t_gui_line *next_line; /* link to next line */ |
208 |
|
}; |
209 |
|
|
210 |
typedef struct t_gui_buffer t_gui_buffer; |
typedef struct t_gui_buffer t_gui_buffer; |
211 |
|
|
212 |
struct t_gui_buffer |
struct t_gui_buffer |
303 |
/* windows for Qt GUI */ |
/* windows for Qt GUI */ |
304 |
/* TODO: declare Qt window */ |
/* TODO: declare Qt window */ |
305 |
|
|
306 |
|
int current_style_fg;; /* current color used for foreground */ |
307 |
|
int current_style_bg;; /* current color used for background */ |
308 |
|
int current_style_attr; /* current attributes (bold, ..) */ |
309 |
|
int current_color_attr; /* attr sum of last color(s) displayed */ |
310 |
|
|
311 |
/* DCC */ |
/* DCC */ |
312 |
void *dcc_first; /* first dcc displayed */ |
void *dcc_first; /* first dcc displayed */ |
313 |
void *dcc_selected; /* selected dcc */ |
void *dcc_selected; /* selected dcc */ |
364 |
extern int gui_key_grab_count; |
extern int gui_key_grab_count; |
365 |
extern char *gui_input_clipboard; |
extern char *gui_input_clipboard; |
366 |
|
|
367 |
|
extern t_gui_color *gui_color[NUM_COLORS]; |
368 |
|
|
369 |
/* GUI independent functions: windows & buffers */ |
/* GUI independent functions: windows & buffers */ |
370 |
|
|
371 |
extern t_gui_window *gui_window_new (int, int, int, int); |
extern t_gui_window *gui_window_new (int, int, int, int); |
377 |
extern void gui_infobar_remove (); |
extern void gui_infobar_remove (); |
378 |
extern void gui_buffer_free (t_gui_buffer *, int); |
extern void gui_buffer_free (t_gui_buffer *, int); |
379 |
extern t_gui_line *gui_new_line (t_gui_buffer *); |
extern t_gui_line *gui_new_line (t_gui_buffer *); |
380 |
extern t_gui_message *gui_new_message (t_gui_buffer *); |
extern int gui_word_strlen (t_gui_window *, char *); |
381 |
|
extern int gui_word_real_pos (t_gui_window *, char *, int); |
382 |
|
extern void gui_printf_internal (t_gui_buffer *, int, int, char *, ...); |
383 |
extern void gui_optimize_input_buffer_size (t_gui_buffer *); |
extern void gui_optimize_input_buffer_size (t_gui_buffer *); |
384 |
extern void gui_exec_action_dcc (t_gui_window *, char *); |
extern void gui_exec_action_dcc (t_gui_window *, char *); |
385 |
extern int gui_insert_string_input (t_gui_window *, char *, int); |
extern int gui_insert_string_input (t_gui_window *, char *, int); |
455 |
/* GUI dependant functions: display */ |
/* GUI dependant functions: display */ |
456 |
|
|
457 |
extern int gui_assign_color (int *, char *); |
extern int gui_assign_color (int *, char *); |
458 |
extern int gui_get_color_by_name (char *); |
extern char *gui_get_color_name (int); |
459 |
extern char *gui_get_color_by_value (int); |
extern unsigned char *gui_color_decode (unsigned char *, int); |
460 |
|
extern unsigned char *gui_color_encode (unsigned char *); |
461 |
extern int gui_buffer_has_nicklist (t_gui_buffer *); |
extern int gui_buffer_has_nicklist (t_gui_buffer *); |
462 |
extern void gui_calculate_pos_size (t_gui_window *); |
extern void gui_calculate_pos_size (t_gui_window *); |
463 |
extern void gui_draw_buffer_title (t_gui_buffer *, int); |
extern void gui_draw_buffer_title (t_gui_buffer *, int); |
464 |
|
extern char *gui_word_get_next_char (t_gui_window *, unsigned char *, int); |
465 |
extern void gui_draw_buffer_chat (t_gui_buffer *, int); |
extern void gui_draw_buffer_chat (t_gui_buffer *, int); |
466 |
extern void gui_draw_buffer_nick (t_gui_buffer *, int); |
extern void gui_draw_buffer_nick (t_gui_buffer *, int); |
467 |
extern void gui_draw_buffer_status (t_gui_buffer *, int); |
extern void gui_draw_buffer_status (t_gui_buffer *, int); |
488 |
extern void gui_window_merge_all (t_gui_window *); |
extern void gui_window_merge_all (t_gui_window *); |
489 |
extern void gui_refresh_screen (); |
extern void gui_refresh_screen (); |
490 |
extern void gui_pre_init (int *, char **[]); |
extern void gui_pre_init (int *, char **[]); |
491 |
extern void gui_init_colors (); |
extern void gui_rebuild_weechat_colors (); |
492 |
extern void gui_set_window_title (); |
extern void gui_set_window_title (); |
493 |
extern void gui_init (); |
extern void gui_init (); |
494 |
extern void gui_end (); |
extern void gui_end (); |
|
extern void gui_printf_internal (t_gui_buffer *, int, int, int, char *, ...); |
|
495 |
extern void gui_input_default_key_bindings (); |
extern void gui_input_default_key_bindings (); |
496 |
extern void gui_main_loop (); |
extern void gui_main_loop (); |
497 |
|
|