diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-chat.c | 18 | ||||
-rw-r--r-- | src/gui/gui-chat.h | 3 | ||||
-rw-r--r-- | src/gui/gui-line.c | 63 |
3 files changed, 50 insertions, 34 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); } } } diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h index 18a3b9bba..3ef59f587 100644 --- a/src/gui/gui-chat.h +++ b/src/gui/gui-chat.h @@ -90,7 +90,8 @@ extern void gui_chat_get_word_info (struct t_gui_window *window, int *word_end_offset, int *word_length_with_spaces, int *word_length); -extern char *gui_chat_get_time_string (time_t date, int date_usec); +extern char *gui_chat_get_time_string (time_t date, int date_usec, + int highlight); extern int gui_chat_get_time_length (); extern void gui_chat_change_time_format (); extern int gui_chat_buffer_valid (struct t_gui_buffer *buffer, diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 43eb68baa..bfdd2f1d8 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -1528,7 +1528,6 @@ gui_line_new (struct t_gui_buffer *buffer, int y, new_line->data->date_usec = date_usec; new_line->data->date_printed = date_printed; new_line->data->date_usec_printed = date_usec_printed; - new_line->data->str_time = gui_chat_get_time_string (date, date_usec); gui_line_tags_alloc (new_line->data, tags); new_line->data->refresh_needed = 0; new_line->data->prefix = (prefix) ? @@ -1540,6 +1539,8 @@ gui_line_new (struct t_gui_buffer *buffer, int y, gui_line_set_highlight (new_line, max_notify_level); if (new_line->data->highlight && (new_line->data->notify_level >= 0)) new_line->data->notify_level = GUI_HOTLIST_HIGHLIGHT; + new_line->data->str_time = gui_chat_get_time_string ( + date, date_usec, new_line->data->highlight); } else { @@ -1642,6 +1643,30 @@ gui_line_hook_update (struct t_gui_line *line, } } + ptr_value2 = hashtable_get (hashtable2, "notify_level"); + if (ptr_value2) + { + error = NULL; + value = strtol (ptr_value2, &error, 10); + if (error && !error[0] && (value >= -1) && (value <= GUI_HOTLIST_MAX)) + { + notify_level_updated = 1; + line->data->notify_level = value; + } + } + + ptr_value2 = hashtable_get (hashtable2, "highlight"); + if (ptr_value2) + { + error = NULL; + value = strtol (ptr_value2, &error, 10); + if (error && !error[0]) + { + highlight_updated = 1; + line->data->highlight = (value) ? 1 : 0; + } + } + ptr_value2 = hashtable_get (hashtable2, "date"); if (ptr_value2) { @@ -1654,7 +1679,8 @@ gui_line_hook_update (struct t_gui_line *line, free (line->data->str_time); line->data->str_time = gui_chat_get_time_string ( line->data->date, - line->data->date_usec); + line->data->date_usec, + line->data->highlight); } } @@ -1670,7 +1696,8 @@ gui_line_hook_update (struct t_gui_line *line, free (line->data->str_time); line->data->str_time = gui_chat_get_time_string ( line->data->date, - line->data->date_usec); + line->data->date_usec, + line->data->highlight); } } @@ -1710,30 +1737,6 @@ gui_line_hook_update (struct t_gui_line *line, gui_line_tags_alloc (line->data, ptr_value2); } - ptr_value2 = hashtable_get (hashtable2, "notify_level"); - if (ptr_value2) - { - error = NULL; - value = strtol (ptr_value2, &error, 10); - if (error && !error[0] && (value >= -1) && (value <= GUI_HOTLIST_MAX)) - { - notify_level_updated = 1; - line->data->notify_level = value; - } - } - - ptr_value2 = hashtable_get (hashtable2, "highlight"); - if (ptr_value2) - { - error = NULL; - value = strtol (ptr_value2, &error, 10); - if (error && !error[0]) - { - highlight_updated = 1; - line->data->highlight = (value) ? 1 : 0; - } - } - ptr_value = hashtable_get (hashtable, "prefix"); ptr_value2 = hashtable_get (hashtable2, "prefix"); if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0))) @@ -2218,7 +2221,8 @@ gui_line_hdata_line_data_update_cb (void *data, free (line_data->str_time); line_data->str_time = gui_chat_get_time_string ( line_data->date, - line_data->date_usec); + line_data->date_usec, + line_data->highlight); rc++; update_coords = 1; } @@ -2234,7 +2238,8 @@ gui_line_hdata_line_data_update_cb (void *data, free (line_data->str_time); line_data->str_time = gui_chat_get_time_string ( line_data->date, - line_data->date_usec); + line_data->date_usec, + line_data->highlight); rc++; update_coords = 1; } |