1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 20:36:38 +02:00

irc: add search for lower case nicks in option irc.look.nick_color_force

This commit is contained in:
Sebastien Helleu
2012-02-26 18:18:37 +01:00
parent a1e87fe63d
commit f3dc2e7ef9
18 changed files with 179 additions and 113 deletions
+3 -1
View File
@@ -2087,7 +2087,9 @@ irc_config_init ()
"nick_color_force", "string",
N_("force color for some nicks: hash computed with nickname "
"to find color will not be used for these nicks (format is: "
"\"nick1:color1;nick2:color2\")"),
"\"nick1:color1;nick2:color2\"); lookup for nicks is with "
"exact case then lower case, so it's possible to use only lower "
"case for nicks in this option"),
NULL, 0, 0, "", NULL, 0, NULL, NULL,
&irc_config_change_look_nick_color_force, NULL, NULL, NULL);
irc_config_look_nick_color_stop_chars = weechat_config_new_option (
+33 -4
View File
@@ -159,6 +159,37 @@ irc_nick_hash_color (const char *nickname)
return (color % irc_config_num_nick_colors);
}
/*
* irc_nick_get_forced_color: get forced color for a nick
* (NULL if no color is forced for nick)
*/
const char *
irc_nick_get_forced_color (const char *nickname)
{
const char *forced_color;
char *nick_lower;
if (!nickname)
return NULL;
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
nickname);
if (forced_color)
return forced_color;
nick_lower = strdup (nickname);
if (nick_lower)
{
weechat_string_tolower (nick_lower);
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
nick_lower);
free (nick_lower);
}
return forced_color;
}
/*
* irc_nick_find_color: find a color code for a nick
* (according to nick letters)
@@ -178,8 +209,7 @@ irc_nick_find_color (const char *nickname)
return weechat_color ("default");
/* look if color is forced */
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
nickname);
forced_color = irc_nick_get_forced_color (nickname);
if (forced_color)
{
forced_color = weechat_color (forced_color);
@@ -218,8 +248,7 @@ irc_nick_find_color_name (const char *nickname)
return default_color;
/* look if color is forced */
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
nickname);
forced_color = irc_nick_get_forced_color (nickname);
if (forced_color)
return forced_color;