summaryrefslogtreecommitdiff
path: root/src/gui/gui.h
blob: c3e56e08e15d944d7f6d47ceff092eccbe9d491a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/*
 * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
 * See README for License detail, AUTHORS for developers list.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */


#ifndef __WEECHAT_GUI_H
#define __WEECHAT_GUI_H 1

#include "gui-color.h"
#include "gui-panel.h"
#include "gui-buffer.h"
#include "gui-window.h"
#include "gui-keyboard.h"


#define gui_printf(buffer, fmt, argz...) \
    gui_printf_internal(buffer, 1, MSG_TYPE_INFO, NULL, fmt, ##argz)

#define gui_printf_type(buffer, type, fmt, argz...) \
    gui_printf_internal(buffer, 1, type, NULL, fmt, ##argz)

#define gui_printf_type_nick(buffer, type, nick, fmt, argz...) \
    gui_printf_internal(buffer, 1, type, nick, fmt, ##argz)

#define gui_printf_nolog(buffer, fmt, argz...) \
    gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, NULL, fmt, ##argz)

#define gui_printf_nolog_notime(buffer, fmt, argz...) \
    gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, NULL, fmt, ##argz)


typedef struct t_gui_infobar t_gui_infobar;

struct t_gui_infobar
{
    int color;                      /* text color                           */
    char *text;                     /* infobar text                         */
    int remaining_time;             /* delay (sec) before erasing this text */
                                    /* if < 0, text is never erased (except */
                                    /* by user action to erase it)          */
    t_gui_infobar *next_infobar;    /* next message for infobar             */
};

/* GUI variables */

extern int gui_init_ok;
extern int gui_ok;
extern int gui_add_hotlist;
extern t_gui_infobar *gui_infobar;
extern char *gui_input_clipboard;
extern time_t gui_last_activity_time;

/* GUI independent functions */

/* window */
extern int gui_window_tree_init (t_gui_window *);
extern void gui_window_tree_node_to_leaf (t_gui_window_tree *, t_gui_window *);
extern void gui_window_tree_free (t_gui_window_tree **);
extern t_gui_window *gui_window_new (t_gui_window *, int, int, int, int, int, int);
extern void gui_window_free (t_gui_window *);
extern void gui_window_switch_server (t_gui_window *);
extern void gui_window_switch_previous (t_gui_window *);
extern void gui_window_switch_next (t_gui_window *);
extern void gui_window_switch_by_buffer (t_gui_window *, int);
extern void gui_window_print_log (t_gui_window *);

/* buffer */
extern t_gui_buffer *gui_buffer_servers_search ();
extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
extern t_gui_buffer *gui_buffer_search (char *, char *);
extern t_gui_buffer *gui_buffer_search_by_number (int);
extern t_gui_window *gui_buffer_find_window (t_gui_buffer *);
extern int gui_buffer_is_scrolled (t_gui_buffer *);
extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *);
extern void gui_buffer_clear (t_gui_buffer *);
extern void gui_buffer_clear_all ();
extern void gui_buffer_free (t_gui_buffer *, int);
extern t_gui_line *gui_buffer_line_new (t_gui_buffer *, time_t);
extern int gui_buffer_line_search (t_gui_line *, char *, int);
extern void gui_buffer_merge_servers (t_gui_window *);
extern void gui_buffer_split_server (t_gui_window *);
extern void gui_buffer_switch_previous (t_gui_window *);
extern void gui_buffer_switch_next (t_gui_window *);
extern void gui_buffer_switch_dcc (t_gui_window *);
extern void gui_buffer_switch_raw_data (t_gui_window *);
extern t_gui_buffer *gui_buffer_switch_by_number (t_gui_window *, int);
extern void gui_buffer_move_to_number (t_gui_buffer *, int);
extern void gui_buffer_search_start (t_gui_window *);
extern void gui_buffer_search_restart (t_gui_window *);
extern void gui_buffer_search_stop (t_gui_window *);
extern int gui_buffer_search_text (t_gui_window *);
extern void gui_buffer_print_log (t_gui_buffer *);

/* panel */
extern int gui_panel_global_get_size (t_gui_panel *, int);
extern t_gui_panel *gui_panel_new (char *, int, int, int, int);
extern void gui_panel_free (t_gui_panel *);
extern void gui_panel_print_log ();

/* action */
extern void gui_action_clipboard_copy (char *, int);
extern void gui_action_clipboard_paste (t_gui_window *, char *);
extern void gui_action_return (t_gui_window *, char *);
extern void gui_action_tab (t_gui_window *, char *);
extern void gui_action_tab_previous (t_gui_window *, char *);
extern void gui_action_backspace (t_gui_window *, char *);
extern void gui_action_delete (t_gui_window *, char *);
extern void gui_action_delete_previous_word (t_gui_window *, char *);
extern void gui_action_delete_next_word (t_gui_window *, char *);
extern void gui_action_delete_begin_of_line (t_gui_window *, char *);
extern void gui_action_delete_end_of_line (t_gui_window *, char *);
extern void gui_action_delete_line (t_gui_window *, char *);
extern void gui_action_transpose_chars (t_gui_window *, char *);
extern void gui_action_home (t_gui_window *, char *);
extern void gui_action_end (t_gui_window *, char *);
extern void gui_action_left (t_gui_window *, char *);
extern void gui_action_previous_word (t_gui_window *, char *);
extern void gui_action_right (t_gui_window *, char *);
extern void gui_action_next_word (t_gui_window *, char *);
extern void gui_action_up (t_gui_window *, char *);
extern void gui_action_up_global (t_gui_window *, char *);
extern void gui_action_down (t_gui_window *, char *);
extern void gui_action_down_global (t_gui_window *, char *);
extern void gui_action_page_up (t_gui_window *, char *);
extern void gui_action_page_down (t_gui_window *, char *);
extern void gui_action_scroll_up (t_gui_window *, char *);
extern void gui_action_scroll_down (t_gui_window *, char *);
extern void gui_action_scroll_top (t_gui_window *, char *);
extern void gui_action_scroll_bottom (t_gui_window *, char *);
extern void gui_action_scroll_topic_left (t_gui_window *, char *);
extern void gui_action_scroll_topic_right (t_gui_window *, char *);
extern void gui_action_nick_beginning (t_gui_window *, char *);
extern void gui_action_nick_end (t_gui_window *, char *);
extern void gui_action_nick_page_up (t_gui_window *, char *);
extern void gui_action_nick_page_down (t_gui_window *, char *);
extern void gui_action_jump_smart (t_gui_window *, char *);
extern void gui_action_jump_dcc (t_gui_window *, char *);
extern void gui_action_jump_raw_data (t_gui_window *, char *);
extern void gui_action_jump_last_buffer (t_gui_window *, char *);
extern void gui_action_jump_server (t_gui_window *, char *);
extern void gui_action_jump_next_server (t_gui_window *, char *);
extern void gui_action_switch_server (t_gui_window *, char *);
extern void gui_action_scroll_previous_highlight (t_gui_window *, char *);
extern void gui_action_scroll_next_highlight (t_gui_window *, char *);
extern void gui_action_scroll_unread (t_gui_window *, char *);
extern void gui_action_hotlist_clear (t_gui_window *, char *);
extern void gui_action_infobar_clear (t_gui_window *, char *);
extern void gui_action_refresh_screen (t_gui_window *, char *);
extern void gui_action_grab_key (t_gui_window *, char *);
extern void gui_action_insert_string (t_gui_window *, char *);
extern void gui_action_search_text (t_gui_window *, char *);

/* key */
extern void gui_keyboard_init ();
extern void gui_keyboard_init_grab ();
extern char *gui_keyboard_get_internal_code (char *);
extern char *gui_keyboard_get_expanded_name (char *);
extern t_gui_key *gui_keyboard_search (char *);
extern t_gui_key_func *gui_keyboard_function_search_by_name (char *);
extern char *gui_keyboard_function_search_by_ptr (t_gui_key_func *);
extern t_gui_key *gui_keyboard_bind (char *, char *);
extern int gui_keyboard_unbind (char *);
extern int gui_keyboard_pressed (char *);
extern void gui_keyboard_free (t_gui_key *);
extern void gui_keyboard_free_all ();

/* log */
extern void gui_log_write_date (t_gui_buffer *);
extern void gui_log_write_line (t_gui_buffer *, char *);
extern void gui_log_write (t_gui_buffer *, char *);
extern void gui_log_start (t_gui_buffer *);
extern void gui_log_end (t_gui_buffer *);

/* other */
extern int gui_word_strlen (t_gui_window *, char *);
extern int gui_word_real_pos (t_gui_window *, char *, int);
extern void gui_printf_internal (t_gui_buffer *, int, int, char *, char *, ...);
extern void gui_printf_raw_data (void *, int, int, char *);
extern void gui_infobar_printf (int, int, char *, ...);
extern void gui_infobar_printf_from_buffer (t_gui_buffer *, int, int, char *, char *, ...);
extern void gui_infobar_remove ();
extern void gui_infobar_remove_all ();
extern void gui_input_optimize_size (t_gui_buffer *);
extern void gui_input_init_color_mask (t_gui_buffer *);
extern void gui_input_move (t_gui_buffer *, char *, char *, int );
extern void gui_input_complete (t_gui_window *);
extern void gui_exec_action_dcc (t_gui_window *, char *);
extern void gui_exec_action_raw_data (t_gui_window *, char *);
extern int gui_insert_string_input (t_gui_window *, char *, int);

/* GUI dependent functions */

/* color */
extern int gui_color_assign (int *, char *);
extern char *gui_color_get_name (int);
extern unsigned char *gui_color_decode (unsigned char *, int);
extern unsigned char *gui_color_decode_for_user_entry (unsigned char *);
extern unsigned char *gui_color_encode (unsigned char *);
extern void gui_color_init_pairs ();
extern void gui_color_rebuild_weechat();

/* keyboard */
extern void gui_keyboard_default_bindings ();

/* chat */
extern void gui_chat_draw_title (t_gui_buffer *, int);
extern char *gui_chat_word_get_next_char (t_gui_window *, unsigned char *, int, int *);
extern void gui_chat_draw (t_gui_buffer *, int);
extern void gui_chat_draw_line (t_gui_buffer *, t_gui_line *);

/* status bar */
extern void gui_infobar_draw_time (t_gui_buffer *);
extern void gui_infobar_draw (t_gui_buffer *, int);

/* info bar */
extern void gui_status_draw (t_gui_buffer *, int);

/* input */
extern void gui_input_draw (t_gui_buffer *, int);

/* nicklist */
extern void gui_nicklist_draw (t_gui_buffer *, int, int);

/* window */
extern int gui_window_get_width ();
extern int gui_window_get_height ();
extern int gui_window_objects_init (t_gui_window *);
extern void gui_window_objects_free (t_gui_window *, int);
extern int gui_window_calculate_pos_size (t_gui_window *, int);
extern void gui_window_redraw_buffer (t_gui_buffer *);
extern void gui_window_switch_to_buffer (t_gui_window *, t_gui_buffer *);
extern void gui_window_page_up (t_gui_window *);
extern void gui_window_page_down (t_gui_window *);
extern void gui_window_scroll_up (t_gui_window *);
extern void gui_window_scroll_down (t_gui_window *);
extern void gui_window_scroll_top (t_gui_window *);
extern void gui_window_scroll_bottom (t_gui_window *);
extern void gui_window_scroll_topic_left (t_gui_window *);
extern void gui_window_scroll_topic_right (t_gui_window *);
extern void gui_window_nick_beginning (t_gui_window *);
extern void gui_window_nick_end (t_gui_window *);
extern void gui_window_nick_page_up (t_gui_window *);
extern void gui_window_nick_page_down (t_gui_window *);
extern void gui_window_init_subwindows (t_gui_window *);
extern void gui_window_refresh_windows ();
extern void gui_window_split_horiz (t_gui_window *, int);
extern void gui_window_split_vertic (t_gui_window *, int);
extern void gui_window_resize (t_gui_window *, int);
extern int gui_window_merge (t_gui_window *);
extern void gui_window_merge_all (t_gui_window *);
extern void gui_window_switch_up (t_gui_window *);
extern void gui_window_switch_down (t_gui_window *);
extern void gui_window_switch_left (t_gui_window *);
extern void gui_window_switch_right (t_gui_window *);
extern void gui_window_refresh_screen ();
extern void gui_window_set_title ();
extern void gui_window_reset_title ();
extern void gui_window_objects_print_log (t_gui_window *);

/* panel */
extern int gui_panel_window_new (t_gui_panel *, t_gui_window *);
extern void gui_panel_window_free (void *);

/* main */
extern void gui_main_loop ();
extern void gui_main_pre_init (int *, char **[]);
extern void gui_main_init ();
extern void gui_main_end ();

#endif /* gui.h */