1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 20:45:42 +02:00

Add new option irc.look.nick_color_force

This commit is contained in:
Sebastien Helleu
2010-10-29 23:25:05 +02:00
parent 90c99339b4
commit fcc209a8bf
18 changed files with 295 additions and 117 deletions
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -82,6 +82,8 @@ extern struct t_config_option *irc_config_look_new_channel_position;
extern struct t_config_option *irc_config_look_new_pv_position;
extern struct t_config_option *irc_config_look_nick_prefix;
extern struct t_config_option *irc_config_look_nick_suffix;
extern struct t_config_option *irc_config_look_nick_color_force;
extern struct t_config_option *irc_config_look_nick_color_stop_chars;
extern struct t_config_option *irc_config_look_nick_completion_smart;
extern struct t_config_option *irc_config_look_display_away;
extern struct t_config_option *irc_config_look_display_ctcp_blocked;
@@ -102,7 +104,6 @@ extern struct t_config_option *irc_config_look_hide_nickserv_pwd;
extern struct t_config_option *irc_config_look_highlight_tags;
extern struct t_config_option *irc_config_look_item_display_server;
extern struct t_config_option *irc_config_look_msgbuffer_fallback;
extern struct t_config_option *irc_config_look_nick_color_stop_chars;
extern struct t_config_option *irc_config_look_notice_as_pv;
extern struct t_config_option *irc_config_look_part_closes_buffer;
extern struct t_config_option *irc_config_look_raw_messages;
@@ -140,6 +141,8 @@ extern struct t_config_option *irc_config_network_send_unknown_commands;
extern struct t_config_option *irc_config_server_default[];
extern struct t_hashtable *irc_config_hashtable_nick_color_force;
extern void irc_config_server_change_cb (void *data,
struct t_config_option *option);
struct t_config_option *irc_config_server_new_option (struct t_config_file *config_file,
+40 -6
View File
@@ -162,15 +162,32 @@ irc_nick_find_color (const char *nickname)
{
int color;
char *nickname2, color_name[64];
const char *forced_color;
nickname2 = irc_nick_strdup_for_color (nickname);
/* look if color is forced */
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
(nickname2) ? nickname2 : nickname);
if (forced_color)
{
forced_color = weechat_color (forced_color);
if (forced_color && forced_color[0])
{
if (nickname2)
free (nickname2);
return forced_color;
}
}
/* hash nickname to get color */
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
if (nickname2)
free (nickname2);
/* return color */
snprintf (color_name, sizeof (color_name),
"chat_nick_color%02d", color + 1);
return weechat_color (color_name);
}
@@ -184,15 +201,28 @@ irc_nick_find_color_name (const char *nickname)
{
int color;
char *nickname2, color_name[128];
const char *forced_color;
nickname2 = irc_nick_strdup_for_color (nickname);
/* look if color is forced */
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
(nickname2) ? nickname2 : nickname);
if (forced_color)
{
if (nickname2)
free (nickname2);
return forced_color;
}
/* hash nickname to get color */
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
if (nickname2)
free (nickname2);
/* return color name */
snprintf (color_name, sizeof (color_name),
"weechat.color.chat_nick_color%02d", color + 1);
return weechat_config_color (weechat_config_get (color_name));
}
@@ -493,9 +523,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
irc_nick_set_prefixes (server, new_nick, prefixes);
new_nick->away = away;
if (weechat_strcasecmp (new_nick->name, server->nick) == 0)
new_nick->color = IRC_COLOR_CHAT_NICK_SELF;
new_nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
else
new_nick->color = irc_nick_find_color (new_nick->name);
new_nick->color = strdup (irc_nick_find_color (new_nick->name));
/* add nick to end of list */
new_nick->prev_nick = channel->last_nick;
@@ -539,10 +569,12 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
if (nick->name)
free (nick->name);
nick->name = strdup (new_nick);
if (nick->color)
free (nick->color);
if (nick_is_me)
nick->color = IRC_COLOR_CHAT_NICK_SELF;
nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
else
nick->color = irc_nick_find_color (nick->name);
nick->color = strdup (irc_nick_find_color (nick->name));
/* add nick in nicklist */
irc_nick_nicklist_add (server, channel, nick);
@@ -616,6 +648,8 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
free (nick->host);
if (nick->prefixes)
free (nick->prefixes);
if (nick->color)
free (nick->color);
free (nick);
+1 -1
View File
@@ -36,7 +36,7 @@ struct t_irc_nick
char prefix[2]; /* current prefix (higher prefix set in */
/* prefixes) */
int away; /* 1 if nick is away */
const char *color; /* color for nickname in chat window */
char *color; /* color for nickname in chat window */
struct t_irc_nick *prev_nick; /* link to previous nick on channel */
struct t_irc_nick *next_nick; /* link to next nick on channel */
};