diff options
Diffstat (limited to 'src/gui')
37 files changed, 380 insertions, 307 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 1558c4708..834583877 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -31,6 +31,7 @@ #include "../../core/wee-config.h" #include "../../core/wee-string.h" #include "../../core/wee-utf8.h" +#include "../gui-buffer.h" #include "../gui-chat.h" #include "../gui-color.h" #include "../gui-main.h" @@ -849,13 +850,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, } /* - * gui_chat_calculate_line_diff: returns pointer to line & offset for a difference - * with given line + * gui_chat_calculate_line_diff: returns pointer to line & offset for a + * difference with given line */ void -gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **line, - int *line_pos, int difference) +gui_chat_calculate_line_diff (struct t_gui_window *window, + struct t_gui_line **line, int *line_pos, + int difference) { int backward, current_size; diff --git a/src/gui/curses/gui-curses-input.c b/src/gui/curses/gui-curses-input.c index 68eefc5a8..657ca3962 100644 --- a/src/gui/curses/gui-curses-input.c +++ b/src/gui/curses/gui-curses-input.c @@ -32,6 +32,7 @@ #include "../../core/wee-utf8.h" #include "../../plugins/plugin.h" #include "../gui-input.h" +#include "../gui-buffer.h" #include "../gui-color.h" #include "../gui-keyboard.h" #include "../gui-main.h" diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c index 86f542606..89b5ed35b 100644 --- a/src/gui/curses/gui-curses-keyboard.c +++ b/src/gui/curses/gui-curses-keyboard.c @@ -31,6 +31,7 @@ #include "../../core/wee-utf8.h" #include "../../core/wee-string.h" #include "../gui-keyboard.h" +#include "../gui-buffer.h" #include "../gui-color.h" #include "../gui-input.h" #include "../gui-completion.h" diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index eebdade5c..e408161d2 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -37,6 +37,7 @@ #include "../../core/wee-util.h" #include "../../plugins/plugin.h" #include "../gui-main.h" +#include "../gui-buffer.h" #include "../gui-chat.h" #include "../gui-color.h" #include "../gui-infobar.h" @@ -198,7 +199,7 @@ gui_main_end () /* delete all buffers */ while (gui_buffers) - gui_buffer_free (gui_buffers, 0); + gui_buffer_close (gui_buffers, 0); /* delete global history */ gui_history_global_free (); diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c index a0a253609..c97484076 100644 --- a/src/gui/curses/gui-curses-nicklist.c +++ b/src/gui/curses/gui-curses-nicklist.c @@ -30,6 +30,7 @@ #include "../../core/wee-string.h" #include "../../core/wee-utf8.h" #include "../gui-nicklist.h" +#include "../gui-buffer.h" #include "../gui-chat.h" #include "../gui-color.h" #include "../gui-main.h" diff --git a/src/gui/curses/gui-curses-status.c b/src/gui/curses/gui-curses-status.c index 9422a7f44..f941f197a 100644 --- a/src/gui/curses/gui-curses-status.c +++ b/src/gui/curses/gui-curses-status.c @@ -31,6 +31,7 @@ #include "../../core/wee-utf8.h" #include "../../plugins/plugin.h" #include "../gui-status.h" +#include "../gui-buffer.h" #include "../gui-color.h" #include "../gui-main.h" #include "../gui-hotlist.h" diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 8fce32f39..cdc650ca3 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -34,6 +34,7 @@ #include "../../core/wee-log.h" #include "../../core/wee-string.h" #include "../gui-window.h" +#include "../gui-buffer.h" #include "../gui-chat.h" #include "../gui-color.h" #include "../gui-hotlist.h" @@ -77,7 +78,7 @@ gui_window_objects_init (struct t_gui_window *window) { struct t_gui_curses_objects *new_objects; - if ((new_objects = (struct t_gui_curses_objects *) malloc (sizeof (struct t_gui_curses_objects)))) + if ((new_objects = (struct t_gui_curses_objects *)malloc (sizeof (struct t_gui_curses_objects)))) { window->gui_objects = new_objects; GUI_CURSES(window)->win_title = NULL; diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 2801b6862..f1e6aea17 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -50,12 +50,13 @@ extern struct t_gui_color gui_weechat_colors[]; extern int gui_refresh_screen_needed; /* color functions */ -extern int gui_color_get_pair (int); +extern int gui_color_get_pair (int num_color); extern void gui_color_init (); /* chat functions */ -extern void gui_chat_calculate_line_diff (struct t_gui_window *, - struct t_gui_line **, int *, int); +extern void gui_chat_calculate_line_diff (struct t_gui_window *window, + struct t_gui_line **line, + int *line_pos, int difference); /* keyboard functions */ extern void gui_keyboard_default_bindings (); @@ -63,9 +64,9 @@ extern void gui_keyboard_read (); extern void gui_keyboard_flush (); /* window functions */ -extern void gui_window_wprintw (WINDOW *, char *, ...); -extern void gui_window_curses_clear (WINDOW *, int); -extern void gui_window_set_weechat_color (WINDOW *, int); +extern void gui_window_wprintw (WINDOW *window, char *data, ...); +extern void gui_window_curses_clear (WINDOW *window, int num_color); +extern void gui_window_set_weechat_color (WINDOW *window, int num_color); extern void gui_window_refresh_screen_sigwinch (); extern void gui_window_title_set (); extern void gui_window_title_reset (); diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c index 97a11ddb8..4760eb62a 100644 --- a/src/gui/gtk/gui-gtk-chat.c +++ b/src/gui/gtk/gui-gtk-chat.c @@ -30,6 +30,7 @@ #include "../../core/weechat.h" #include "../../core/wee-config.h" #include "../../core/wee-utf8.h" +#include "../gui-buffer.h" #include "../gui-chat.h" #include "../gui-color.h" #include "../gui-main.h" diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c index 33d1fc9b2..4a316fcc8 100644 --- a/src/gui/gtk/gui-gtk-main.c +++ b/src/gui/gtk/gui-gtk-main.c @@ -34,6 +34,7 @@ #include "../../core/wee-utf8.h" #include "../../plugins/plugin.h" #include "../gui-main.h" +#include "../gui-buffer.h" #include "../gui-history.h" #include "../gui-infobar.h" #include "../gui-input.h" @@ -211,7 +212,7 @@ gui_main_end () /* delete all buffers */ while (gui_buffers) - gui_buffer_free (gui_buffers, 0); + gui_buffer_close (gui_buffers, 0); /* delete all windows */ while (gui_windows) diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c index c00813f3a..bbb11c326 100644 --- a/src/gui/gtk/gui-gtk-window.c +++ b/src/gui/gtk/gui-gtk-window.c @@ -30,6 +30,7 @@ #include "../../core/wee-config.h" #include "../../core/wee-log.h" #include "../gui-window.h" +#include "../gui-buffer.h" #include "../gui-chat.h" #include "../gui-hotlist.h" #include "../gui-nicklist.h" @@ -67,7 +68,7 @@ gui_window_objects_init (struct t_gui_window *window) { struct t_gui_gtk_objects *new_objects; - if ((new_objects = (struct t_gui_gtk_objects *) malloc (sizeof (struct t_gui_gtk_objects)))) + if ((new_objects = (struct t_gui_gtk_objects *)malloc (sizeof (struct t_gui_gtk_objects)))) { window->gui_objects = new_objects; GUI_GTK(window)->textview_chat = NULL; diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h index e88e0ae2e..6bea6943d 100644 --- a/src/gui/gtk/gui-gtk.h +++ b/src/gui/gtk/gui-gtk.h @@ -22,6 +22,9 @@ #include <gtk/gtk.h> +struct t_gui_window; +struct t_gui_line; + /* TODO: remove these temporary defines */ #define A_BOLD 1 @@ -78,12 +81,13 @@ extern GtkWidget *gui_gtk_entry_input; extern GtkWidget *gui_gtk_label1; /* color functions */ -extern int gui_color_get_pair (int); +extern int gui_color_get_pair (int num_color); extern void gui_color_init (); /* chat functions */ -extern void gui_chat_calculate_line_diff (struct t_gui_window *, - struct t_gui_line **, int *, int); +extern void gui_chat_calculate_line_diff (struct t_gui_window *window, + struct t_gui_line **line, + int *line_pos, int difference); /* keyboard functions */ extern void gui_keyboard_default_bindings (); @@ -91,7 +95,7 @@ extern void gui_keyboard_read (); extern void gui_keyboard_flush (); /* window functions */ -extern void gui_window_set_title (); -extern void gui_window_reset_title (); +extern void gui_window_title_set (); +extern void gui_window_title_reset (); #endif /* gui-gtk.h */ diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c index daef042a6..87cd9b308 100644 --- a/src/gui/gui-action.c +++ b/src/gui/gui-action.c @@ -37,6 +37,7 @@ #include "../core/wee-log.h" #include "../core/wee-string.h" #include "../core/wee-utf8.h" +#include "gui-action.h" #include "gui-buffer.h" #include "gui-chat.h" #include "gui-completion.h" @@ -62,7 +63,7 @@ gui_action_clipboard_copy (char *buffer, int size) if (gui_input_clipboard != NULL) free (gui_input_clipboard); - gui_input_clipboard = (char *) malloc( (size + 1) * sizeof(*gui_input_clipboard)); + gui_input_clipboard = (char *)malloc( (size + 1) * sizeof(*gui_input_clipboard)); if (gui_input_clipboard) { diff --git a/src/gui/gui-action.h b/src/gui/gui-action.h index 8588beb91..cc4bf564d 100644 --- a/src/gui/gui-action.h +++ b/src/gui/gui-action.h @@ -22,58 +22,58 @@ /* action functions */ -extern void gui_action_clipboard_copy (char *, int); -extern void gui_action_clipboard_paste (char *); -extern void gui_action_return (char *); -extern void gui_action_tab (char *); -extern void gui_action_tab_previous (char *); -extern void gui_action_backspace (char *); -extern void gui_action_delete (char *); -extern void gui_action_delete_previous_word (char *); -extern void gui_action_delete_next_word (char *); -extern void gui_action_delete_begin_of_line (char *); -extern void gui_action_delete_end_of_line (char *); -extern void gui_action_delete_line (char *); -extern void gui_action_transpose_chars (char *); -extern void gui_action_home (char *); -extern void gui_action_end (char *); -extern void gui_action_left (char *); -extern void gui_action_previous_word (char *); -extern void gui_action_right (char *); -extern void gui_action_next_word (char *); -extern void gui_action_up (char *); -extern void gui_action_up_global (char *); -extern void gui_action_down (char *); -extern void gui_action_down_global (char *); -extern void gui_action_page_up (char *); -extern void gui_action_page_down (char *); -extern void gui_action_scroll_up (char *); -extern void gui_action_scroll_down (char *); -extern void gui_action_scroll_top (char *); -extern void gui_action_scroll_bottom (char *); -extern void gui_action_scroll_topic_left (char *); -extern void gui_action_scroll_topic_right (char *); -extern void gui_action_nick_beginning (char *); -extern void gui_action_nick_end (char *); -extern void gui_action_nick_page_up (char *); -extern void gui_action_nick_page_down (char *); -extern void gui_action_jump_smart (char *); -extern void gui_action_jump_dcc (char *); -extern void gui_action_jump_raw_data (char *); -extern void gui_action_jump_last_buffer (char *); -extern void gui_action_jump_previous_buffer (char *); -extern void gui_action_jump_server (char *); -extern void gui_action_jump_next_server (char *); -extern void gui_action_switch_server (char *); -extern void gui_action_scroll_previous_highlight (char *); -extern void gui_action_scroll_next_highlight (char *); -extern void gui_action_scroll_unread (char *); -extern void gui_action_set_unread (char *); -extern void gui_action_hotlist_clear (char *); -extern void gui_action_infobar_clear (char *); -extern void gui_action_refresh_screen (char *); -extern void gui_action_grab_key (char *); -extern void gui_action_insert_string (char *); -extern void gui_action_search_text (char *); +extern void gui_action_clipboard_copy (char *buffer, int size); +extern void gui_action_clipboard_paste (char *args); +extern void gui_action_return (char *args); +extern void gui_action_tab (char *args); +extern void gui_action_tab_previous (char *args); +extern void gui_action_backspace (char *args); +extern void gui_action_delete (char *args); +extern void gui_action_delete_previous_word (char *args); +extern void gui_action_delete_next_word (char *args); +extern void gui_action_delete_begin_of_line (char *args); +extern void gui_action_delete_end_of_line (char *args); +extern void gui_action_delete_line (char *args); +extern void gui_action_transpose_chars (char *args); +extern void gui_action_home (char *args); +extern void gui_action_end (char *args); +extern void gui_action_left (char *args); +extern void gui_action_previous_word (char *args); +extern void gui_action_right (char *args); +extern void gui_action_next_word (char *args); +extern void gui_action_up (char *args); +extern void gui_action_up_global (char *args); +extern void gui_action_down (char *args); +extern void gui_action_down_global (char *args); +extern void gui_action_page_up (char *args); +extern void gui_action_page_down (char *args); +extern void gui_action_scroll_up (char *args); +extern void gui_action_scroll_down (char *args); +extern void gui_action_scroll_top (char *args); +extern void gui_action_scroll_bottom (char *args); +extern void gui_action_scroll_topic_left (char *args); +extern void gui_action_scroll_topic_right (char *args); +extern void gui_action_nick_beginning (char *args); +extern void gui_action_nick_end (char *args); +extern void gui_action_nick_page_up (char *args); +extern void gui_action_nick_page_down (char *args); +extern void gui_action_jump_smart (char *args); +extern void gui_action_jump_dcc (char *args); +extern void gui_action_jump_raw_data (char *args); +extern void gui_action_jump_last_buffer (char *args); +extern void gui_action_jump_previous_buffer (char *args); +extern void gui_action_jump_server (char *args); +extern void gui_action_jump_next_server (char *args); +extern void gui_action_switch_server (char *args); +extern void gui_action_scroll_previous_highlight (char *args); +extern void gui_action_scroll_next_highlight (char *args); +extern void gui_action_scroll_unread (char *args); +extern void gui_action_set_unread (char *args); +extern void gui_action_hotlist_clear (char *args); +extern void gui_action_infobar_clear (char *args); +extern void gui_action_refresh_screen (char *args); +extern void gui_action_grab_key (char *args); +extern void gui_action_insert_string (char *args); +extern void gui_action_search_text (char *args); #endif /* gui-action.h */ diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index c88c38f30..74f7d6514 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -65,8 +65,8 @@ struct t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buf. before raw */ */ struct t_gui_buffer * -gui_buffer_new (void *plugin, char *category, char *name, - void (*input_data_cb)(struct t_gui_buffer *, char *)) +gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name, + void (*callback_input_data)(struct t_gui_buffer *buffer, char *data)) { struct t_gui_buffer *new_buffer; struct t_gui_completion *new_completion; @@ -121,11 +121,11 @@ gui_buffer_new (void *plugin, char *category, char *name, /* input */ new_buffer->input = 1; - new_buffer->input_data_cb = input_data_cb; + new_buffer->input_data_cb = callback_input_data; new_buffer->input_nick = NULL; new_buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE; - new_buffer->input_buffer = (char *) malloc (GUI_BUFFER_INPUT_BLOCK_SIZE); - new_buffer->input_buffer_color_mask = (char *) malloc (GUI_BUFFER_INPUT_BLOCK_SIZE); + new_buffer->input_buffer = (char *)malloc (GUI_BUFFER_INPUT_BLOCK_SIZE); + new_buffer->input_buffer_color_mask = (char *)malloc (GUI_BUFFER_INPUT_BLOCK_SIZE); new_buffer->input_buffer[0] = '\0'; new_buffer->input_buffer_color_mask[0] = '\0'; new_buffer->input_buffer_size = 0; @@ -174,7 +174,7 @@ gui_buffer_new (void *plugin, char *category, char *name, gui_window_redraw_buffer (new_buffer); } - hook_signal_exec ("buffer_open", new_buffer); + hook_signal_send ("buffer_open", new_buffer); } else return NULL; @@ -572,17 +572,17 @@ gui_buffer_clear_all () } /* - * gui_buffer_free: delete a buffer + * gui_buffer_close: close a buffer */ void -gui_buffer_free (struct t_gui_buffer *buffer, int switch_to_another) +gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another) { struct t_gui_window *ptr_window; struct t_gui_buffer *ptr_buffer; struct t_gui_line *ptr_line; - hook_signal_exec ("buffer_close", buffer); + hook_signal_send ("buffer_close", buffer); if (switch_to_another) { diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 975f28c92..7ffb52e0e 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -50,17 +50,6 @@ struct t_gui_line struct t_gui_line *next_line; /* link to next line */ }; -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 { struct t_weechat_plugin *plugin; /* plugin which created this buffer */ @@ -96,7 +85,7 @@ struct t_gui_buffer /* inupt */ int input; /* = 1 if input is enabled */ - void (*input_data_cb)(struct t_gui_buffer *, char *); + void (*input_data_cb)(struct t_gui_buffer *buffer, char *data); /* called when user send data */ /* to this buffer */ char *input_nick; /* self nick */ @@ -139,38 +128,40 @@ extern struct t_gui_buffer *gui_buffer_before_raw_data; /* buffer functions */ -extern struct t_gui_buffer *gui_buffer_new (void *, char *, char *, - void (*)(struct t_gui_buffer *, char *)); -extern int gui_buffer_valid (struct t_gui_buffer *); -extern void *gui_buffer_get (struct t_gui_buffer *, char *); -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 void gui_buffer_set (struct t_gui_buffer *, char *, char *); +extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin, + char *category, char *name, + void (*input_data_cb)(struct t_gui_buffer *buffer, + char *data)); +extern int gui_buffer_valid (struct t_gui_buffer *buffer); +extern void *gui_buffer_get (struct t_gui_buffer *buffer, char *property); +extern void gui_buffer_set_category (struct t_gui_buffer *buffer, + char *category); +extern void gui_buffer_set_name (struct t_gui_buffer *buffer, char *name); +extern void gui_buffer_set_title (struct t_gui_buffer *buffer, char *new_title); +extern void gui_buffer_set_nicklist (struct t_gui_buffer *buffer, int nicklist); +extern void gui_buffer_set_nick_case_sensitive (struct t_gui_buffer * buffer, + int nick_case_sensitive); +extern void gui_buffer_set_nick (struct t_gui_buffer *buffer, char *new_nick); +extern void gui_buffer_set (struct t_gui_buffer *buffer, char *property, + char *value); extern struct t_gui_buffer *gui_buffer_search_main (); -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 struct t_gui_buffer *gui_buffer_search_by_category_name (char *category, + char *name); +extern struct t_gui_buffer *gui_buffer_search_by_number (int number); +extern struct t_gui_window *gui_buffer_find_window (struct t_gui_buffer *buffer); +extern int gui_buffer_is_scrolled (struct t_gui_buffer *buffer); +extern struct t_gui_buffer *gui_buffer_get_dcc (struct t_gui_window *window); +extern void gui_buffer_clear (struct t_gui_buffer *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_close (struct t_gui_buffer *buffer, int switch_to_another); +extern void gui_buffer_switch_previous (struct t_gui_window *window); +extern void gui_buffer_switch_next (struct t_gui_window *window); +extern void gui_buffer_switch_dcc (struct t_gui_window *window); +extern void gui_buffer_switch_raw_data (struct t_gui_window *window); +extern struct t_gui_buffer *gui_buffer_switch_by_number (struct t_gui_window *window, + int number); +extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number); +extern void gui_buffer_dump_hexa (struct t_gui_buffer *buffer); extern void gui_buffer_print_log (); #endif /* gui-buffer.h */ diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 94b25fc55..cf0c5e69b 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -35,6 +35,7 @@ #include "../core/wee-string.h" #include "../core/wee-utf8.h" #include "gui-chat.h" +#include "gui-buffer.h" #include "gui-color.h" #include "gui-hotlist.h" #include "gui-main.h" @@ -409,7 +410,7 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, { struct t_gui_line *new_line, *ptr_line; - new_line = (struct t_gui_line *) malloc (sizeof (struct t_gui_line)); + new_line = (struct t_gui_line *)malloc (sizeof (struct t_gui_line)); if (!new_line) { log_printf (_("Not enough memory for new line")); diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h index 99b0c2ee0..3da67508f 100644 --- a/src/gui/gui-chat.h +++ b/src/gui/gui-chat.h @@ -20,7 +20,9 @@ #ifndef __WEECHAT_GUI_CHAT_H #define __WEECHAT_GUI_CHAT_H 1 -#include "gui-buffer.h" +struct t_gui_window; +struct t_gui_buffer; +struct t_gui_line; #define gui_chat_printf(buffer, argz...) \ gui_chat_printf_date(buffer, 0, ##argz) \ @@ -44,24 +46,33 @@ extern int gui_chat_time_length; /* chat functions */ extern void gui_chat_prefix_build (); -extern int gui_chat_strlen_screen (char *); -extern int gui_chat_string_real_pos (char *, int); -extern void gui_chat_get_word_info (struct t_gui_window *, - char *, int *, int *, int *, int *); +extern int gui_chat_strlen_screen (char *string); +extern int gui_chat_string_real_pos (char *string, int pos); +extern void gui_chat_get_word_info (struct t_gui_window *window, + char *data, int *word_start_offset, + int *word_end_offset, + int *word_length_with_spaces, + int *word_length); extern void gui_chat_change_time_format (); -extern int gui_chat_get_line_align (struct t_gui_buffer *, - struct t_gui_line *, int); -extern int gui_chat_line_search (struct t_gui_line *, char *, int); -extern void gui_chat_line_free (struct t_gui_line *); -extern void gui_chat_printf_date (struct t_gui_buffer *, time_t, char *, ...); -extern void gui_chat_printf_raw_data (void *, int, int, char *); +extern int gui_chat_get_line_align (struct t_gui_buffer *buffer, + struct t_gui_line *line, + int with_suffix); +extern int gui_chat_line_search (struct t_gui_line *line, char *text, + int case_sensitive); +extern void gui_chat_line_free (struct t_gui_line *line); +extern void gui_chat_printf_date (struct t_gui_buffer *buffer, time_t date, + char *message, ...); +extern void gui_chat_printf_raw_data (void *server, int send, int modified, + char *message); /* chat functions (GUI dependent) */ -extern void gui_chat_draw_title (struct t_gui_buffer *, int); -extern char *gui_chat_string_next_char (struct t_gui_window *, unsigned char *, - int); -extern void gui_chat_draw (struct t_gui_buffer *, int); -extern void gui_chat_draw_line (struct t_gui_buffer *, struct t_gui_line *); +extern void gui_chat_draw_title (struct t_gui_buffer *buffer, int erase); +extern char *gui_chat_string_next_char (struct t_gui_window *window, + unsigned char *string, + int apply_style); +extern void gui_chat_draw (struct t_gui_buffer *buffer, int erase); +extern void gui_chat_draw_line (struct t_gui_buffer *buffer, + struct t_gui_line *line); #endif /* gui-chat.h */ diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index 090e64f37..263805c0e 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -142,13 +142,13 @@ extern struct t_gui_color *gui_color[GUI_NUM_COLORS]; /* color functions */ -extern int gui_color_search_config (char *); -extern unsigned char *gui_color_decode (unsigned char *); +extern int gui_color_search_config (char *color_name); +extern unsigned char *gui_color_decode (unsigned char *string); /* color functions (GUI dependent) */ -extern int gui_color_assign (int *, char *); -extern char *gui_color_get_name (int); +extern int gui_color_assign (int *color, char *color_name); +extern char *gui_color_get_name (int num_color); extern void gui_color_init_pairs (); extern void gui_color_rebuild_weechat (); diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 3689830ed..d87f506d4 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -228,7 +228,7 @@ gui_completion_nickncmp (char *base_word, char *nick, int max) void gui_completion_list_add (struct t_gui_completion *completion, char *word, - int nick_completion, int position) + int nick_completion, char *where) { if (!word || !word[0]) return; @@ -239,8 +239,7 @@ gui_completion_list_add (struct t_gui_completion *completion, char *word, || (!nick_completion && (string_strncasecmp (completion->base_word, word, strlen (completion->base_word)) == 0))) { - weelist_add (completion->completion_list, - word, position); + weelist_add (completion->completion_list, word, where); } } @@ -296,7 +295,7 @@ gui_completion_list_add_filename (struct t_gui_completion *completion) char home[3] = { '~', DIR_SEPARATOR_CHAR, '\0' }; buffer_len = PATH_MAX; - buffer = (char *) malloc (buffer_len * sizeof (char)); + buffer = (char *)malloc (buffer_len * sizeof (char)); if (!buffer) return; @@ -880,7 +879,7 @@ gui_completion_find_context (struct t_gui_completion *completion, char *data, if (pos_start <= pos_end) { completion->position_replace = pos_start; - completion->base_word = (char *) malloc (pos_end - pos_start + 2); + completion->base_word = (char *)malloc (pos_end - pos_start + 2); for (i = pos_start; i <= pos_end; i++) completion->base_word[i - pos_start] = data[i]; completion->base_word[pos_end - pos_start + 1] = '\0'; @@ -905,7 +904,7 @@ gui_completion_find_context (struct t_gui_completion *completion, char *data, if (data[pos_end] == ' ') pos_end--; - completion->base_command = (char *) malloc (pos_end - pos_start + 2); + completion->base_command = (char *)malloc (pos_end - pos_start + 2); for (i = pos_start; i <= pos_end; i++) completion->base_command[i - pos_start] = data[i]; completion->base_command[pos_end - pos_start + 1] = '\0'; diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h index e66c16ce7..a0c1806a5 100644 --- a/src/gui/gui-completion.h +++ b/src/gui/gui-completion.h @@ -53,9 +53,12 @@ struct t_gui_completion /* completion functions */ -extern void gui_completion_init (struct t_gui_completion *, struct t_gui_buffer *); -extern void gui_completion_free (struct t_gui_completion *); -extern void gui_completion_search (struct t_gui_completion *, int, char *, int, int); -extern void gui_completion_print_log (struct t_gui_completion *); +extern void gui_completion_init (struct t_gui_completion *completion, + struct t_gui_buffer *buffer); +extern void gui_completion_free (struct t_gui_completion *completion); +extern void gui_completion_search (struct t_gui_completion *completion, + int direction, char *data, int size, + int pos); +extern void gui_completion_print_log (struct t_gui_completion *completion); #endif /* gui-completion.h */ diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c index 971d5690a..ccf0c0bb5 100644 --- a/src/gui/gui-history.c +++ b/src/gui/gui-history.c @@ -44,19 +44,16 @@ int num_history_global = 0; */ void -gui_history_buffer_add (void *buffer, char *string) +gui_history_buffer_add (struct t_gui_buffer *buffer, char *string) { - struct t_gui_buffer *ptr_buffer; struct t_gui_history *new_history, *ptr_history; - - ptr_buffer = (struct t_gui_buffer *)buffer; if (!string) return; - if (!ptr_buffer->history - || (ptr_buffer->history - && (strcmp (ptr_buffer->history->text, string) != 0))) + if (!buffer->history + || (buffer->history + && (strcmp (buffer->history->text, string) != 0))) { new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history)); if (new_history) @@ -65,28 +62,28 @@ gui_history_buffer_add (void *buffer, char *string) /*if (config_log_hide_nickserv_pwd) irc_display_hide_password (new_history->text, 1);*/ - if (ptr_buffer->history) - ptr_buffer->history->prev_history = new_history; + if (buffer->history) + buffer->history->prev_history = new_history; else - ptr_buffer->last_history = new_history; - new_history->next_history = ptr_buffer->history; + buffer->last_history = new_history; + new_history->next_history = buffer->history; new_history->prev_history = NULL; - ptr_buffer->history = new_history; - ptr_buffer->num_history++; + buffer->history = new_history; + buffer->num_history++; /* remove one command if necessary */ if ((CONFIG_INTEGER(config_history_max_commands) > 0) - && (ptr_buffer->num_history > CONFIG_INTEGER(config_history_max_commands))) + && (buffer->num_history > CONFIG_INTEGER(config_history_max_commands))) { - ptr_history = ptr_buffer->last_history->prev_history; - if (ptr_buffer->ptr_history == ptr_buffer->last_history) - ptr_buffer->ptr_history = ptr_history; - ptr_buffer->last_history->prev_history->next_history = NULL; - if (ptr_buffer->last_history->text) - free (ptr_buffer->last_history->text); - free (ptr_buffer->last_history); - ptr_buffer->last_history = ptr_history; - ptr_buffer->num_history++; + ptr_history = buffer->last_history->prev_history; + if (buffer->ptr_history == buffer->last_history) + buffer->ptr_history = ptr_history; + buffer->last_history->prev_history->next_history = NULL; + if (buffer->last_history->text) + free (buffer->last_history->text); + free (buffer->last_history); + buffer->last_history = ptr_history; + buffer->num_history++; } } } @@ -171,23 +168,20 @@ gui_history_global_free () */ void -gui_history_buffer_free (void *buffer) +gui_history_buffer_free (struct t_gui_buffer *buffer) { - struct t_gui_buffer *ptr_buffer; struct t_gui_history *ptr_history; - ptr_buffer = (struct t_gui_buffer *)buffer; - - while (ptr_buffer->history) + while (buffer->history) { - ptr_history = ptr_buffer->history->next_history; - if (ptr_buffer->history->text) - free (ptr_buffer->history->text); - free (ptr_buffer->history); - ptr_buffer->history = ptr_history; + ptr_history = buffer->history->next_history; + if (buffer->history->text) + free (buffer->history->text); + free (buffer->history); + buffer->history = ptr_history; } - ptr_buffer->history = NULL; - ptr_buffer->last_history = NULL; - ptr_buffer->ptr_history = NULL; - ptr_buffer->num_history = 0; + buffer->history = NULL; + buffer->last_history = NULL; + buffer->ptr_history = NULL; + buffer->num_history = 0; } diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h index 40fedc71b..a97990b7d 100644 --- a/src/gui/gui-history.h +++ b/src/gui/gui-history.h @@ -20,6 +20,8 @@ #ifndef __WEECHAT_GUI_HISTORY_H #define __WEECHAT_GUI_HISTORY_H 1 +struct t_gui_buffer; + struct t_gui_history { char *text; /* text or command (entered by user) */ @@ -32,9 +34,9 @@ extern struct t_gui_history *history_global_last; extern struct t_gui_history *history_global_ptr; /* history functions (gui-history.c) */ -extern void gui_history_buffer_add (void *, char *); -extern void gui_history_global_add (char *); +extern void gui_history_buffer_add (struct t_gui_buffer *buffer, char *string); +extern void gui_history_global_add (char *string); extern void gui_history_global_free (); -extern void gui_history_buffer_free (void *); +extern void gui_history_buffer_free (struct t_gui_buffer *buffer); #endif /* gui-history.h */ diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c index 0e541beec..b741d5966 100644 --- a/src/gui/gui-hotlist.c +++ b/src/gui/gui-hotlist.c @@ -207,7 +207,8 @@ gui_hotlist_add (struct t_gui_buffer *buffer, int priority, gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist); } - if ((new_hotlist = (struct t_gui_hotlist *) malloc (sizeof (struct t_gui_hotlist))) == NULL) + new_hotlist = (struct t_gui_hotlist *)malloc (sizeof (struct t_gui_hotlist)); + if (!new_hotlist) { log_printf (_("Error: not enough memory to add a buffer to " "hotlist")); @@ -236,7 +237,8 @@ gui_hotlist_dup (struct t_gui_hotlist *hotlist) { struct t_gui_hotlist *new_hotlist; - if ((new_hotlist = (struct t_gui_hotlist *) malloc (sizeof (struct t_gui_hotlist)))) + new_hotlist = (struct t_gui_hotlist *)malloc (sizeof (struct t_gui_hotlist)); + if (new_hotlist) { new_hotlist->priority = hotlist->priority; memcpy (&(new_hotlist->creation_time), &(hotlist->creation_time), diff --git a/src/gui/gui-hotlist.h b/src/gui/gui-hotlist.h index 9cb664c5c..361831437 100644 --- a/src/gui/gui-hotlist.h +++ b/src/gui/gui-hotlist.h @@ -44,13 +44,16 @@ extern int gui_add_hotlist; /* hotlist functions */ -extern void gui_hotlist_add (struct t_gui_buffer *, int, struct timeval *, int); +extern void gui_hotlist_add (struct t_gui_buffer *buffer, int priority, + struct timeval *creation_time, + int allow_current_buffer); extern void gui_hotlist_resort (); -extern void gui_hotlist_free (struct t_gui_hotlist **, struct t_gui_hotlist **, - struct t_gui_hotlist *); -extern void gui_hotlist_free_all (struct t_gui_hotlist **, - struct t_gui_hotlist **); -extern void gui_hotlist_remove_buffer (struct t_gui_buffer *); +extern void gui_hotlist_free (struct t_gui_hotlist **hotlist, + struct t_gui_hotlist **last_hotlist, + struct t_gui_hotlist *ptr_hotlist); +extern void gui_hotlist_free_all (struct t_gui_hotlist **hotlist, + struct t_gui_hotlist **last_hotlist); +extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer); extern void gui_hotlist_print_log (); #endif /* gui-hotlist.h */ diff --git a/src/gui/gui-infobar.c b/src/gui/gui-infobar.c index 2f29dd5a8..97e82bae6 100644 --- a/src/gui/gui-infobar.c +++ b/src/gui/gui-infobar.c @@ -45,7 +45,7 @@ struct t_hook *gui_infobar_highlight_timer = NULL; /* highlight timer */ */ void -gui_infobar_printf (int time_displayed, int color, char *message, ...) +gui_infobar_printf (int delay, int color, char *message, ...) { static char buf[1024]; va_list argptr; @@ -70,7 +70,7 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...) pos = strchr (ptr_infobar->text, '\n'); if (pos) pos[0] = '\0'; - ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed; + ptr_infobar->remaining_time = (delay <= 0) ? -1 : delay; ptr_infobar->next_infobar = gui_infobar; gui_infobar = ptr_infobar; gui_infobar_draw (gui_current_window->buffer, 1); diff --git a/src/gui/gui-infobar.h b/src/gui/gui-infobar.h index 080c02110..d1b50406f 100644 --- a/src/gui/gui-infobar.h +++ b/src/gui/gui-infobar.h @@ -20,8 +20,6 @@ #ifndef __WEECHAT_GUI_INFOBAR_H #define __WEECHAT_GUI_INFOBAR_H 1 -#include "gui-buffer.h" - struct t_gui_infobar { int color; /* text color */ @@ -40,15 +38,15 @@ extern struct t_hook *gui_infobar_highlight_timer; /* infobar functions */ -extern void gui_infobar_printf (int, int, char *, ...); +extern void gui_infobar_printf (int delay, int color, char *message, ...); extern void gui_infobar_remove (); extern void gui_infobar_remove_all (); /* infobar functions (GUI dependent) */ -extern void gui_infobar_draw_time (struct t_gui_buffer *); -extern void gui_infobar_draw (struct t_gui_buffer *, int); -extern int gui_infobar_refresh_timer_cb (void *); -extern int gui_infobar_highlight_timer_cb (void *); +extern void gui_infobar_draw_time (struct t_gui_buffer *buffer); +extern void gui_infobar_draw (struct t_gui_buffer *buffer, int erase); +extern int gui_infobar_refresh_timer_cb (void *data); +extern int gui_infobar_highlight_timer_cb (void *data); #endif /* gui-infobar.h */ diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 3144e25c7..2eff275ce 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -31,11 +31,12 @@ #include "../core/wee-utf8.h" #include "../plugins/plugin.h" #include "gui-input.h" +#include "gui-buffer.h" #include "gui-completion.h" #include "gui-window.h" -char *gui_input_clipboard = NULL; /* clipboard content */ +char *gui_input_clipboard = NULL; /* clipboard content */ /* @@ -84,7 +85,8 @@ gui_input_init_color_mask (struct t_gui_buffer *buffer) */ void -gui_input_move (struct t_gui_buffer *buffer, char *target, char *source, int size) +gui_input_move (struct t_gui_buffer *buffer, char *target, char *source, + int size) { int pos_source, pos_target; @@ -148,7 +150,7 @@ gui_input_insert_string (struct t_gui_buffer *buffer, char *string, int pos) buffer->input_buffer_pos += length; - string2 = (char *) malloc (size + 2); + string2 = (char *)malloc (size + 2); if (string2) { snprintf (string2, size + 2, "*%s", string); @@ -510,10 +512,10 @@ gui_exec_action_raw_data (struct t_gui_window *window, char *actions) gui_window_switch_to_buffer (ptr_win, gui_buffer_before_raw_data); } - gui_buffer_free (ptr_buffer, 0); + gui_buffer_close (ptr_buffer, 0); } else - gui_buffer_free (window->buffer, 1); + gui_buffer_close (window->buffer, 1); gui_window_redraw_buffer (window->buffer); return; break; diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h index 54aebd3da..18fb98d4a 100644 --- a/src/gui/gui-input.h +++ b/src/gui/gui-input.h @@ -20,7 +20,7 @@ #ifndef __WEECHAT_GUI_INPUT_H #define __WEECHAT_GUI_INPUT_H 1 -#include "gui-buffer.h" +struct t_gui_buffer; /* input variables */ @@ -28,16 +28,18 @@ extern char *gui_input_clipboard; /* input functions */ -extern void gui_input_optimize_size (struct t_gui_buffer *); -extern void gui_input_init_color_mask (struct t_gui_buffer *); -extern void gui_input_move (struct t_gui_buffer *, char *, char *, int ); -extern int gui_input_insert_string (struct t_gui_buffer *, char *, int); -extern void gui_input_complete (struct t_gui_buffer *); -extern void gui_input_delete_line (struct t_gui_buffer *); -extern int gui_input_get_prompt_length (struct t_gui_buffer *); +extern void gui_input_optimize_size (struct t_gui_buffer *buffer); +extern void gui_input_init_color_mask (struct t_gui_buffer *buffer); +extern void gui_input_move (struct t_gui_buffer *buffer, char *target, + char *source, int size); +extern int gui_input_insert_string (struct t_gui_buffer *buffer, char *string, + int pos); +extern void gui_input_complete (struct t_gui_buffer *buffer); +extern void gui_input_delete_line (struct t_gui_buffer *buffer); +extern int gui_input_get_prompt_length (struct t_gui_buffer *buffer); /* input functions (GUI dependent) */ -extern void gui_input_draw (struct t_gui_buffer *, int); +extern void gui_input_draw (struct t_gui_buffer *buffer, int erase); #endif /* gui-input.h */ diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index edc519042..3c52f729e 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -34,6 +34,7 @@ #include "../plugins/plugin.h" #include "gui-keyboard.h" #include "gui-action.h" +#include "gui-buffer.h" #include "gui-completion.h" #include "gui-input.h" #include "gui-window.h" @@ -244,7 +245,7 @@ gui_keyboard_get_internal_code (char *key) { char *result; - if ((result = (char *) malloc (strlen (key) + 1))) + if ((result = (char *)malloc (strlen (key) + 1))) { result[0] = '\0'; while (key[0]) @@ -287,7 +288,7 @@ gui_keyboard_get_expanded_name (char *key) { char *result; - if ((result = (char *) malloc ((strlen (key) * 5) + 1))) + if ((result = (char *)malloc ((strlen (key) * 5) + 1))) { result[0] = '\0'; while (key[0]) @@ -390,7 +391,7 @@ gui_keyboard_new (char *key, char *command, t_gui_key_func *function, char *args char *internal_code; int length; - if ((new_key = (t_gui_key *) malloc (sizeof (t_gui_key)))) + if ((new_key = (t_gui_key *)malloc (sizeof (t_gui_key)))) { internal_code = gui_keyboard_get_internal_code (key); new_key->key = (internal_code) ? strdup (internal_code) : strdup (key); @@ -750,7 +751,7 @@ gui_keyboard_buffer_reset () { gui_keyboard_buffer_alloc = GUI_KEYBOARD_BUFFER_BLOCK_SIZE; gui_keyboard_buffer_size = 0; - gui_keyboard_buffer = (int *) malloc (gui_keyboard_buffer_alloc); + gui_keyboard_buffer = (int *)malloc (gui_keyboard_buffer_alloc); } else { diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h index c7e048edd..556e93a00 100644 --- a/src/gui/gui-keyboard.h +++ b/src/gui/gui-keyboard.h @@ -24,7 +24,7 @@ /* keyboard structures */ -typedef void (t_gui_key_func)(char *); +typedef void (t_gui_key_func)(char *args); typedef struct t_gui_key t_gui_key; @@ -52,7 +52,7 @@ struct t_gui_key_function extern t_gui_key *gui_keys; extern t_gui_key *last_gui_key; extern t_gui_key_function gui_key_functions[]; -extern char gui_key_combo_buffer[128]; +extern char gui_key_combo_buffer[]; extern int gui_key_grab; extern int gui_key_grab_count; extern int *gui_keyboard_buffer; @@ -65,18 +65,18 @@ extern time_t gui_keyboard_last_activity_time; extern void gui_keyboard_init (); extern void gui_keyboard_grab_init (); extern void gui_keyboard_grab_end (); -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 char *gui_keyboard_get_internal_code (char *key); +extern char *gui_keyboard_get_expanded_name (char *key); +extern t_gui_key *gui_keyboard_search (char *key); +extern t_gui_key_func *gui_keyboard_function_search_by_name (char *name); +extern char *gui_keyboard_function_search_by_ptr (t_gui_key_func *function); +extern t_gui_key *gui_keyboard_bind (char *key, char *command); +extern int gui_keyboard_unbind (char *key); +extern int gui_keyboard_pressed (char *key_str); +extern void gui_keyboard_free (t_gui_key *key); extern void gui_keyboard_free_all (); extern void gui_keyboard_buffer_reset (); -extern void gui_keyboard_buffer_add (int); +extern void gui_keyboard_buffer_add (int key); extern int gui_keyboard_get_paste_lines (); extern void gui_keyboard_paste_accept (); extern void gui_keyboard_paste_cancel (); diff --git a/src/gui/gui-main.h b/src/gui/gui-main.h index 04c3f2e24..f47c4965c 100644 --- a/src/gui/gui-main.h +++ b/src/gui/gui-main.h @@ -23,7 +23,7 @@ /* main functions (GUI dependent) */ extern void gui_main_loop (); -extern void gui_main_pre_init (int *, char **[]); +extern void gui_main_pre_init (int *argc, char **argv[]); extern void gui_main_init (); extern void gui_main_end (); diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index 03109d931..1433c5641 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -36,6 +36,8 @@ #include "../core/wee-string.h" #include "../core/wee-utf8.h" #include "gui-nicklist.h" +#include "gui-buffer.h" +#include "gui-color.h" /* @@ -171,9 +173,10 @@ gui_nicklist_search (struct t_gui_buffer *buffer, char *nick) struct t_gui_nick * gui_nicklist_add (struct t_gui_buffer *buffer, char *nick, int sort_index, - int color_nick, char prefix, int color_prefix) + char *color_nick, char prefix, char *color_prefix) { struct t_gui_nick *new_nick; + int num_color_nick, num_color_prefix; if (!nick || gui_nicklist_search (buffer, nick)) return NULL; @@ -182,11 +185,19 @@ gui_nicklist_add (struct t_gui_buffer *buffer, char *nick, int sort_index, if (!new_nick) return NULL; + num_color_nick = gui_color_search_config (color_nick); + if (num_color_nick < 0) + num_color_nick = GUI_COLOR_NICKLIST; + + num_color_prefix = gui_color_search_config (color_prefix); + if (num_color_prefix < 0) + num_color_prefix = GUI_COLOR_NICKLIST; + new_nick->nick = strdup (nick); new_nick->sort_index = sort_index; - new_nick->color_nick = color_nick; + new_nick->color_nick = num_color_nick; new_nick->prefix = prefix; - new_nick->color_prefix = color_prefix; + new_nick->color_prefix = num_color_prefix; gui_nicklist_insert_sorted (buffer, new_nick); @@ -202,20 +213,30 @@ gui_nicklist_add (struct t_gui_buffer *buffer, char *nick, int sort_index, void gui_nicklist_update (struct t_gui_buffer *buffer, struct t_gui_nick *nick, char *new_nick, int sort_index, - int color_nick, char prefix, int color_prefix) + char *color_nick, char prefix, char *color_prefix) { + int num_color_nick, num_color_prefix; + if (!nick) return; + num_color_nick = gui_color_search_config (color_nick); + if (num_color_nick < 0) + num_color_nick = GUI_COLOR_NICKLIST; + + num_color_prefix = gui_color_search_config (color_prefix); + if (num_color_prefix < 0) + num_color_prefix = GUI_COLOR_NICKLIST; + if (new_nick) { free (nick->nick); nick->nick = strdup (new_nick); } nick->sort_index = sort_index; - nick->color_nick = color_nick; + nick->color_nick = num_color_nick; nick->prefix = prefix; - nick->color_prefix = color_prefix; + nick->color_prefix = num_color_prefix; gui_nicklist_resort (buffer, nick); } diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h index b9cf4bd3b..a69a086b6 100644 --- a/src/gui/gui-nicklist.h +++ b/src/gui/gui-nicklist.h @@ -20,22 +20,40 @@ #ifndef __WEECHAT_GUI_NICKLIST_H #define __WEECHAT_GUI_NICKLIST_H 1 -#include "gui-buffer.h" +struct 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 */ +}; /* nicklist functions */ -extern struct t_gui_nick *gui_nicklist_search (struct t_gui_buffer *, char *); -extern struct t_gui_nick *gui_nicklist_add (struct t_gui_buffer *, char *, - int, int, char, int); -extern void gui_nicklist_update (struct t_gui_buffer *, struct t_gui_nick *, - char *, int, int, char, int); -extern void gui_nicklist_free (struct t_gui_buffer *, struct t_gui_nick *); -extern void gui_nicklist_free_all (struct t_gui_buffer *); -extern int gui_nicklist_remove (struct t_gui_buffer *, char *); -extern int gui_nicklist_get_max_length (struct t_gui_buffer *); +extern struct t_gui_nick *gui_nicklist_search (struct t_gui_buffer *buffer, + char *nick); +extern struct t_gui_nick *gui_nicklist_add (struct t_gui_buffer *buffer, + char *nick, + int sort_index, char *color_nick, + char prefix, char *color_prefix); +extern void gui_nicklist_update (struct t_gui_buffer *buffer, + struct t_gui_nick *nick, + char *new_nick, int sort_index, + char *color_nick, char prefix, + char *color_prefix); +extern void gui_nicklist_free (struct t_gui_buffer *buffer, + struct t_gui_nick *nick); +extern void gui_nicklist_free_all (struct t_gui_buffer *buffer); +extern int gui_nicklist_remove (struct t_gui_buffer *buffer, char *nick); +extern int gui_nicklist_get_max_length (struct t_gui_buffer *buffer); /* nicklist functions (GUI dependent) */ -extern void gui_nicklist_draw (struct t_gui_buffer *, int); +extern void gui_nicklist_draw (struct t_gui_buffer *buffer, int erase); #endif /* gui-nicklist.h */ diff --git a/src/gui/gui-status.h b/src/gui/gui-status.h index 0c19d6b36..706ef1a5b 100644 --- a/src/gui/gui-status.h +++ b/src/gui/gui-status.h @@ -20,10 +20,10 @@ #ifndef __WEECHAT_GUI_STATUS_H #define __WEECHAT_GUI_STATUS_H 1 -#include "gui-buffer.h" +struct t_gui_buffer; /* statusbar functions (GUI dependent) */ -extern void gui_status_draw (struct t_gui_buffer *, int); +extern void gui_status_draw (struct t_gui_buffer *buffer, int erase); #endif /* gui-status.h */ diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index 258a7154d..d5034935a 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -37,6 +37,7 @@ #include "../core/wee-log.h" #include "../core/wee-utf8.h" #include "gui-window.h" +#include "gui-buffer.h" #include "gui-chat.h" #include "gui-input.h" #include "gui-hotlist.h" diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h index e1aab192c..073e89929 100644 --- a/src/gui/gui-window.h +++ b/src/gui/gui-window.h @@ -123,61 +123,68 @@ extern struct t_gui_window *gui_current_window; extern struct t_gui_window_tree *gui_windows_tree; /* window functions */ -extern int gui_window_tree_init (struct t_gui_window *); -extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *, - struct t_gui_window *); -extern void gui_window_tree_free (struct t_gui_window_tree **); -extern struct t_gui_window *gui_window_new (struct t_gui_window *, int, int, - int, int, int, int); -extern void gui_window_free (struct t_gui_window *); -extern struct t_gui_window *gui_window_search_by_buffer (struct t_gui_buffer *); -extern void gui_window_switch_server (struct t_gui_window *); -extern void gui_window_switch_previous (struct t_gui_window *); -extern void gui_window_switch_next (struct t_gui_window *); -extern void gui_window_switch_by_buffer (struct t_gui_window *, int); -extern void gui_window_scroll (struct t_gui_window *, char *); -extern void gui_window_search_start (struct t_gui_window *); -extern void gui_window_search_restart (struct t_gui_window *); -extern void gui_window_search_stop (struct t_gui_window *); -extern int gui_window_search_text (struct t_gui_window *); +extern int gui_window_tree_init (struct t_gui_window *window); +extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *node, + struct t_gui_window *window); +extern void gui_window_tree_free (struct t_gui_window_tree **tree); +extern struct t_gui_window *gui_window_new (struct t_gui_window *parent, + int x, int y, int width, int height, + int width_pct, int height_pct); +extern void gui_window_free (struct t_gui_window *window); +extern struct t_gui_window *gui_window_search_by_buffer (struct t_gui_buffer *buffer); +extern void gui_window_switch_server (struct t_gui_window *window); +extern void gui_window_switch_previous (struct t_gui_window *window); +extern void gui_window_switch_next (struct t_gui_window *window); +extern void gui_window_switch_by_buffer (struct t_gui_window *window, + int buffer_number); +extern void gui_window_scroll (struct t_gui_window *window, char *scroll); +extern void gui_window_search_start (struct t_gui_window *window); +extern void gui_window_search_restart (struct t_gui_window *window); +extern void gui_window_search_stop (struct t_gui_window *window); +extern int gui_window_search_text (struct t_gui_window *window); extern void gui_window_print_log (); /* window functions (GUI dependent) */ extern int gui_window_get_width (); extern int gui_window_get_height (); -extern int gui_window_objects_init (struct t_gui_window *); -extern void gui_window_objects_free (struct t_gui_window *, int); -extern int gui_window_calculate_pos_size (struct t_gui_window *, int); -extern void gui_window_redraw_buffer (struct t_gui_buffer *); +extern int gui_window_objects_init (struct t_gui_window *window); +extern void gui_window_objects_free (struct t_gui_window *window, + int free_separator); +extern int gui_window_calculate_pos_size (struct t_gui_window *window, + int force_calculate); +extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer); extern void gui_window_redraw_all_buffers (); -extern void gui_window_switch_to_buffer (struct t_gui_window *, struct t_gui_buffer *); -extern void gui_window_page_up (struct t_gui_window *); -extern void gui_window_page_down (struct t_gui_window *); -extern void gui_window_scroll_up (struct t_gui_window *); -extern void gui_window_scroll_down (struct t_gui_window *); -extern void gui_window_scroll_top (struct t_gui_window *); -extern void gui_window_scroll_bottom (struct t_gui_window *); -extern void gui_window_scroll_topic_left (struct t_gui_window *); -extern void gui_window_scroll_topic_right (struct t_gui_window *); -extern void gui_window_nick_beginning (struct t_gui_window *); -extern void gui_window_nick_end (struct t_gui_window *); -extern void gui_window_nick_page_up (struct t_gui_window *); -extern void gui_window_nick_page_down (struct t_gui_window *); -extern void gui_window_init_subwindows (struct t_gui_window *); +extern void gui_window_switch_to_buffer (struct t_gui_window *window, + struct t_gui_buffer *buffer); +extern void gui_window_page_up (struct t_gui_window *window); +extern void gui_window_page_down (struct t_gui_window *window); +extern void gui_window_scroll_up (struct t_gui_window *window); +extern void gui_window_scroll_down (struct t_gui_window *window); +extern void gui_window_scroll_top (struct t_gui_window *window); +extern void gui_window_scroll_bottom (struct t_gui_window *window); +extern void gui_window_scroll_topic_left (struct t_gui_window *window); +extern void gui_window_scroll_topic_right (struct t_gui_window *window); +extern void gui_window_nick_beginning (struct t_gui_window *window); +extern void gui_window_nick_end (struct t_gui_window *window); +extern void gui_window_nick_page_up (struct t_gui_window *window); +extern void gui_window_nick_page_down (struct t_gui_window *window); +extern void gui_window_init_subwindows (struct t_gui_window *window); extern void gui_window_refresh_windows (); -extern void gui_window_split_horiz (struct t_gui_window *, int); -extern void gui_window_split_vertic (struct t_gui_window *, int); -extern void gui_window_resize (struct t_gui_window *, int); -extern int gui_window_merge (struct t_gui_window *); -extern void gui_window_merge_all (struct t_gui_window *); -extern void gui_window_switch_up (struct t_gui_window *); -extern void gui_window_switch_down (struct t_gui_window *); -extern void gui_window_switch_left (struct t_gui_window *); -extern void gui_window_switch_right (struct t_gui_window *); +extern void gui_window_split_horiz (struct t_gui_window *window, + int pourcentage); +extern void gui_window_split_vertic (struct t_gui_window *window, + int pourcentage); +extern void gui_window_resize (struct t_gui_window *window, int pourcentage); +extern int gui_window_merge (struct t_gui_window *window); +extern void gui_window_merge_all (struct t_gui_window *window); +extern void gui_window_switch_up (struct t_gui_window *window); +extern void gui_window_switch_down (struct t_gui_window *window); +extern void gui_window_switch_left (struct t_gui_window *window); +extern void gui_window_switch_right (struct t_gui_window *window); extern void gui_window_refresh_screen (); extern void gui_window_title_set (); extern void gui_window_title_reset (); -extern void gui_window_objects_print_log (struct t_gui_window *); +extern void gui_window_objects_print_log (struct t_gui_window *window); #endif /* gui-window.h */ |