diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2007-11-26 14:27:53 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2007-11-26 14:27:53 +0000 |
commit | f5d026a775cc940c16d23ee9559140f4606d8aff (patch) | |
tree | 7809ee4bd647a8985692ad781e638c431806f144 | |
parent | 7cc78f4172631fc67d10045518dc6c5ac63ac66a (diff) | |
download | weechat-f5d026a775cc940c16d23ee9559140f4606d8aff.zip |
Added input_data callback argument to gui_buffer_new() function
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 2 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-main.c | 2 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 5 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 3 | ||||
-rw-r--r-- | src/plugins/demo/demo.c | 26 | ||||
-rw-r--r-- | src/plugins/plugin-api.c | 5 | ||||
-rw-r--r-- | src/plugins/plugin-api.h | 3 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 8 |
8 files changed, 35 insertions, 19 deletions
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index c4870167b..7fbcd40cc 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -93,7 +93,7 @@ gui_main_init () if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100)) { gui_current_window = gui_windows; - ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat"); + ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL); if (ptr_buffer) { gui_init_ok = 1; diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c index bee6ff971..46fd7380c 100644 --- a/src/gui/gtk/gui-gtk-main.c +++ b/src/gui/gtk/gui-gtk-main.c @@ -162,7 +162,7 @@ gui_main_init () if (gui_window_new (NULL, 0, 0, 0, 0, 100, 100)) { gui_current_window = gui_windows; - ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat"); + ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL); if (ptr_buffer) { gui_init_ok = 1; diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 91bd41522..f4719d572 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -63,7 +63,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) +gui_buffer_new (void *plugin, char *category, char *name, + void (*input_data_cb)(struct t_gui_buffer *, char *)) { struct t_gui_buffer *new_buffer; struct t_gui_completion *new_completion; @@ -118,7 +119,7 @@ gui_buffer_new (void *plugin, char *category, char *name) /* input */ new_buffer->input = 1; - new_buffer->input_data_cb = NULL; + new_buffer->input_data_cb = input_data_cb; 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); diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 95985bd9f..8e3a11ddb 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -139,7 +139,8 @@ extern struct t_gui_buffer *gui_buffer_before_raw_data; /* buffer functions */ -extern struct t_gui_buffer *gui_buffer_new (void *, char *, char *); +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_set_category (struct t_gui_buffer *, char *); extern void gui_buffer_set_name (struct t_gui_buffer *, char *); diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c index d25e7d304..6797e5afc 100644 --- a/src/plugins/demo/demo.c +++ b/src/plugins/demo/demo.c @@ -49,23 +49,22 @@ demo_printf_command_cb (void *data, void *buffer, int argc, char **argv, { /* make C compiler happy */ (void) data; - (void) buffer; (void) argv; if (argc > 1) - weechat_printf (weechat_current_buffer, - "demo_printf: %s", argv_eol[1]); + weechat_printf (buffer, + "demo_printf: '%s'", argv_eol[1]); else { - weechat_printf (weechat_current_buffer, + weechat_printf (buffer, "demo message without prefix"); - weechat_printf (weechat_current_buffer, + weechat_printf (buffer, "%sdemo message with info prefix", weechat_prefix ("info")); - weechat_printf (weechat_current_buffer, + weechat_printf (buffer, "%sdemo message with error prefix", weechat_prefix ("error")); - weechat_printf (weechat_current_buffer, + weechat_printf (buffer, "colors: %s buffer %s nick1 %s nick2 %s nick3 " "%s nick4", weechat_color ("col_chat_buffer"), @@ -79,6 +78,16 @@ demo_printf_command_cb (void *data, void *buffer, int argc, char **argv, } /* + * demo_buffer_input_data_cb: callback for input data on buffer + */ + +static void +demo_buffer_input_data_cb (struct t_gui_buffer *buffer, char *data) +{ + weechat_printf (buffer, "buffer input_data_cb: data = '%s'", data); +} + +/* * demo_buffer_command_cb: demo command for creatig new buffer */ @@ -95,7 +104,8 @@ demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv, if (argc > 2) { - new_buffer = weechat_buffer_new (argv[1], argv[2]); + new_buffer = weechat_buffer_new (argv[1], argv[2], + demo_buffer_input_data_cb); if (new_buffer) weechat_buffer_set (new_buffer, "display", "1"); } diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 610855f7e..97202d154 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -554,10 +554,11 @@ plugin_api_unhook_all (struct t_weechat_plugin *plugin) struct t_gui_buffer * plugin_api_buffer_new (struct t_weechat_plugin *plugin, char *category, - char *name) + char *name, + void (*input_data_cb)(struct t_gui_buffer *, char *)) { if (plugin && name && name[0]) - return gui_buffer_new (plugin, category, name); + return gui_buffer_new (plugin, category, name, input_data_cb); return NULL; } diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h index 076003913..7dcb54361 100644 --- a/src/plugins/plugin-api.h +++ b/src/plugins/plugin-api.h @@ -84,7 +84,8 @@ extern void plugin_api_unhook_all (struct t_weechat_plugin *); /* buffers */ extern struct t_gui_buffer *plugin_api_buffer_new (struct t_weechat_plugin *, - char *, char *); + char *, char *, + void (*)(struct t_gui_buffer *, char *)); extern struct t_gui_buffer *plugin_api_buffer_search (struct t_weechat_plugin *, char *, char *); extern void plugin_api_buffer_close (struct t_weechat_plugin *, void *); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index d94b6748b..be24519d0 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -106,7 +106,8 @@ struct t_weechat_plugin /* buffers */ struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *, - char *, char *); + char *, char *, + void (*)(struct t_gui_buffer *, char *)); struct t_gui_buffer *(*buffer_search) (struct t_weechat_plugin *, char *, char *); void (*buffer_close) (struct t_weechat_plugin *, void *); @@ -210,8 +211,9 @@ struct t_weechat_plugin #define weechat_unhook_all() \ weechat_plugin->unhook(weechat_plugin) -#define weechat_buffer_new(category, name) \ - weechat_plugin->buffer_new(weechat_plugin, category, name) +#define weechat_buffer_new(category, name, input_data_cb) \ + weechat_plugin->buffer_new(weechat_plugin, category, name, \ + input_data_cb) #define weechat_buffer_search(category, name) \ weechat_plugin->buffer_search(weechat_plugin, category, name) #define weechat_current_buffer \ |