mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 00:33:13 +02:00
Add IRC info "irc_nick_color_name" to get color name of a nick
This commit is contained in:
@@ -102,6 +102,10 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
{
|
||||
return irc_nick_find_color (arguments);
|
||||
}
|
||||
else if (weechat_strcasecmp (info_name, "irc_nick_color_name") == 0)
|
||||
{
|
||||
return irc_nick_find_color_name (arguments);
|
||||
}
|
||||
else if (weechat_strcasecmp (info_name, "irc_buffer") == 0)
|
||||
{
|
||||
if (arguments && arguments[0])
|
||||
@@ -456,7 +460,10 @@ irc_info_init ()
|
||||
weechat_hook_info ("irc_nick_from_host", N_("get nick from IRC host"),
|
||||
N_("IRC host (like `:nick!name@server.com`)"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_nick_color", N_("get nick color"),
|
||||
weechat_hook_info ("irc_nick_color", N_("get nick color code"),
|
||||
N_("nickname"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_nick_color_name", N_("get nick color name"),
|
||||
N_("nickname"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel/nick"),
|
||||
|
||||
@@ -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 *
|
||||
@@ -116,6 +117,34 @@ irc_nick_find_color (const char *nickname)
|
||||
return weechat_color (color_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
|
||||
@@ -70,6 +70,7 @@ extern int irc_nick_valid (struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick);
|
||||
extern int irc_nick_is_nick (const char *string);
|
||||
extern const char *irc_nick_find_color (const char *nickname);
|
||||
extern const char *irc_nick_find_color_name (const char *nickname);
|
||||
extern void irc_nick_get_gui_infos (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
char *prefix, int *prefix_color,
|
||||
|
||||
Reference in New Issue
Block a user