diff options
Diffstat (limited to 'src/gui/curses/gui-curses-chat.c')
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 94 |
1 files changed, 74 insertions, 20 deletions
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])) |