summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-11-04 21:04:03 +0100
committerSébastien Helleu <flashcode@flashtux.org>2017-11-04 21:04:03 +0100
commitbfc579cb3354cb47a224c8fa55b6a2e5684c7ab9 (patch)
treeb7280d04b59efdd349125bac3caa87e83845fd23
parentb072586d79ebc0509dd08b6f4f4f2880b33cedfa (diff)
downloadweechat-bfc579cb3354cb47a224c8fa55b6a2e5684c7ab9.zip
core: remove colors from prefix/message only when needed in hook_print_exec
-rw-r--r--src/core/wee-hook.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index e612acd22..d86f4e8b7 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -2484,16 +2484,8 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
if (!line->data->message || !line->data->message[0])
return;
- prefix_no_color = (line->data->prefix) ?
- gui_color_decode (line->data->prefix, NULL) : NULL;
-
- message_no_color = gui_color_decode (line->data->message, NULL);
- if (!message_no_color)
- {
- if (prefix_no_color)
- free (prefix_no_color);
- return;
- }
+ prefix_no_color = NULL;
+ message_no_color = NULL;
hook_exec_start ();
@@ -2511,12 +2503,23 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
|| string_strcasestr (prefix_no_color, HOOK_PRINT(ptr_hook, message))
|| string_strcasestr (message_no_color, HOOK_PRINT(ptr_hook, message))))
{
- /* check if tags match */
+ /* check if tags are matching */
if (!HOOK_PRINT(ptr_hook, tags_array)
|| gui_line_match_tags (line->data,
HOOK_PRINT(ptr_hook, tags_count),
HOOK_PRINT(ptr_hook, tags_array)))
{
+ /* strip colors if needed (and if not already done) */
+ if (HOOK_PRINT(ptr_hook, strip_colors) && !message_no_color)
+ {
+ message_no_color = gui_color_decode (line->data->message,
+ NULL);
+ if (!message_no_color)
+ goto end;
+ prefix_no_color = (line->data->prefix) ?
+ gui_color_decode (line->data->prefix, NULL) : NULL;
+ }
+
/* run callback */
ptr_hook->running = 1;
(void) (HOOK_PRINT(ptr_hook, callback))
@@ -2534,6 +2537,7 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
ptr_hook = next_hook;
}
+end:
if (prefix_no_color)
free (prefix_no_color);
if (message_no_color)