diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-16 09:46:55 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-16 09:46:55 +0100 |
commit | 6f660f243025157655aaff167beeb0770b166e82 (patch) | |
tree | bbd1c4b7440f86bb3b532a72c36da0e00bf8f027 /src/gui/gui-chat.c | |
parent | 41fb29bbd0aac35e7365ea28e7987465c93ee9bb (diff) | |
download | weechat-6f660f243025157655aaff167beeb0770b166e82.zip |
core: add variable `${highlight}` in option weechat.look.buffer_time_format (issue #2079)
Diffstat (limited to 'src/gui/gui-chat.c')
-rw-r--r-- | src/gui/gui-chat.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index a1ff81322..53d029b27 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -390,12 +390,13 @@ gui_chat_get_word_info (struct t_gui_window *window, */ char * -gui_chat_get_time_string (time_t date, int date_usec) +gui_chat_get_time_string (time_t date, int date_usec, int highlight) { char text_time[128], text_time2[(128*3)+16], text_time_char[2]; char *text_with_color; int i, time_first_digit, time_last_digit, last_color; struct timeval tv; + struct t_hashtable *extra_vars; if (date == 0) return NULL; @@ -413,7 +414,15 @@ gui_chat_get_time_string (time_t date, int date_usec) if (strstr (text_time, "${")) { - text_with_color = eval_expression (text_time, NULL, NULL, NULL); + extra_vars = hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); + if (extra_vars) + hashtable_set (extra_vars, "highlight", (highlight) ? "1" : "0"); + text_with_color = eval_expression (text_time, NULL, extra_vars, NULL); + if (extra_vars) + hashtable_free (extra_vars); if (text_with_color) { if (strcmp (text_time, text_with_color) != 0) @@ -510,7 +519,7 @@ gui_chat_get_time_length () length = 0; gettimeofday (&tv_now, NULL); - text_time = gui_chat_get_time_string (tv_now.tv_sec, tv_now.tv_usec); + text_time = gui_chat_get_time_string (tv_now.tv_sec, tv_now.tv_usec, 0); if (text_time) { @@ -543,7 +552,8 @@ gui_chat_change_time_format () free (ptr_line->data->str_time); ptr_line->data->str_time = gui_chat_get_time_string ( ptr_line->data->date, - ptr_line->data->date_usec); + ptr_line->data->date_usec, + ptr_line->data->highlight); } } } |