diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-03-28 21:48:55 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-03-28 21:48:55 +0200 |
commit | fbf38ddbd58a7fc71ca8c99b3e3ec400c0aee690 (patch) | |
tree | 2de4395a25c58fccd1f0f13ad47af96bf846d375 /src/plugins | |
parent | 1236befd7490c18297d2abfbe9f2a3a35ca00959 (diff) | |
download | weechat-fbf38ddbd58a7fc71ca8c99b3e3ec400c0aee690.zip |
logger: add colors for backlog lines and end of backlog (task #11966)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/logger/logger-config.c | 28 | ||||
-rw-r--r-- | src/plugins/logger/logger-config.h | 3 | ||||
-rw-r--r-- | src/plugins/logger/logger.c | 40 |
3 files changed, 50 insertions, 21 deletions
diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c index 1cad5fd46..e8e526f04 100644 --- a/src/plugins/logger/logger-config.c +++ b/src/plugins/logger/logger-config.c @@ -39,6 +39,11 @@ int logger_config_loading = 0; struct t_config_option *logger_config_look_backlog; +/* logger config, color section */ + +struct t_config_option *logger_config_color_backlog_line; +struct t_config_option *logger_config_color_backlog_end; + /* logger config, file section */ struct t_config_option *logger_config_file_auto_log; @@ -378,6 +383,29 @@ logger_config_init () "new buffer (0 = no backlog)"), NULL, 0, INT_MAX, "20", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + /* color */ + ptr_section = weechat_config_new_section (logger_config_file, "color", + 0, 0, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL); + if (!ptr_section) + { + weechat_config_free (logger_config_file); + return 0; + } + + logger_config_color_backlog_line = weechat_config_new_option ( + logger_config_file, ptr_section, + "backlog_line", "color", + N_("color for backlog lines"), + NULL, -1, 0, "darkgray", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + logger_config_color_backlog_end = weechat_config_new_option ( + logger_config_file, ptr_section, + "backlog_end", "color", + N_("color for line ending the backlog"), + NULL, -1, 0, "darkgray", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + /* file */ ptr_section = weechat_config_new_section (logger_config_file, "file", 0, 0, diff --git a/src/plugins/logger/logger-config.h b/src/plugins/logger/logger-config.h index 32f0bc38d..865bf3be8 100644 --- a/src/plugins/logger/logger-config.h +++ b/src/plugins/logger/logger-config.h @@ -25,6 +25,9 @@ extern struct t_config_option *logger_config_look_backlog; +extern struct t_config_option *logger_config_color_backlog_line; +extern struct t_config_option *logger_config_color_backlog_end; + extern struct t_config_option *logger_config_file_auto_log; extern struct t_config_option *logger_config_file_name_lower_case; extern struct t_config_option *logger_config_file_path; diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index a08c479a9..7c440e813 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -915,7 +915,7 @@ void logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines) { struct t_logger_line *last_lines, *ptr_lines; - char *pos_message, *error; + char *pos_message, *pos_tab, *error; time_t datetime, time_now; struct tm tm_line; int num_lines; @@ -947,25 +947,21 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines) datetime = mktime (&tm_line); pos_message[0] = '\t'; } - if (pos_message) - { - if (datetime != 0) - { - weechat_printf_date_tags (buffer, datetime, - "no_highlight,notify_none", - "%s", pos_message + 1); - } - else - { - weechat_printf_tags (buffer, "no_highlight,notify_none", - "%s", ptr_lines->data); - } - } - else - { - weechat_printf_tags (buffer, "no_highlight,notify_none", - "%s", ptr_lines->data); - } + pos_message = (pos_message && (datetime != 0)) ? + pos_message + 1 : ptr_lines->data; + pos_tab = strchr (pos_message, '\t'); + if (pos_tab) + pos_tab[0] = '\0'; + weechat_printf_date_tags (buffer, datetime, + "no_highlight,notify_none", + "%s%s%s%s%s", + weechat_color (weechat_config_string (logger_config_color_backlog_line)), + pos_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'; num_lines++; ptr_lines = ptr_lines->next_line; } @@ -974,7 +970,9 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines) if (num_lines > 0) { weechat_printf_tags (buffer, "no_highlight,notify_none", - _("===\t========== End of backlog (%d lines) =========="), + _("%s===\t%s========== End of backlog (%d lines) =========="), + weechat_color (weechat_config_string (logger_config_color_backlog_end)), + weechat_color (weechat_config_string (logger_config_color_backlog_end)), num_lines); weechat_buffer_set (buffer, "unread", ""); } |