diff options
Diffstat (limited to 'src/plugins')
-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 |
4 files changed, 28 insertions, 14 deletions
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 \ |