diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-04-03 21:22:53 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-04-03 21:22:53 +0200 |
commit | 5459e6595a5aaa36bb1e239d08407cbe9af2478c (patch) | |
tree | 873a72b436ea7ea7f4276df5f68b8214e61d448e /src/gui/curses/gui-curses-chat.c | |
parent | 7038630b6d242a97e3be0a16bd64059562570076 (diff) | |
download | weechat-5459e6595a5aaa36bb1e239d08407cbe9af2478c.zip |
core: fix bugs with option weechat.look.prefix_same_nick, use nick color for string used as replacement
Bugs fixed:
- hide/replace prefix only if prefix is a nick (do not do it for join/part/quit or action messages)
- hide/replace prefix only when displaying messages (do not cache value in lines)
The nick color used in replacement string comes from tag "prefix_nick_ccc", where "ccc" is the color of nick.
Diffstat (limited to 'src/gui/curses/gui-curses-chat.c')
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index cbdedbe98..509a6f406 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -575,8 +575,9 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, int simulate) { char str_space[] = " ", str_plus[] = "+"; - char *prefix_no_color, *prefix_highlighted, *ptr_prefix; - const char *short_name; + char *prefix_no_color, *prefix_highlighted, *ptr_prefix, *ptr_prefix2; + char *ptr_prefix_color; + const char *short_name, *str_color; int i, length, length_allowed, num_spaces, prefix_length, extra_spaces; int chars_displayed; struct t_gui_lines *mixed_lines; @@ -738,8 +739,30 @@ 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); + if (ptr_prefix) + { + ptr_prefix2 = NULL; + if (ptr_prefix_color && ptr_prefix_color[0]) + { + str_color = gui_color_get_custom (ptr_prefix_color); + if (str_color && str_color[0]) + { + length = strlen (str_color) + strlen (ptr_prefix) + 1; + ptr_prefix2 = malloc (length); + if (ptr_prefix2) + { + snprintf (ptr_prefix2, length, "%s%s", + str_color, ptr_prefix); + } + } + } + ptr_prefix = (ptr_prefix2) ? ptr_prefix2 : strdup (ptr_prefix); + } + /* display prefix */ - gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length); if (ptr_prefix && (ptr_prefix[0] || (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE))) @@ -921,6 +944,8 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, lines_displayed, simulate, 0); } } + if (ptr_prefix) + free (ptr_prefix); } /* |