From 6f660f243025157655aaff167beeb0770b166e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 16 Mar 2024 09:46:55 +0100 Subject: core: add variable `${highlight}` in option weechat.look.buffer_time_format (issue #2079) --- src/gui/gui-chat.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/gui/gui-chat.c') 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); } } } -- cgit v1.2.3