diff options
Diffstat (limited to 'src/plugins/irc/irc-nick.c')
-rw-r--r-- | src/plugins/irc/irc-nick.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 5c474440a..9ea273910 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -90,7 +90,8 @@ irc_nick_is_nick (const char *string) } /* - * irc_nick_find_color: find a color for a nick (according to nick letters) + * irc_nick_find_color: find a color code for a nick + * (according to nick letters) */ const char * @@ -117,6 +118,34 @@ irc_nick_find_color (const char *nickname) } /* + * irc_nick_find_color_name: find a color name for a nick + * (according to nick letters) + */ + +const char * +irc_nick_find_color_name (const char *nickname) +{ + int color; + char color_name[128]; + const char *ptr_nick; + + color = 0; + ptr_nick = nickname; + while (ptr_nick && ptr_nick[0]) + { + color += weechat_utf8_char_int (ptr_nick); + ptr_nick = weechat_utf8_next_char (ptr_nick); + } + color = (color % + weechat_config_integer (weechat_config_get ("weechat.look.color_nicks_number"))); + + snprintf (color_name, sizeof (color_name), + "weechat.color.chat_nick_color%02d", color + 1); + + return weechat_config_color (weechat_config_get (color_name)); +} + +/* * irc_nick_get_gui_infos: get GUI infos for a nick (sort_index, prefix, * prefix color) */ |