mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 15:53:12 +02:00
Allow buffer local variables in highlight words (option "weechat.look.highlight" and buffer property "highlight_words")
For example "$nick" with highlight a message printed if it contains content of local variable "nick" for buffer.
This commit is contained in:
@@ -579,6 +579,9 @@ gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
|
||||
const char *pos_end_name;
|
||||
struct t_gui_buffer_local_var *ptr_local_var;
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
length = strlen (string) + 1;
|
||||
result = malloc (length);
|
||||
if (result)
|
||||
|
||||
+21
-7
@@ -361,7 +361,7 @@ int
|
||||
gui_line_has_highlight (struct t_gui_line *line)
|
||||
{
|
||||
int rc, i;
|
||||
char *msg_no_color;
|
||||
char *msg_no_color, *highlight_words;
|
||||
|
||||
/*
|
||||
* highlights are disabled on this buffer? (special value "-" means that
|
||||
@@ -396,13 +396,27 @@ gui_line_has_highlight (struct t_gui_line *line)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* there is highlight on line if one of global highlight words matches line
|
||||
* or one of buffer highlight words matches line
|
||||
* there is highlight on line if one of buffer highlight words matches line
|
||||
* or one of global highlight words matches line
|
||||
*/
|
||||
rc = (string_has_highlight (msg_no_color,
|
||||
CONFIG_STRING(config_look_highlight)) ||
|
||||
string_has_highlight (msg_no_color,
|
||||
line->data->buffer->highlight_words));
|
||||
highlight_words = gui_buffer_string_replace_local_var (line->data->buffer,
|
||||
line->data->buffer->highlight_words);
|
||||
rc = string_has_highlight (msg_no_color,
|
||||
(highlight_words) ?
|
||||
highlight_words : line->data->buffer->highlight_words);
|
||||
if (highlight_words)
|
||||
free (highlight_words);
|
||||
|
||||
if (!rc)
|
||||
{
|
||||
highlight_words = gui_buffer_string_replace_local_var (line->data->buffer,
|
||||
CONFIG_STRING(config_look_highlight));
|
||||
rc = string_has_highlight (msg_no_color,
|
||||
(highlight_words) ?
|
||||
highlight_words : CONFIG_STRING(config_look_highlight));
|
||||
if (highlight_words)
|
||||
free (highlight_words);
|
||||
}
|
||||
|
||||
free (msg_no_color);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user