diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-10-02 20:31:47 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-10-02 20:44:12 +0200 |
commit | 70fd7222787d6f07bfd649ff67c9a7f837949493 (patch) | |
tree | 82e2bc13009220bf830004c92dc153a3ce84c919 /src/plugins/logger/logger-backlog.c | |
parent | e386965abad857581abafa70d7999c2e3a8c4c2c (diff) | |
download | weechat-70fd7222787d6f07bfd649ff67c9a7f837949493.zip |
logger: add option logger.file.color_lines (closes #528, closes #621)
Diffstat (limited to 'src/plugins/logger/logger-backlog.c')
-rw-r--r-- | src/plugins/logger/logger-backlog.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/plugins/logger/logger-backlog.c b/src/plugins/logger/logger-backlog.c index bfd3c022c..f1ff70aa1 100644 --- a/src/plugins/logger/logger-backlog.c +++ b/src/plugins/logger/logger-backlog.c @@ -110,13 +110,15 @@ void logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines) { struct t_logger_line *last_lines, *ptr_lines; - char *charset, *pos_message, *pos_tab, *error, *message; + char *charset, *pos_message, *pos_tab, *error, *message, *message2; time_t datetime, time_now; struct tm tm_line; - int num_lines; + int color_lines, num_lines; weechat_buffer_set (buffer, "print_hooks_enabled", "0"); + color_lines = weechat_config_boolean (logger_config_file_color_lines); + num_lines = 0; last_lines = logger_tail_file (filename, lines); ptr_lines = last_lines; @@ -145,26 +147,35 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines) } pos_message = (pos_message && (datetime != 0)) ? pos_message + 1 : ptr_lines->data; - charset = weechat_info_get ("charset_terminal", ""); - message = (charset) ? - weechat_iconv_to_internal (charset, pos_message) : strdup (pos_message); - if (charset) - free (charset); + message = weechat_hook_modifier_exec ( + "color_decode_ansi", + (color_lines) ? "1" : "0", + pos_message); if (message) { - pos_tab = strchr (message, '\t'); - if (pos_tab) - pos_tab[0] = '\0'; - weechat_printf_date_tags (buffer, datetime, - "no_highlight,notify_none,logger_backlog", - "%s%s%s%s%s", - weechat_color (weechat_config_string (logger_config_color_backlog_line)), - message, - (pos_tab) ? "\t" : "", - (pos_tab) ? weechat_color (weechat_config_string (logger_config_color_backlog_line)) : "", - (pos_tab) ? pos_tab + 1 : ""); - if (pos_tab) - pos_tab[0] = '\t'; + charset = weechat_info_get ("charset_terminal", ""); + message2 = (charset) ? + weechat_iconv_to_internal (charset, message) : strdup (message); + if (charset) + free (charset); + if (message2) + { + pos_tab = strchr (message2, '\t'); + if (pos_tab) + pos_tab[0] = '\0'; + weechat_printf_date_tags ( + buffer, datetime, + "no_highlight,notify_none,logger_backlog", + "%s%s%s%s%s", + (color_lines) ? "" : weechat_color (weechat_config_string (logger_config_color_backlog_line)), + message2, + (pos_tab) ? "\t" : "", + (pos_tab && !color_lines) ? weechat_color (weechat_config_string (logger_config_color_backlog_line)) : "", + (pos_tab) ? pos_tab + 1 : ""); + if (pos_tab) + pos_tab[0] = '\t'; + free (message2); + } free (message); } num_lines++; |