diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-04-29 18:30:59 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-04-29 18:30:59 +0200 |
commit | 16cc0b6088354df6b5e8fdfd7ac9b79871190128 (patch) | |
tree | 902cbe43814e6430c92f153203a07aba53b3a391 | |
parent | cf8a125ef233bff8315f28540753f50cad279663 (diff) | |
download | weechat-16cc0b6088354df6b5e8fdfd7ac9b79871190128.zip |
core: make nick prefix/suffix dynamic (move options from irc plugin to core, add logger options) (bug #37531)
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | NEWS | 28 | ||||
-rw-r--r-- | src/core/wee-config.c | 49 | ||||
-rw-r--r-- | src/core/wee-config.h | 5 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 94 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 2 | ||||
-rw-r--r-- | src/gui/gui-color.h | 2 | ||||
-rw-r--r-- | src/gui/gui-line.c | 41 | ||||
-rw-r--r-- | src/gui/gui-line.h | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-color.h | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 28 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 16 | ||||
-rw-r--r-- | src/plugins/logger/logger-config.c | 12 | ||||
-rw-r--r-- | src/plugins/logger/logger-config.h | 2 | ||||
-rw-r--r-- | src/plugins/logger/logger.c | 59 |
16 files changed, 251 insertions, 101 deletions
@@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.4.1-dev, 2013-04-28 +v0.4.1-dev, 2013-04-29 This document lists all changes for each version. @@ -14,6 +14,10 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] Version 0.4.1 (under dev!) -------------------------- +* core: make nick prefix/suffix dynamic (not stored in the line): move options + irc.look.nick_{prefix|suffix} to weechat.look.nick_{prefix|suffix} and options + irc.color.nick_{prefix|suffix} to weechat.color.chat_nick_{prefix|suffix}, + add new options logger.file.nick_{prefix|suffix} (bug #37531) * core: reset scroll in window before zooming on a merged buffer (bug #38207) * core: install icon file (patch #7972) * core: fix refresh of item "completion": clear it after any action that is @@ -1,7 +1,7 @@ WeeChat Release Notes ===================== Sébastien Helleu <flashcode@flashtux.org> -v0.4.1-dev, 2013-03-24 +v0.4.1-dev, 2013-04-29 This document lists important changes for each version, that require manual @@ -16,6 +16,32 @@ http://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog] Version 0.4.1 (under dev!) -------------------------- +=== Dynamic nick prefix/suffix === + +The nick prefix/suffix (for example: "<" and ">") are now dynamic and used on +display (not stored any more in the line). + +Options moved from irc plugin (irc.conf) to core (weechat.conf): + +* 'irc.look.nick_prefix' moved to 'weechat.look.nick_prefix' +* 'irc.look.nick_suffix' moved to 'weechat.look.nick_suffix' +* 'irc.color.nick_prefix' moved to 'weechat.color.chat_nick_prefix' +* 'irc.color.nick_suffix' moved to 'weechat.color.chat_nick_suffix' + +Types and default values for these four options remain unchanged. + +After `/upgrade`, if you set new options to non-empty strings, and if old +options were set to non-empty strings too, you will see double prefix/suffix +on old messages, this is normal behaviour (lines displayed before `/upgrade` +have prefix/suffix saved in prefix, but new lines don't have them any more). + +New options in logger plugin (logger.conf): + +* 'logger.file.nick_prefix': prefix for nicks in log files (default: empty + string) +* 'logger.file.nick_suffix': suffix for nicks in log files (default: empty + string) + === IRC reconnection on important lag === Option 'irc.network.lag_disconnect' has been renamed to diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 489efc8f7..9b2ea82bb 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -124,6 +124,8 @@ struct t_config_option *config_look_item_buffer_filter; struct t_config_option *config_look_jump_current_to_previous_buffer; struct t_config_option *config_look_jump_previous_buffer_when_closing; struct t_config_option *config_look_jump_smart_back_to_buffer; +struct t_config_option *config_look_nick_prefix; +struct t_config_option *config_look_nick_suffix; struct t_config_option *config_look_mouse; struct t_config_option *config_look_mouse_timer_delay; struct t_config_option *config_look_paste_bracketed; @@ -175,6 +177,8 @@ struct t_config_option *config_color_chat_server; struct t_config_option *config_color_chat_channel; struct t_config_option *config_color_chat_nick; struct t_config_option *config_color_chat_nick_colors; +struct t_config_option *config_color_chat_nick_prefix; +struct t_config_option *config_color_chat_nick_suffix; struct t_config_option *config_color_chat_nick_self; struct t_config_option *config_color_chat_nick_offline; struct t_config_option *config_color_chat_nick_offline_highlight; @@ -248,6 +252,7 @@ struct t_config_option *config_plugin_save_config_on_unload; /* other */ +int config_length_nick_prefix_suffix = 0; int config_length_prefix_same_nick = 0; struct t_hook *config_day_change_timer = NULL; int config_day_change_old_day = -1; @@ -408,6 +413,26 @@ config_compute_prefix_max_length_all_buffers () } /* + * Callback for changes on options "weechat.look.nick_prefix" and + * "weechat.look.nick_suffix". + */ + +void +config_change_nick_prefix_suffix (void *data, struct t_config_option *option) +{ + /* make C compiler happy */ + (void) data; + (void) option; + + config_length_nick_prefix_suffix = + gui_chat_strlen_screen (CONFIG_STRING(config_look_nick_prefix)) + + gui_chat_strlen_screen (CONFIG_STRING(config_look_nick_suffix)); + + config_compute_prefix_max_length_all_buffers (); + gui_window_ask_refresh (1); +} + +/* * Callback for changes on option "weechat.look.prefix_same_nick". */ @@ -2152,6 +2177,18 @@ config_weechat_init_options () "jump_smart_back_to_buffer", "boolean", N_("jump back to initial buffer after reaching end of hotlist"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + config_look_nick_prefix = config_file_new_option ( + weechat_config_file, ptr_section, + "nick_prefix", "string", + N_("text to display before nick in prefix of message, example: \"<\""), + NULL, 0, 0, "", NULL, 0, NULL, NULL, + &config_change_nick_prefix_suffix, NULL, NULL, NULL); + config_look_nick_suffix = config_file_new_option ( + weechat_config_file, ptr_section, + "nick_suffix", "string", + N_("text to display after nick in prefix of message, example: \">\""), + NULL, 0, 0, "", NULL, 0, NULL, NULL, + &config_change_nick_prefix_suffix, NULL, NULL, NULL); config_look_mouse = config_file_new_option ( weechat_config_file, ptr_section, "mouse", "boolean", @@ -2529,6 +2566,18 @@ config_weechat_init_options () NULL, 0, 0, "cyan,magenta,green,brown,lightblue,default,lightcyan," "lightmagenta,lightgreen,blue", NULL, 0, NULL, NULL, &config_change_nick_colors, NULL, NULL, NULL); + config_color_chat_nick_prefix = config_file_new_option ( + weechat_config_file, ptr_section, + "chat_nick_prefix", "color", + N_("color for nick prefix (string displayed before nick in prefix)"), + NULL, GUI_COLOR_CHAT_NICK_PREFIX, 0, "green", NULL, 0, NULL, NULL, + &config_change_color, NULL, NULL, NULL); + config_color_chat_nick_suffix = config_file_new_option ( + weechat_config_file, ptr_section, + "chat_nick_suffix", "color", + N_("color for nick suffix (string displayed after nick in suffix)"), + NULL, GUI_COLOR_CHAT_NICK_SUFFIX, 0, "green", NULL, 0, NULL, NULL, + &config_change_color, NULL, NULL, NULL); config_color_chat_nick_self = config_file_new_option ( weechat_config_file, ptr_section, "chat_nick_self", "color", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 28df95a2e..966d9b356 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -148,6 +148,8 @@ extern struct t_config_option *config_look_item_buffer_filter; extern struct t_config_option *config_look_jump_current_to_previous_buffer; extern struct t_config_option *config_look_jump_previous_buffer_when_closing; extern struct t_config_option *config_look_jump_smart_back_to_buffer; +extern struct t_config_option *config_look_nick_prefix; +extern struct t_config_option *config_look_nick_suffix; extern struct t_config_option *config_look_mouse; extern struct t_config_option *config_look_mouse_timer_delay; extern struct t_config_option *config_look_paste_bracketed; @@ -197,6 +199,8 @@ extern struct t_config_option *config_color_chat_server; extern struct t_config_option *config_color_chat_channel; extern struct t_config_option *config_color_chat_nick; extern struct t_config_option *config_color_chat_nick_colors; +extern struct t_config_option *config_color_chat_nick_prefix; +extern struct t_config_option *config_color_chat_nick_suffix; extern struct t_config_option *config_color_chat_nick_self; extern struct t_config_option *config_color_chat_nick_offline; extern struct t_config_option *config_color_chat_nick_offline_highlight; @@ -260,6 +264,7 @@ extern struct t_config_option *config_plugin_extension; extern struct t_config_option *config_plugin_path; extern struct t_config_option *config_plugin_save_config_on_unload; +extern int config_length_nick_prefix_suffix; extern int config_length_prefix_same_nick; extern regex_t *config_highlight_regex; extern char **config_highlight_tags; diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 68bb3975d..18afb7b60 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -602,9 +602,9 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, char str_space[] = " "; char *prefix_no_color, *prefix_highlighted, *ptr_prefix, *ptr_prefix2; char *ptr_prefix_color; - const char *short_name, *str_color; + const char *short_name, *str_color, *ptr_nick_prefix, *ptr_nick_suffix; int i, length, length_allowed, num_spaces, prefix_length, extra_spaces; - int chars_displayed, nick_offline; + int chars_displayed, nick_offline, prefix_is_nick, length_nick_prefix_suffix; struct t_gui_lines *mixed_lines; if (!simulate) @@ -773,7 +773,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, /* get prefix for display */ gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length, - &ptr_prefix_color); + &ptr_prefix_color, &prefix_is_nick); if (ptr_prefix) { ptr_prefix2 = NULL; @@ -794,6 +794,20 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, ptr_prefix = (ptr_prefix2) ? ptr_prefix2 : strdup (ptr_prefix); } + /* get nick prefix/suffix (if prefix is a nick) */ + if (prefix_is_nick && (config_length_nick_prefix_suffix > 0)) + { + ptr_nick_prefix = CONFIG_STRING(config_look_nick_prefix); + ptr_nick_suffix = CONFIG_STRING(config_look_nick_suffix); + length_nick_prefix_suffix = config_length_nick_prefix_suffix; + } + else + { + ptr_nick_prefix = NULL; + ptr_nick_suffix = NULL; + length_nick_prefix_suffix = 0; + } + /* display prefix */ if (ptr_prefix && (ptr_prefix[0] @@ -816,7 +830,19 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, else length_allowed = window->buffer->lines->prefix_max_length; - num_spaces = length_allowed - prefix_length; + /* + * if we are not able to display at least 1 char of prefix (inside + * prefix/suffix), then do not display nick prefix/suffix at all + */ + if (ptr_nick_prefix && ptr_nick_suffix + && (length_nick_prefix_suffix + 1 > length_allowed)) + { + ptr_nick_prefix = NULL; + ptr_nick_suffix = NULL; + length_nick_prefix_suffix = 0; + } + + num_spaces = length_allowed - prefix_length - length_nick_prefix_suffix; if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_RIGHT) { @@ -830,6 +856,20 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, } } + /* display prefix before nick (for example "<") */ + if (ptr_nick_prefix) + { + if (!simulate) + { + gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat, + GUI_COLOR_CHAT_NICK_PREFIX); + } + gui_chat_display_word (window, line, + ptr_nick_prefix, + NULL, 1, num_lines, count, + lines_displayed, simulate, 0, 0); + } + nick_offline = CONFIG_BOOLEAN(config_look_color_nick_offline) && gui_line_has_offline_nick (line); @@ -888,15 +928,14 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, (prefix_highlighted) ? prefix_highlighted : ptr_prefix, (prefix_highlighted) ? prefix_highlighted + gui_chat_string_real_pos (prefix_highlighted, - length_allowed) : + length_allowed - length_nick_prefix_suffix - 1) : ptr_prefix + gui_chat_string_real_pos (ptr_prefix, - length_allowed), + length_allowed - length_nick_prefix_suffix - 1), 1, num_lines, count, lines_displayed, simulate, CONFIG_BOOLEAN(config_look_color_inactive_prefix), nick_offline); - if (chars_displayed < length_allowed) - extra_spaces = length_allowed - chars_displayed; + extra_spaces = length_allowed - length_nick_prefix_suffix - 1 - chars_displayed; } else { @@ -922,17 +961,15 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, GUI_COLOR_CHAT); } - if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT) + for (i = 0; i < extra_spaces; i++) { - for (i = 0; i < num_spaces; i++) - { - gui_chat_display_word (window, line, str_space, - NULL, 1, num_lines, count, lines_displayed, - simulate, - CONFIG_BOOLEAN(config_look_color_inactive_prefix), - 0); - } + gui_chat_display_word (window, line, str_space, + NULL, 1, num_lines, count, lines_displayed, + simulate, + CONFIG_BOOLEAN(config_look_color_inactive_prefix), + 0); } + if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE) && (num_spaces < 0)) { @@ -948,9 +985,24 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, CONFIG_BOOLEAN(config_look_color_inactive_prefix), 0); } - else + + /* display suffix after nick (for example ">") */ + if (ptr_nick_suffix) + { + if (!simulate) + { + gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat, + GUI_COLOR_CHAT_NICK_SUFFIX); + } + gui_chat_display_word (window, line, + ptr_nick_suffix, + NULL, 1, num_lines, count, + lines_displayed, simulate, 0, 0); + } + + if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT) { - if (window->buffer->lines->prefix_max_length > 0) + for (i = 0; i < num_spaces; i++) { gui_chat_display_word (window, line, str_space, NULL, 1, num_lines, count, lines_displayed, @@ -959,7 +1011,8 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, 0); } } - for (i = 0; i < extra_spaces; i++) + + if (window->buffer->lines->prefix_max_length > 0) { gui_chat_display_word (window, line, str_space, NULL, 1, num_lines, count, lines_displayed, @@ -967,6 +1020,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, CONFIG_BOOLEAN(config_look_color_inactive_prefix), 0); } + if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE) && (CONFIG_STRING(config_look_prefix_suffix) && CONFIG_STRING(config_look_prefix_suffix)[0])) diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index e870ab893..4e7843f42 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -1421,6 +1421,8 @@ gui_color_init_weechat () gui_color_build (GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER, CONFIG_COLOR(config_color_chat_prefix_buffer_inactive_buffer), CONFIG_COLOR(config_color_chat_bg)); gui_color_build (GUI_COLOR_CHAT_NICK_OFFLINE, CONFIG_COLOR(config_color_chat_nick_offline), CONFIG_COLOR(config_color_chat_bg)); gui_color_build (GUI_COLOR_CHAT_NICK_OFFLINE_HIGHLIGHT, CONFIG_COLOR(config_color_chat_nick_offline_highlight), CONFIG_COLOR(config_color_chat_nick_offline_highlight_bg)); + gui_color_build (GUI_COLOR_CHAT_NICK_PREFIX, CONFIG_COLOR(config_color_chat_nick_prefix), CONFIG_COLOR(config_color_chat_bg)); + gui_color_build (GUI_COLOR_CHAT_NICK_SUFFIX, CONFIG_COLOR(config_color_chat_nick_suffix), CONFIG_COLOR(config_color_chat_bg)); /* * define old nick colors for compatibility on /upgrade with previous diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index aa6dd7ba7..7aa539902 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -76,6 +76,8 @@ enum t_gui_color_enum GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER, GUI_COLOR_CHAT_NICK_OFFLINE, GUI_COLOR_CHAT_NICK_OFFLINE_HIGHLIGHT, + GUI_COLOR_CHAT_NICK_PREFIX, + GUI_COLOR_CHAT_NICK_SUFFIX, /* number of colors */ GUI_COLOR_NUM_COLORS, diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 6636fc745..8e9f78e3c 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -149,7 +149,7 @@ gui_line_prefix_is_same_nick_as_previous (struct t_gui_line *line) void gui_line_get_prefix_for_display (struct t_gui_line *line, char **prefix, int *length, - char **color) + char **color, int *prefix_is_nick) { const char *tag_prefix_nick; @@ -160,6 +160,7 @@ gui_line_get_prefix_for_display (struct t_gui_line *line, /* same nick: return empty prefix or value from option */ if (strcmp (CONFIG_STRING(config_look_prefix_same_nick), " ") == 0) { + /* return empty prefix */ if (prefix) *prefix = gui_chat_prefix_empty; if (length) @@ -169,19 +170,20 @@ gui_line_get_prefix_for_display (struct t_gui_line *line, } else { + /* return prefix from option "weechat.look.prefix_same_nick" */ if (prefix) *prefix = CONFIG_STRING(config_look_prefix_same_nick); if (length) *length = config_length_prefix_same_nick; if (color) { - *color = NULL; tag_prefix_nick = gui_line_search_tag_starting_with (line, "prefix_nick_"); - if (tag_prefix_nick) - *color = (char *)(tag_prefix_nick + 12); + *color = (tag_prefix_nick) ? (char *)(tag_prefix_nick + 12) : NULL; } } + if (prefix_is_nick) + *prefix_is_nick = 0; } else { @@ -192,6 +194,8 @@ gui_line_get_prefix_for_display (struct t_gui_line *line, *length = line->data->prefix_length; if (color) *color = NULL; + if (prefix_is_nick) + *prefix_is_nick = gui_line_search_tag_starting_with (line, "prefix_nick_") ? 1 : 0; } } @@ -203,7 +207,7 @@ int gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, int with_suffix, int first_line) { - int length_time, length_buffer, length_suffix, prefix_length; + int length_time, length_buffer, length_suffix, prefix_length, prefix_is_nick; /* return immediately if alignment for end of lines is "time" */ if (!first_line @@ -253,7 +257,11 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, return length_time + length_buffer; } - gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL); + /* length of prefix */ + gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL, + &prefix_is_nick); + if (prefix_is_nick) + prefix_length += config_length_nick_prefix_suffix; if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE) { @@ -720,7 +728,7 @@ void gui_line_compute_prefix_max_length (struct t_gui_lines *lines) { struct t_gui_line *ptr_line; - int prefix_length; + int prefix_length, prefix_is_nick; lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min); @@ -729,7 +737,10 @@ gui_line_compute_prefix_max_length (struct t_gui_lines *lines) { if (ptr_line->data->displayed) { - gui_line_get_prefix_for_display (ptr_line, NULL, &prefix_length, NULL); + gui_line_get_prefix_for_display (ptr_line, NULL, &prefix_length, + NULL, &prefix_is_nick); + if (prefix_is_nick) + prefix_length += config_length_nick_prefix_suffix; if (prefix_length > lines->prefix_max_length) lines->prefix_max_length = prefix_length; } @@ -744,7 +755,7 @@ void gui_line_add_to_list (struct t_gui_lines *lines, struct t_gui_line *line) { - int prefix_length; + int prefix_length, prefix_is_nick; if (!lines->first_line) lines->first_line = line; @@ -755,7 +766,10 @@ gui_line_add_to_list (struct t_gui_lines *lines, lines->last_line = line; /* adjust "prefix_max_length" if this prefix length is > max */ - gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL); + gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL, + &prefix_is_nick); + if (prefix_is_nick) + prefix_length += config_length_nick_prefix_suffix; if (prefix_length > lines->prefix_max_length) lines->prefix_max_length = prefix_length; @@ -774,7 +788,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, { struct t_gui_window *ptr_win; struct t_gui_window_scroll *ptr_scroll; - int i, update_prefix_max_length, prefix_length; + int i, update_prefix_max_length, prefix_length, prefix_is_nick; for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { @@ -800,7 +814,10 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, } } - gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL); + gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL, + &prefix_is_nick); + if (prefix_is_nick) + prefix_length += config_length_nick_prefix_suffix; update_prefix_max_length = (prefix_length == lines->prefix_max_length); diff --git a/src/gui/gui-line.h b/src/gui/gui-line.h index 49006647f..d09009380 100644 --- a/src/gui/gui-line.h +++ b/src/gui/gui-line.h @@ -69,7 +69,7 @@ extern struct t_gui_lines *gui_lines_alloc (); extern void gui_lines_free (struct t_gui_lines *lines); extern void gui_line_get_prefix_for_display (struct t_gui_line *line, char **prefix, int *length, - char **color); + char **color, int *prefix_is_nick); extern int gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, int with_suffix, int first_line); diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h index 9566df185..271872434 100644 --- a/src/plugins/irc/irc-color.h +++ b/src/plugins/irc/irc-color.h @@ -73,8 +73,6 @@ #define IRC_COLOR_NICK_PREFIX_HALFOP weechat_color(weechat_config_string(irc_config_color_nick_prefix_halfop)) #define IRC_COLOR_NICK_PREFIX_VOICE weechat_color(weechat_config_string(irc_config_color_nick_prefix_voice)) #define IRC_COLOR_NICK_PREFIX_USER weechat_color(weechat_config_string(irc_config_color_nick_prefix_user)) -#define IRC_COLOR_NICK_PREFIX weechat_color(weechat_config_string(irc_config_color_nick_prefix)) -#define IRC_COLOR_NICK_SUFFIX weechat_color(weechat_config_string(irc_config_color_nick_suffix)) #define IRC_COLOR_NOTICE weechat_color(weechat_config_string(irc_config_color_notice)) #define IRC_COLOR_STATUS_NUMBER weechat_color("status_number") #define IRC_COLOR_STATUS_NAME weechat_color("status_name") diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 604a591da..dad57185d 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -59,8 +59,6 @@ struct t_config_option *irc_config_look_server_buffer; struct t_config_option *irc_config_look_pv_buffer; struct t_config_option *irc_config_look_new_channel_position; struct t_config_option *irc_config_look_new_pv_position; -struct t_config_option *irc_config_look_nick_prefix; -struct t_config_option *irc_config_look_nick_suffix; struct t_config_option *irc_config_look_nick_mode; struct t_config_option *irc_config_look_nick_mode_empty; struct t_config_option *irc_config_look_nick_color_force; @@ -107,8 +105,6 @@ struct t_config_option *irc_config_color_message_join; struct t_config_option *irc_config_color_message_quit; struct t_config_option *irc_config_color_mirc_remap; struct t_config_option *irc_config_color_nick_prefixes; -struct t_config_option *irc_config_color_nick_prefix; -struct t_config_option *irc_config_color_nick_suffix; struct t_config_option *irc_config_color_notice; struct t_config_option *irc_config_color_input_nick; struct t_config_option *irc_config_color_item_away; @@ -2209,16 +2205,6 @@ irc_config_init () "of server)"), "none|next|near_server", 0, 0, "none", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_nick_prefix = weechat_config_new_option ( - irc_config_file, ptr_section, - "nick_prefix", "string", - N_("text to display before nick in chat window"), - NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_nick_suffix = weechat_config_new_option ( - irc_config_file, ptr_section, - "nick_suffix", "string", - N_("text to display after nick in chat window"), - NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_nick_mode = weechat_config_new_option ( irc_config_file, ptr_section, "nick_mode", "integer", @@ -2551,20 +2537,6 @@ irc_config_init () NULL, 0, 0, "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;" "v:yellow;*:lightblue", NULL, 0, NULL, NULL, &irc_config_change_color_nick_prefixes, NULL, NULL, NULL); - irc_config_color_nick_prefix = weechat_config_new_option ( - irc_config_file, ptr_section, - "nick_prefix", "color", - N_("color for nick prefix (prefix is custom string displayed " - "before nick)"), - NULL, -1, 0, "green", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); - irc_config_color_nick_suffix = weechat_config_new_option ( - irc_config_file, ptr_section, - "nick_suffix", "color", - N_("color for nick suffix (suffix is custom string displayed " - "after nick)"), - NULL, -1, 0, "green", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); irc_config_color_notice = weechat_config_new_option ( irc_config_file, ptr_section, "notice", "color", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 6a9c3f21d..f4fc847ff 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -101,8 +101,6 @@ extern struct t_config_option *irc_config_look_server_buffer; extern struct t_config_option *irc_config_look_pv_buffer; extern struct t_config_option *irc_config_look_new_channel_position; extern struct t_config_option *irc_config_look_new_pv_position; -extern struct t_config_option *irc_config_look_nick_prefix; -extern struct t_config_option *irc_config_look_nick_suffix; extern struct t_config_option *irc_config_look_nick_mode; extern struct t_config_option *irc_config_look_nick_mode_empty; extern struct t_config_option *irc_config_look_nick_color_force; @@ -147,8 +145,6 @@ extern struct t_config_option *irc_config_color_message_join; extern struct t_config_option *irc_config_color_message_quit; extern struct t_config_option *irc_config_color_mirc_remap; extern struct t_config_option *irc_config_color_nick_prefixes; -extern struct t_config_option *irc_config_color_nick_prefix; -extern struct t_config_option *irc_config_color_nick_suffix; extern struct t_config_option *irc_config_color_notice; extern struct t_config_option *irc_config_color_input_nick; extern struct t_config_option *irc_config_color_item_away; diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 4ea83df4f..ce83bf0cf 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -956,22 +956,10 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick, { static char result[256]; - snprintf (result, sizeof (result), "%s%s%s%s%s%s%s\t", - (weechat_config_string (irc_config_look_nick_prefix) - && weechat_config_string (irc_config_look_nick_prefix)[0]) ? - IRC_COLOR_NICK_PREFIX : "", - (weechat_config_string (irc_config_look_nick_prefix) - && weechat_config_string (irc_config_look_nick_prefix)[0]) ? - weechat_config_string (irc_config_look_nick_prefix) : "", + snprintf (result, sizeof (result), "%s%s%s\t", irc_nick_mode_for_display (server, nick, 1), (force_color) ? force_color : ((nick) ? nick->color : ((nickname) ? irc_nick_find_color (nickname) : IRC_COLOR_CHAT_NICK)), - (nick) ? nick->name : nickname, - (weechat_config_string (irc_config_look_nick_suffix) - && weechat_config_string (irc_config_look_nick_suffix)[0]) ? - IRC_COLOR_NICK_SUFFIX : "", - (weechat_config_string (irc_config_look_nick_suffix) - && weechat_config_string (irc_config_look_nick_suffix)[0]) ? - weechat_config_string (irc_config_look_nick_suffix) : ""); + (nick) ? nick->name : nickname); return result; } diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c index c1d5db74c..a0e64d9da 100644 --- a/src/plugins/logger/logger-config.c +++ b/src/plugins/logger/logger-config.c @@ -52,6 +52,8 @@ struct t_config_option *logger_config_file_mask; struct t_config_option *logger_config_file_replacement_char; struct t_config_option *logger_config_file_info_lines; struct t_config_option *logger_config_file_time_format; +struct t_config_option *logger_config_file_nick_prefix; +struct t_config_option *logger_config_file_nick_suffix; /* @@ -474,6 +476,16 @@ logger_config_init () N_("timestamp used in log files (see man strftime for date/time " "specifiers)"), NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + logger_config_file_nick_prefix = weechat_config_new_option ( + logger_config_file, ptr_section, + "nick_prefix", "string", + N_("text to write before nick in prefix of message, example: \"<\""), + NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + logger_config_file_nick_suffix = weechat_config_new_option ( + logger_config_file, ptr_section, + "nick_suffix", "string", + N_("text to write after nick in prefix of message, example: \">\""), + NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); /* level */ ptr_section = weechat_config_new_section (logger_config_file, "level", diff --git a/src/plugins/logger/logger-config.h b/src/plugins/logger/logger-config.h index 3326a6a79..099d1bd36 100644 --- a/src/plugins/logger/logger-config.h +++ b/src/plugins/logger/logger-config.h @@ -35,6 +35,8 @@ extern struct t_config_option *logger_config_file_mask; extern struct t_config_option *logger_config_file_replacement_char; extern struct t_config_option *logger_config_file_info_lines; extern struct t_config_option *logger_config_file_time_format; +extern struct t_config_option *logger_config_file_nick_prefix; +extern struct t_config_option *logger_config_file_nick_suffix; extern struct t_config_option *logger_config_get_level (const char *name); extern int logger_config_set_level (const char *name, const char *value); diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index 6c23e0881..183905b6a 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -1172,32 +1172,52 @@ logger_day_changed_signal_cb (void *data, const char *signal, } /* - * Gets log level for a line (using its tags). + * Gets info with tags of line: log level and if prefix is a nick. */ -int -logger_line_log_level (int tags_count, const char **tags) +void +logger_get_line_tag_info (int tags_count, const char **tags, + int *log_level, int *prefix_is_nick) { - int i; + int i, log_level_set, prefix_is_nick_set; + + if (log_level) + *log_level = LOGGER_LEVEL_DEFAULT; + if (prefix_is_nick) + *prefix_is_nick = 0; + + log_level_set = 0; + prefix_is_nick_set = 0; for (i = 0; i < tags_count; i++) { - /* log disabled on line? return -1 */ - if (strcmp (tags[i], "no_log") == 0) - return -1; - - /* log level for line? return it */ - if (strncmp (tags[i], "log", 3) == 0) + if (log_level && !log_level_set) { - if (isdigit ((unsigned char)tags[i][3])) + if (strcmp (tags[i], "no_log") == 0) { - return (tags[i][3] - '0'); + /* log disabled on line: set level to -1 */ + *log_level = -1; + log_level_set = 1; + } + else if (strncmp (tags[i], "log", 3) == 0) + { + /* set log level for line */ + if (isdigit ((unsigned char)tags[i][3])) + { + *log_level = (tags[i][3] - '0'); + log_level_set = 1; + } + } + } + if (prefix_is_nick && !prefix_is_nick_set) + { + if (strncmp (tags[i], "prefix_nick", 11) == 0) + { + *prefix_is_nick = 1; + prefix_is_nick_set = 1; } } } - - /* return default log level for line */ - return LOGGER_LEVEL_DEFAULT; } /* @@ -1213,14 +1233,15 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, struct t_logger_buffer *ptr_logger_buffer; struct tm *date_tmp; char buf_time[256]; - int line_log_level; + int line_log_level, prefix_is_nick; /* make C compiler happy */ (void) data; (void) displayed; (void) highlight; - line_log_level = logger_line_log_level (tags_count, tags); + logger_get_line_tag_info (tags_count, tags, &line_log_level, + &prefix_is_nick); if (line_log_level >= 0) { ptr_logger_buffer = logger_buffer_search_buffer (buffer); @@ -1239,9 +1260,11 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, } logger_write_line (ptr_logger_buffer, - "%s\t%s\t%s", + "%s\t%s%s%s\t%s", buf_time, + (prefix && prefix_is_nick) ? weechat_config_string (logger_config_file_nick_prefix) : "", (prefix) ? prefix : "", + (prefix && prefix_is_nick) ? weechat_config_string (logger_config_file_nick_suffix) : "", message); } } |