diff options
Diffstat (limited to 'src/gui/gui-buffer.h')
-rw-r--r-- | src/gui/gui-buffer.h | 225 |
1 files changed, 118 insertions, 107 deletions
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index de21b1fe8..e86a7b194 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -20,145 +20,156 @@ #ifndef __WEECHAT_GUI_BUFFER_H #define __WEECHAT_GUI_BUFFER_H 1 -#include "../common/completion.h" -#include "../common/history.h" - -#define GUI_BUFFER_TYPE_STANDARD 0 -#define GUI_BUFFER_TYPE_DCC 1 -#define GUI_BUFFER_TYPE_RAW_DATA 2 - -#define GUI_SERVER(buffer) ((t_irc_server *)(buffer->server)) -#define GUI_CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) - -#define GUI_BUFFER_IS_SERVER(buffer) ((GUI_SERVER(buffer) || (buffer->all_servers)) && !GUI_CHANNEL(buffer)) -#define GUI_BUFFER_IS_CHANNEL(buffer) (GUI_CHANNEL(buffer) && (GUI_CHANNEL(buffer)->type == IRC_CHANNEL_TYPE_CHANNEL)) -#define GUI_BUFFER_IS_PRIVATE(buffer) (GUI_CHANNEL(buffer) && \ - ((GUI_CHANNEL(buffer)->type == IRC_CHANNEL_TYPE_PRIVATE) \ - || (GUI_CHANNEL(buffer)->type == IRC_CHANNEL_TYPE_DCC_CHAT))) - -#define GUI_BUFFER_HAS_NICKLIST(buffer) (GUI_BUFFER_IS_CHANNEL(buffer)) - -#define GUI_LINE_LENGTH_ALIGN(line) ((cfg_look_align_text_offset >= 0) ? \ - cfg_look_align_text_offset : line->length_align) - -#define GUI_MSG_TYPE_TIME 1 -#define GUI_MSG_TYPE_PREFIX 2 -#define GUI_MSG_TYPE_NICK 4 -#define GUI_MSG_TYPE_INFO 8 -#define GUI_MSG_TYPE_MSG 16 -#define GUI_MSG_TYPE_HIGHLIGHT 32 -#define GUI_MSG_TYPE_NOLOG 64 - -#define GUI_PREFIX_SERVER "-@-" -#define GUI_PREFIX_INFO "-=-" -#define GUI_PREFIX_ACTION_ME "-*-" -#define GUI_PREFIX_JOIN "-->" -#define GUI_PREFIX_PART "<--" -#define GUI_PREFIX_QUIT "<--" -#define GUI_PREFIX_ERROR "=!=" -#define GUI_PREFIX_PLUGIN "-P-" -#define GUI_PREFIX_RECV_MOD "==>" -#define GUI_PREFIX_SEND_MOD "<==" +enum t_gui_buffer_type +{ + GUI_BUFFER_TYPE_FORMATED = 0, + GUI_BUFFER_TYPE_FREE, +}; -#define GUI_NOTIFY_LEVEL_MIN 0 -#define GUI_NOTIFY_LEVEL_MAX 3 -#define GUI_NOTIFY_LEVEL_DEFAULT GUI_NOTIFY_LEVEL_MAX +#define GUI_BUFFER_NOTIFY_LEVEL_MIN 0 +#define GUI_BUFFER_NOTIFY_LEVEL_MAX 3 +#define GUI_BUFFER_NOTIFY_LEVEL_DEFAULT GUI_BUFFER_NOTIFY_LEVEL_MAX #define GUI_TEXT_SEARCH_DISABLED 0 #define GUI_TEXT_SEARCH_BACKWARD 1 #define GUI_TEXT_SEARCH_FORWARD 2 -#define GUI_INPUT_BUFFER_BLOCK_SIZE 256 +#define GUI_BUFFER_INPUT_BLOCK_SIZE 256 /* buffer structures */ -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 */ - time_t date; /* date/time of line */ - char *nick; /* nickname for line (may be NULL) */ - char *data; /* line content */ - int ofs_after_date; /* offset to first char after date */ - int ofs_start_message; /* offset to first char after date/nick */ - t_gui_line *prev_line; /* link to previous line */ - t_gui_line *next_line; /* link to next line */ + time_t date; /* date/time of line */ + char *str_time; /* time string (for display) */ + char *prefix; /* prefix for line (may be NULL) */ + int prefix_length; /* prefix length (on screen) */ + char *message; /* line content (after prefix) */ + struct t_gui_line *prev_line; /* link to previous line */ + struct t_gui_line *next_line; /* link to next line */ }; -typedef struct t_gui_buffer t_gui_buffer; +struct t_gui_nick +{ + char *nick; /* nickname */ + int sort_index; /* index to force sort */ + int color_nick; /* color for nick in nicklist */ + char prefix; /* prefix for nick (for admins, ..) */ + int color_prefix; /* color for prefix */ + struct t_gui_nick *prev_nick; /* link to previous nick in nicklist */ + struct t_gui_nick *next_nick; /* link to next nick in nicklist */ +}; struct t_gui_buffer { - int num_displayed; /* number of windows displaying buffer */ - - int number; /* buffer number (for jump/switch) */ + void *plugin; /* plugin which created this buffer */ + /* (NULL for a WeeChat buffer) */ + int number; /* buffer number (for jump/switch) */ + char *category; /* category name */ + char *name; /* buffer name */ + enum t_gui_buffer_type type; /* buffer type (formated, free, ..) */ + int notify_level; /* 0 = never */ + /* 1 = highlight only */ + /* 2 = highlight + msg */ + /* 3 = highlight + msg + join/part */ + int num_displayed; /* number of windows displaying buf. */ - /* server/channel */ - void *server; /* buffer's server */ - int all_servers; /* =1 if all servers are displayed here */ - void *channel; /* buffer's channel */ - int type; /* type: standard (server/channel/pv), */ - /* dcc or raw data */ + /* logging */ + char *log_filename; /* filename for saving content */ + FILE *log_file; /* file descriptor for log */ - /* chat content (lines, line is composed by many messages) */ - t_gui_line *lines; /* lines of chat window */ - t_gui_line *last_line; /* last line of chat window */ - t_gui_line *last_read_line; /* last read line before jump */ - int num_lines; /* number of lines in the window */ - int line_complete; /* current line complete ? (\n ending) */ + /* buffer title */ + char *title; /* buffer title */ - /* notify level: when activity should be displayed? default: 3 (always) */ - int notify_level; /* 0 = never */ - /* 1 = highlight only */ - /* 2 = highlight + message */ - /* 3 = highlight + message + join/part */ + /* chat content */ + struct t_gui_line *lines; /* lines of chat window */ + struct t_gui_line *last_line; /* last line of chat window */ + struct t_gui_line *last_read_line; /* last read line before jump */ + int lines_count; /* number of lines in the buffer */ + int prefix_max_length; /* length for prefix align */ + int chat_refresh_needed; /* if refresh is needed (printf) */ - /* file to save buffer content */ - char *log_filename; /* filename for saving buffer content */ - FILE *log_file; /* for logging buffer to file */ + /* nicklist */ + int nicklist; /* = 1 if nicklist is enabled */ + int nick_case_sensitive; /* nicks are case sensitive ? */ + struct t_gui_nick *nicks; /* pointer to nicks for nicklist */ + struct t_gui_nick *last_nick; /* last nick in nicklist */ + int nick_max_length; /* max length for a nick */ + int nicks_count; /* number of nicks on buffer */ - /* inupt buffer */ - int has_input; /* = 1 if buffer has input (DCC has not)*/ - char *input_buffer; /* input buffer */ - char *input_buffer_color_mask; /* color mask for input buffer */ - int input_buffer_alloc; /* input buffer: allocated size in mem */ - 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 */ + /* inupt */ + int input; /* = 1 if input is enabled */ + void (*input_data_cb)(struct t_gui_buffer *, char *); + /* called when user send data */ + /* to this buffer */ + char *input_nick; /* self nick */ + char *input_buffer; /* input buffer */ + char *input_buffer_color_mask; /* color mask for 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 */ /* completion */ - t_completion completion; /* for cmds/nicks completion */ + struct t_gui_completion *completion; /* completion */ /* history */ - t_history *history; /* commands history */ - t_history *last_history; /* last command in history */ - t_history *ptr_history; /* current command in history */ - int num_history; /* number of commands in 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 */ + 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 */ /* link to previous/next buffer */ - t_gui_buffer *prev_buffer; /* link to previous buffer */ - t_gui_buffer *next_buffer; /* link to next buffer */ + struct t_gui_buffer *prev_buffer; /* link to previous buffer */ + struct t_gui_buffer *next_buffer; /* link to next buffer */ }; /* buffer variables */ -extern t_gui_buffer *gui_buffers; -extern t_gui_buffer *last_gui_buffer; -extern t_gui_buffer *gui_previous_buffer; -extern t_gui_buffer *gui_buffer_before_dcc; -extern t_gui_buffer *gui_buffer_raw_data; -extern t_gui_buffer *gui_buffer_before_raw_data; +extern struct t_gui_buffer *gui_buffers; +extern struct t_gui_buffer *last_gui_buffer; +extern struct t_gui_buffer *gui_previous_buffer; +extern struct t_gui_buffer *gui_buffer_before_dcc; +extern struct t_gui_buffer *gui_buffer_raw_data; +extern struct t_gui_buffer *gui_buffer_before_raw_data; + +/* buffer functions */ + +extern struct t_gui_buffer *gui_buffer_new (void *, char *, char *); +extern int gui_buffer_valid (struct t_gui_buffer *); +extern void gui_buffer_set_category (struct t_gui_buffer *, char *); +extern void gui_buffer_set_name (struct t_gui_buffer *, char *); +extern void gui_buffer_set_log (struct t_gui_buffer *, char *); +extern void gui_buffer_set_title (struct t_gui_buffer *, char *); +extern void gui_buffer_set_nick_case_sensitive (struct t_gui_buffer *, int); +extern void gui_buffer_set_nick (struct t_gui_buffer *, char *); +extern struct t_gui_buffer *gui_buffer_search_by_category_name (char *, + char *); +extern struct t_gui_buffer *gui_buffer_search_by_number (int); +extern struct t_gui_window *gui_buffer_find_window (struct t_gui_buffer *); +extern void gui_buffer_find_context (void *, void *, + struct t_gui_window **, + struct t_gui_buffer **); +extern int gui_buffer_is_scrolled (struct t_gui_buffer *); +extern struct t_gui_buffer *gui_buffer_get_dcc (struct t_gui_window *); +extern void gui_buffer_clear (struct t_gui_buffer *); +extern void gui_buffer_clear_all (); +extern void gui_buffer_free (struct t_gui_buffer *, int); +extern void gui_buffer_switch_previous (struct t_gui_window *); +extern void gui_buffer_switch_next (struct t_gui_window *); +extern void gui_buffer_switch_dcc (struct t_gui_window *); +extern void gui_buffer_switch_raw_data (struct t_gui_window *); +extern struct t_gui_buffer *gui_buffer_switch_by_number (struct t_gui_window *, + int); +extern void gui_buffer_move_to_number (struct t_gui_buffer *, int); +extern void gui_buffer_dump_hexa (struct t_gui_buffer *); +extern void gui_buffer_print_log (); #endif /* gui-buffer.h */ |