1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 22:06:38 +02:00

Add "displayed" and "highlight" arguments to callback for hook_print

This commit is contained in:
Sebastien Helleu
2008-11-29 17:44:42 +01:00
parent bc00946a0d
commit bf0b5f5644
16 changed files with 149 additions and 55 deletions
+13 -14
View File
@@ -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;
}
}
+4 -4
View File
@@ -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,
+1 -5
View File
@@ -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;
}
+3
View File
@@ -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);
+11 -4
View File
@@ -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;
}
+10
View File
@@ -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]);
}
}
}
}
}
+11 -4
View File
@@ -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;
}
@@ -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;
}
+22 -3
View File
@@ -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);
+11 -4
View File
@@ -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;
}
+35 -8
View File
@@ -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)
{
+1
View File
@@ -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)
+2
View File
@@ -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);
+11 -4
View File
@@ -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;
}
+1 -1
View File
@@ -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);
+2
View File
@@ -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);