diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-11-29 17:44:42 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-11-29 17:44:42 +0100 |
commit | bf0b5f5644abbf0a79674af7e75f6e24981babfc (patch) | |
tree | e3bd5fb98c83ba64f8f0f922084e6e941644529a | |
parent | bc00946a0da47dbc16cefbb915ae7f94b0ac3abf (diff) | |
download | weechat-bf0b5f5644abbf0a79674af7e75f6e24981babfc.zip |
Add "displayed" and "highlight" arguments to callback for hook_print
-rw-r--r-- | src/core/wee-hook.c | 27 | ||||
-rw-r--r-- | src/core/wee-hook.h | 8 | ||||
-rw-r--r-- | src/gui/gui-chat.c | 6 | ||||
-rw-r--r-- | src/plugins/logger/logger.c | 3 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 15 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua.c | 10 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 15 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 15 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 25 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 15 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.c | 43 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.c | 1 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.h | 2 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 15 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl.c | 2 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 2 |
16 files changed, 149 insertions, 55 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 8e8627974..d834cd58f 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -1021,21 +1021,19 @@ hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer, */ void -hook_print_exec (struct t_gui_buffer *buffer, time_t date, int tags_count, - const char **tags_array, const char *prefix, - const char *message) +hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line) { struct t_hook *ptr_hook, *next_hook; char *prefix_no_color, *message_no_color; int tags_match, tag_found, i, j; - if (!message || !message[0]) + if (!line->message || !line->message[0]) return; - prefix_no_color = (prefix) ? - (char *)gui_color_decode ((unsigned char *)prefix) : NULL; + prefix_no_color = (line->prefix) ? + (char *)gui_color_decode ((unsigned char *)line->prefix) : NULL; - message_no_color = (char *)gui_color_decode ((unsigned char *)message); + message_no_color = (char *)gui_color_decode ((unsigned char *)line->message); if (!message_no_color) { free (prefix_no_color); @@ -1061,17 +1059,17 @@ hook_print_exec (struct t_gui_buffer *buffer, time_t date, int tags_count, if (HOOK_PRINT(ptr_hook, tags_array)) { /* if there are tags in message printed */ - if (tags_array) + if (line->tags_array) { tags_match = 1; for (i = 0; i < HOOK_PRINT(ptr_hook, tags_count); i++) { /* search for tag in message */ tag_found = 0; - for (j = 0; j < tags_count; j++) + for (j = 0; j < line->tags_count; j++) { if (string_strcasecmp (HOOK_PRINT(ptr_hook, tags_array)[i], - tags_array[j]) != 0) + line->tags_array[j]) != 0) { tag_found = 1; break; @@ -1096,10 +1094,11 @@ hook_print_exec (struct t_gui_buffer *buffer, time_t date, int tags_count, { ptr_hook->running = 1; (void) (HOOK_PRINT(ptr_hook, callback)) - (ptr_hook->callback_data, buffer, date, - tags_count, tags_array, - (HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : prefix, - (HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : message); + (ptr_hook->callback_data, buffer, line->date, + line->tags_count, (const char **)line->tags_array, + (int)line->displayed, (int)line->highlight, + (HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : line->prefix, + (HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : line->message); ptr_hook->running = 0; } } diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index 6e6dd0c27..1c9e4e8de 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -25,6 +25,7 @@ #endif struct t_gui_buffer; +struct t_gui_line; struct t_gui_completion; struct t_weelist; struct t_infolist; @@ -145,7 +146,8 @@ struct t_hook_connect typedef int (t_hook_callback_print)(void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, - const char **tags, const char *prefix, + const char **tags, int displayed, + int highlight, const char *prefix, const char *message); struct t_hook_print @@ -270,9 +272,7 @@ extern struct t_hook *hook_print (struct t_weechat_plugin *plugin, t_hook_callback_print *callback, void *callback_data); extern void hook_print_exec (struct t_gui_buffer *buffer, - time_t date, int tags_count, - const char **tags_array, const char *prefix, - const char *message); + struct t_gui_line *line); extern struct t_hook *hook_signal (struct t_weechat_plugin *plugin, const char *signal, t_hook_callback_signal *callback, diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index a782a15a5..c452f47ca 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -1132,11 +1132,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, tags, pos_prefix, ptr_msg); if (buffer->last_line) { - hook_print_exec (buffer, buffer->last_line->date, - buffer->last_line->tags_count, - (const char **)buffer->last_line->tags_array, - buffer->last_line->prefix, - buffer->last_line->message); + hook_print_exec (buffer, buffer->last_line); } at_least_one_message_printed = 1; } diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index 8d8242645..e8130e8b6 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -908,6 +908,7 @@ logger_line_log_level (int tags_count, const char **tags) int logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, + int displayed, int highlight, const char *prefix, const char *message) { struct t_logger_buffer *ptr_logger_buffer; @@ -917,6 +918,8 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, /* make C compiler happy */ (void) data; + (void) displayed; + (void) highlight; line_log_level = logger_line_log_level (tags_count, tags); diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 51ebcd0c6..82edef379 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -2812,10 +2812,11 @@ int weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, + int displayed, int highlight, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *lua_argv[6]; + char *lua_argv[8]; static char timebuffer[64]; int *rc, ret; @@ -2829,9 +2830,11 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, lua_argv[0] = script_ptr2str (buffer); lua_argv[1] = timebuffer; lua_argv[2] = weechat_string_build_with_exploded (tags, ","); - lua_argv[3] = (char *)prefix; - lua_argv[4] = (char *)message; - lua_argv[5] = NULL; + lua_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); + lua_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); + lua_argv[5] = (char *)prefix; + lua_argv[6] = (char *)message; + lua_argv[7] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2849,6 +2852,10 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, free (lua_argv[0]); if (lua_argv[2]) free (lua_argv[2]); + if (lua_argv[3]) + free (lua_argv[3]); + if (lua_argv[4]) + free (lua_argv[4]); return ret; } diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 70b731292..377b213ff 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -88,6 +88,16 @@ weechat_lua_exec (struct t_plugin_script *script, { argc = 5; lua_pushstring (lua_current_interpreter, argv[4]); + if (argv[5]) + { + argc = 6; + lua_pushstring (lua_current_interpreter, argv[5]); + if (argv[6]) + { + argc = 7; + lua_pushstring (lua_current_interpreter, argv[6]); + } + } } } } diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index f25824e3c..b953b0b3b 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -2344,10 +2344,11 @@ int weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, + int displayed, int highlight, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *perl_argv[6]; + char *perl_argv[8]; static char timebuffer[64]; int *rc, ret; @@ -2361,9 +2362,11 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, perl_argv[0] = script_ptr2str (buffer); perl_argv[1] = timebuffer; perl_argv[2] = weechat_string_build_with_exploded (tags, ","); - perl_argv[3] = (char *)prefix; - perl_argv[4] = (char *)message; - perl_argv[5] = NULL; + perl_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); + perl_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); + perl_argv[5] = (char *)prefix; + perl_argv[6] = (char *)message; + perl_argv[7] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2381,6 +2384,10 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, free (perl_argv[0]); if (perl_argv[2]) free (perl_argv[2]); + if (perl_argv[3]) + free (perl_argv[3]); + if (perl_argv[4]) + free (perl_argv[4]); return ret; } diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index d4d5da1aa..f6253f087 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -2504,10 +2504,11 @@ int weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, + int displayed, int highlight, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *python_argv[6]; + char *python_argv[8]; static char timebuffer[64]; int *rc, ret; @@ -2521,9 +2522,11 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, python_argv[0] = script_ptr2str (buffer); python_argv[1] = timebuffer; python_argv[2] = weechat_string_build_with_exploded (tags, ","); - python_argv[3] = (char *)prefix; - python_argv[4] = (char *)message; - python_argv[5] = NULL; + python_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); + python_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); + python_argv[5] = (char *)prefix; + python_argv[6] = (char *)message; + python_argv[7] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2541,6 +2544,10 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, free (python_argv[0]); if (python_argv[2]) free (python_argv[2]); + if (python_argv[3]) + free (python_argv[3]); + if (python_argv[4]) + free (python_argv[4]); return ret; } diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index e43deffe4..721f7dcdf 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -93,28 +93,47 @@ weechat_python_exec (struct t_plugin_script *script, { if (argv[5]) { - rc = PyObject_CallFunction (evFunc, "ssssss", argv[0], - argv[1], argv[2], argv[3], - argv[4], argv[5]); + if (argv[6]) + { + rc = PyObject_CallFunction (evFunc, "sssssss", argv[0], + argv[1], argv[2], argv[3], + argv[4], argv[5], argv[6]); + } + else + { + rc = PyObject_CallFunction (evFunc, "ssssss", argv[0], + argv[1], argv[2], argv[3], + argv[4], argv[5]); + } } else + { rc = PyObject_CallFunction (evFunc, "sssss", argv[0], argv[1], argv[2], argv[3], argv[4]); + } } else + { rc = PyObject_CallFunction (evFunc, "ssss", argv[0], argv[1], argv[2], argv[3]); + } } else + { rc = PyObject_CallFunction (evFunc, "sss", argv[0], argv[1], argv[2]); + } } else + { rc = PyObject_CallFunction (evFunc, "ss", argv[0], argv[1]); + } } else + { rc = PyObject_CallFunction (evFunc, "s", argv[0]); + } } else rc = PyObject_CallFunction (evFunc, NULL); diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index fd09a9e7f..8e3f0e5d5 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -2887,10 +2887,11 @@ int weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, + int displayed, int highlight, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *ruby_argv[6]; + char *ruby_argv[8]; static char timebuffer[64]; int *rc, ret; @@ -2904,9 +2905,11 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ruby_argv[0] = script_ptr2str (buffer); ruby_argv[1] = timebuffer; ruby_argv[2] = weechat_string_build_with_exploded (tags, ","); - ruby_argv[3] = (char *)prefix; - ruby_argv[4] = (char *)message; - ruby_argv[5] = NULL; + ruby_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); + ruby_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); + ruby_argv[5] = (char *)prefix; + ruby_argv[6] = (char *)message; + ruby_argv[7] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2924,6 +2927,10 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, free (ruby_argv[0]); if (ruby_argv[2]) free (ruby_argv[2]); + if (ruby_argv[3]) + free (ruby_argv[3]); + if (ruby_argv[4]) + free (ruby_argv[4]); return ret; } diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 83f96dd50..53a616018 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -130,16 +130,32 @@ weechat_ruby_exec (struct t_plugin_script *script, { if (argv[5]) { - rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), - &ruby_error, 6, - rb_str_new2(argv[0]), - rb_str_new2(argv[1]), - rb_str_new2(argv[2]), - rb_str_new2(argv[3]), - rb_str_new2(argv[4]), - rb_str_new2(argv[5])); + if (argv[6]) + { + rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), + &ruby_error, 7, + rb_str_new2(argv[0]), + rb_str_new2(argv[1]), + rb_str_new2(argv[2]), + rb_str_new2(argv[3]), + rb_str_new2(argv[4]), + rb_str_new2(argv[5]), + rb_str_new2(argv[6])); + } + else + { + rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), + &ruby_error, 6, + rb_str_new2(argv[0]), + rb_str_new2(argv[1]), + rb_str_new2(argv[2]), + rb_str_new2(argv[3]), + rb_str_new2(argv[4]), + rb_str_new2(argv[5])); + } } else + { rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), &ruby_error, 5, rb_str_new2(argv[0]), @@ -147,36 +163,47 @@ weechat_ruby_exec (struct t_plugin_script *script, rb_str_new2(argv[2]), rb_str_new2(argv[3]), rb_str_new2(argv[4])); + } } else + { rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), &ruby_error, 4, rb_str_new2(argv[0]), rb_str_new2(argv[1]), rb_str_new2(argv[2]), rb_str_new2(argv[3])); + } } else + { rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), &ruby_error, 3, rb_str_new2(argv[0]), rb_str_new2(argv[1]), rb_str_new2(argv[2])); + } } else + { rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), &ruby_error, 2, rb_str_new2(argv[0]), rb_str_new2(argv[1])); + } } else + { rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), &ruby_error, 1, rb_str_new2(argv[0])); + } } else + { rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), &ruby_error, 0); + } if (ruby_error) { diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index 25cdad711..62e19e9a3 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -790,6 +790,7 @@ script_api_hook_print (struct t_weechat_plugin *weechat_plugin, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, + int displayed, int highlight, const char *prefix, const char *message), const char *function) diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index c1a379d30..eff244667 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -143,6 +143,8 @@ extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_pl time_t date, int tags_count, const char **tags, + int displayed, + int highlight, const char *prefix, const char *message), const char *function); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 090f999dc..4e51e24d1 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -2716,10 +2716,11 @@ int weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, + int displayed, int highlight, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *tcl_argv[6]; + char *tcl_argv[8]; static char timebuffer[64]; int *rc, ret; @@ -2733,9 +2734,11 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, tcl_argv[0] = script_ptr2str (buffer); tcl_argv[1] = timebuffer; tcl_argv[2] = weechat_string_build_with_exploded (tags, ","); - tcl_argv[3] = (char *)prefix; - tcl_argv[4] = (char *)message; - tcl_argv[5] = NULL; + tcl_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); + tcl_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); + tcl_argv[5] = (char *)prefix; + tcl_argv[6] = (char *)message; + tcl_argv[7] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2753,6 +2756,10 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, free (tcl_argv[0]); if (tcl_argv[2]) free (tcl_argv[2]); + if (tcl_argv[3]) + free (tcl_argv[3]); + if (tcl_argv[4]) + free (tcl_argv[4]); return ret; } diff --git a/src/plugins/scripts/tcl/weechat-tcl.c b/src/plugins/scripts/tcl/weechat-tcl.c index b3350e191..2f0058ee2 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.c +++ b/src/plugins/scripts/tcl/weechat-tcl.c @@ -82,7 +82,7 @@ weechat_tcl_exec (struct t_plugin_script *script, if (argv) { - for (i = 0; argv[i] && (i<6); i++) + for (i = 0; argv[i]; i++) { Tcl_DStringAppend (&ds, " \"", -1); Tcl_DStringAppend (&ds, argv[i], -1); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 35d5c0439..837462c68 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -363,6 +363,8 @@ struct t_weechat_plugin time_t date, int tags_count, const char **tags, + int displayed, + int highlight, const char *prefix, const char *message), void *callback_data); |