diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-06-15 14:13:59 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-06-15 14:13:59 +0200 |
commit | de49e31965b0d0c8357a181335bc8210f1e69a45 (patch) | |
tree | 7fb3a78facfbd07a94829a6294eff87f39970726 /src/plugins/irc/irc-nick.c | |
parent | 44c95288ab28f9ccc5a6901226a987222000c66f (diff) | |
download | weechat-de49e31965b0d0c8357a181335bc8210f1e69a45.zip |
Add IRC info "irc_nick_color_name" to get color name of a nick
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) */ |