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
286
287
288
|
/*
* Copyright (C) 2003-2011 Sebastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat 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 3 of the License, or
* (at your option) any later version.
*
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_GUI_BUFFER_H
#define __WEECHAT_GUI_BUFFER_H 1
struct t_hashtable;
struct t_gui_window;
struct t_infolist;
enum t_gui_buffer_type
{
GUI_BUFFER_TYPE_FORMATTED = 0,
GUI_BUFFER_TYPE_FREE,
/* number of buffer types */
GUI_BUFFER_NUM_TYPES,
};
enum t_gui_buffer_notify
{
GUI_BUFFER_NOTIFY_NONE = 0,
GUI_BUFFER_NOTIFY_HIGHLIGHT,
GUI_BUFFER_NOTIFY_MESSAGE,
GUI_BUFFER_NOTIFY_ALL,
/* number of buffer notify */
GUI_BUFFER_NUM_NOTIFY,
};
#define GUI_BUFFER_MAIN "weechat"
#define GUI_TEXT_SEARCH_DISABLED 0
#define GUI_TEXT_SEARCH_BACKWARD 1
#define GUI_TEXT_SEARCH_FORWARD 2
#define GUI_BUFFER_INPUT_BLOCK_SIZE 256
/* buffer structures */
struct t_gui_input_undo
{
char *data; /* content of input buffer */
int pos; /* position of cursor in buffer */
struct t_gui_input_undo *prev_undo;/* link to previous undo */
struct t_gui_input_undo *next_undo;/* link to next undo */
};
struct t_gui_buffer
{
struct t_weechat_plugin *plugin; /* plugin which created this buffer */
/* (NULL for a WeeChat buffer) */
/*
* when upgrading, plugins are not loaded, so we use next variable
* to store plugin name, then restore plugin pointer when plugin is
* loaded
*/
char *plugin_name_for_upgrade; /* plugin name when upgrading */
/*
* when upgrading, we use this pointer to remember that this buffer
* must merge with another buffer (it's done when all buffers are
* restored)
*/
struct t_gui_buffer *merge_for_upgrade;
int number; /* buffer number (for jump/switch) */
int layout_number; /* the number of buffer saved in */
/* layout */
int layout_applied; /* used when applying layout, to */
/* know if layout has been applied */
char *name; /* buffer name */
char *short_name; /* short buffer name */
enum t_gui_buffer_type type; /* buffer type (formatted, free, ..) */
int notify; /* 0 = never */
/* 1 = highlight only */
/* 2 = highlight + msg */
/* 3 = highlight + msg + join/part */
int num_displayed; /* number of windows displaying buf. */
int active; /* it is 0 only if buffers are */
/* merged and that this one is not */
/* selected buffer */
int print_hooks_enabled; /* 1 if print hooks are enabled */
/* close callback */
int (*close_callback)(void *data, /* called when buffer is closed */
struct t_gui_buffer *buffer);
void *close_callback_data; /* data for callback */
/* buffer title */
char *title; /* buffer title */
/* chat content */
struct t_gui_lines *own_lines; /* lines (for this buffer only) */
struct t_gui_lines *mixed_lines; /* mixed lines (if buffers merged) */
struct t_gui_lines *lines; /* pointer to "own_lines" or */
/* "mixed_lines" */
int time_for_each_line; /* time is displayed for each line? */
int chat_refresh_needed; /* refresh for chat is needed ? */
/* (1=refresh, 2=erase+refresh) */
/* nicklist */
int nicklist; /* = 1 if nicklist is enabled */
int nicklist_case_sensitive; /* nicks are case sensitive ? */
struct t_gui_nick_group *nicklist_root; /* pointer to groups root */
int nicklist_max_length; /* max length for a nick */
int nicklist_display_groups; /* display groups ? */
int nicklist_visible_count; /* number of nicks/groups to display */
/* inupt */
int input; /* = 1 if input is enabled */
int (*input_callback)(void *data, /* called when user send data */
struct t_gui_buffer *buffer,
const char *input_data);
void *input_callback_data; /* data for callback */
/* to this buffer */
int input_get_unknown_commands; /* 1 if unknown commands are sent to */
/* input_callback */
char *input_buffer; /* input buffer */
int input_buffer_alloc; /* input buffer: allocated size */
int input_buffer_size; /* buffer size in bytes */
int input_buffer_length; /* number of chars in buffer */
int input_buffer_pos; /* position into buffer */
int input_buffer_1st_display; /* first char displayed on screen */
/* undo/redo for input */
struct t_gui_input_undo input_undo_snap; /* snapshot of input buffer */
struct t_gui_input_undo *input_undo; /* undo for input */
struct t_gui_input_undo *last_input_undo; /* last undo for input */
struct t_gui_input_undo *ptr_input_undo; /* pointer to current undo */
int input_undo_count; /* number of undos */
/* completion */
struct t_gui_completion *completion; /* completion */
/* history */
struct t_gui_history *history; /* commands history */
struct t_gui_history *last_history;/* last command in history */
struct t_gui_history *ptr_history; /* current command in history */
int num_history; /* number of commands in history */
/* text search */
int text_search; /* text search type */
int text_search_exact; /* exact search (case sensitive) ? */
int text_search_found; /* 1 if text found, otherwise 0 */
char *text_search_input; /* input saved before text search */
/* highlight settings for buffer */
char *highlight_words; /* list of words to highlight */
char *highlight_tags; /* tags to highlight */
int highlight_tags_count; /* number of tags to highlight */
/* (if 0, any tag is highlighted) */
char **highlight_tags_array; /* tags to highlight */
/* hotlist settings for buffer */
struct t_hashtable *hotlist_max_level_nicks; /* max hotlist level for */
/* some nicks */
/* keys associated to buffer */
struct t_gui_key *keys; /* keys specific to buffer */
struct t_gui_key *last_key; /* last key for buffer */
int keys_count; /* number of keys in buffer */
/* local variables */
struct t_hashtable *local_variables; /* local variables */
/* link to previous/next buffer */
struct t_gui_buffer *prev_buffer; /* link to previous buffer */
struct t_gui_buffer *next_buffer; /* link to next buffer */
};
struct t_gui_buffer_visited
{
struct t_gui_buffer *buffer; /* pointer to buffer */
struct t_gui_buffer_visited *prev_buffer; /* link to previous variable */
struct t_gui_buffer_visited *next_buffer; /* link to next variable */
};
/* buffer variables */
extern struct t_gui_buffer *gui_buffers;
extern struct t_gui_buffer *last_gui_buffer;
extern struct t_gui_buffer_visited *gui_buffers_visited;
extern struct t_gui_buffer_visited *last_gui_buffer_visited;
extern int gui_buffers_visited_index;
extern int gui_buffers_visited_count;
extern int gui_buffers_visited_frozen;
extern char *gui_buffer_notify_string[];
extern char *gui_buffer_properties_get_integer[];
extern char *gui_buffer_properties_get_string[];
extern char *gui_buffer_properties_get_pointer[];
extern char *gui_buffer_properties_set[];
/* buffer functions */
extern void gui_buffer_notify_set_all ();
extern void gui_buffer_input_buffer_init (struct t_gui_buffer *buffer);
extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
const char *name,
int (*input_callback)(void *data,
struct t_gui_buffer *buffer,
const char *input_data),
void *input_callback_data,
int (*close_callback)(void *data,
struct t_gui_buffer *buffer),
void *close_callback_data);
extern int gui_buffer_valid (struct t_gui_buffer *buffer);
extern char *gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
const char *string);
extern void gui_buffer_set_plugin_for_upgrade (char *name,
struct t_weechat_plugin *plugin);
extern int gui_buffer_property_in_list (char *properties[], char *property);
extern int gui_buffer_get_integer (struct t_gui_buffer *buffer,
const char *property);
extern const char *gui_buffer_get_string (struct t_gui_buffer *buffer,
const char *property);
extern void *gui_buffer_get_pointer (struct t_gui_buffer *buffer,
const char *property);
extern void gui_buffer_ask_chat_refresh (struct t_gui_buffer *buffer,
int refresh);
extern void gui_buffer_set_title (struct t_gui_buffer *buffer,
const char *new_title);
extern void gui_buffer_set_highlight_words (struct t_gui_buffer *buffer,
const char *new_highlight_words);
extern void gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
const char *new_highlight_tags);
extern void gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *new_hotlist_max_level_nicks);
extern void gui_buffer_set_unread (struct t_gui_buffer *buffer);
extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value);
extern void gui_buffer_set_pointer (struct t_gui_buffer *buffer,
const char *property, void *pointer);
extern void gui_buffer_add_value_num_displayed (struct t_gui_buffer *buffer,
int value);
extern int gui_buffer_is_main (const char *plugin_name, const char *name);
extern struct t_gui_buffer *gui_buffer_search_main ();
extern struct t_gui_buffer *gui_buffer_search_by_name (const char *plugin,
const char *name);
extern struct t_gui_buffer *gui_buffer_search_by_full_name (const char *full_name);
extern struct t_gui_buffer *gui_buffer_search_by_partial_name (const char *plugin,
const char *name);
extern struct t_gui_buffer *gui_buffer_search_by_number (int number);
extern int gui_buffer_count_merged_buffers (int number);
extern int gui_buffer_is_scrolled (struct t_gui_buffer *buffer);
extern void gui_buffer_clear (struct t_gui_buffer *buffer);
extern void gui_buffer_clear_all ();
extern void gui_buffer_close (struct t_gui_buffer *buffer);
extern void gui_buffer_switch_by_number (struct t_gui_window *window,
int number);
extern void gui_buffer_set_active_buffer (struct t_gui_buffer *buffer);
extern struct t_gui_buffer *gui_buffer_get_next_active_buffer (struct t_gui_buffer *buffer);
extern struct t_gui_buffer *gui_buffer_get_previous_active_buffer (struct t_gui_buffer *buffer);
extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number);
extern void gui_buffer_merge (struct t_gui_buffer *buffer,
struct t_gui_buffer *target_buffer);
extern void gui_buffer_unmerge (struct t_gui_buffer *buffer, int number);
extern void gui_buffer_undo_snap (struct t_gui_buffer *buffer);
extern void gui_buffer_undo_snap_free (struct t_gui_buffer *buffer);
extern void gui_buffer_undo_add (struct t_gui_buffer *buffer);
extern void gui_buffer_undo_free (struct t_gui_buffer *buffer,
struct t_gui_input_undo *undo);
extern void gui_buffer_undo_free_all (struct t_gui_buffer *buffer);
extern struct t_gui_buffer_visited *gui_buffer_visited_search_by_number (int number);
extern void gui_buffer_visited_remove (struct t_gui_buffer_visited *buffer_visited);
extern void gui_buffer_visited_remove_by_buffer (struct t_gui_buffer *buffer);
extern struct t_gui_buffer_visited *gui_buffer_visited_add (struct t_gui_buffer *buffer);
extern int gui_buffer_visited_get_index_previous ();
extern int gui_buffer_visited_get_index_next ();
extern int gui_buffer_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer);
extern void gui_buffer_dump_hexa (struct t_gui_buffer *buffer);
extern void gui_buffer_print_log ();
#endif /* __WEECHAT_GUI_BUFFER_H */
|