mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 02:03:13 +02:00
Add new option irc.look.color_nicks_in_nicklist
This commit is contained in:
@@ -50,6 +50,7 @@ struct t_config_section *irc_config_section_server = NULL;
|
||||
|
||||
/* IRC config, look section */
|
||||
|
||||
struct t_config_option *irc_config_look_color_nicks_in_nicklist;
|
||||
struct t_config_option *irc_config_look_color_nicks_in_server_messages;
|
||||
struct t_config_option *irc_config_look_color_pv_nick_like_channel;
|
||||
struct t_config_option *irc_config_look_server_buffer;
|
||||
@@ -229,6 +230,41 @@ irc_config_change_nick_colors_cb (void *data, const char *option,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_change_look_color_nicks_in_nicklist: called when the
|
||||
* "color nicks in nicklist"
|
||||
* option is changed
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_look_color_nicks_in_nicklist (void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
for (ptr_nick = ptr_channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
irc_nick_nicklist_set (ptr_channel, ptr_nick, "color",
|
||||
irc_nick_get_color_for_nicklist (ptr_server,
|
||||
ptr_nick));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_change_look_server_buffer: called when the "one server buffer"
|
||||
* option is changed
|
||||
@@ -1765,7 +1801,13 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
irc_config_look_color_nicks_in_nicklist = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"color_nicks_in_nicklist", "boolean",
|
||||
N_("use nick color in nicklist"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_look_color_nicks_in_nicklist, NULL, NULL, NULL);
|
||||
irc_config_look_color_nicks_in_server_messages = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"color_nicks_in_server_messages", "boolean",
|
||||
|
||||
@@ -75,6 +75,7 @@ extern struct t_config_section *irc_config_section_ctcp;
|
||||
extern struct t_config_section *irc_config_section_server_default;
|
||||
extern struct t_config_section *irc_config_section_server;
|
||||
|
||||
extern struct t_config_option *irc_config_look_color_nicks_in_nicklist;
|
||||
extern struct t_config_option *irc_config_look_color_nicks_in_server_messages;
|
||||
extern struct t_config_option *irc_config_look_color_pv_nick_like_channel;
|
||||
extern struct t_config_option *irc_config_look_server_buffer;
|
||||
|
||||
+51
-27
@@ -410,6 +410,54 @@ irc_nick_get_prefix_color (struct t_irc_server *server,
|
||||
return prefix_color;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_get_prefix_color_name: return name of color with a prefix number
|
||||
*/
|
||||
|
||||
const char *
|
||||
irc_nick_get_prefix_color_name (int prefix_color)
|
||||
{
|
||||
static char *color_for_prefix[] = {
|
||||
"chat",
|
||||
"irc.color.nick_prefix_op",
|
||||
"irc.color.nick_prefix_halfop",
|
||||
"irc.color.nick_prefix_voice",
|
||||
"irc.color.nick_prefix_user",
|
||||
};
|
||||
|
||||
if ((prefix_color >= 0) && (prefix_color <= 4))
|
||||
return color_for_prefix[prefix_color];
|
||||
|
||||
/* no color by default (should not happen) */
|
||||
return color_for_prefix[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_get_color_for_nicklist: get nick color for nicklist
|
||||
*/
|
||||
|
||||
const char *
|
||||
irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
static char *nick_color_bar_fg = "bar_fg";
|
||||
static char *nick_color_self = "weechat.color.chat_nick_self";
|
||||
static char *nick_color_away = "weechat.color.nicklist_away";
|
||||
|
||||
if (nick->away)
|
||||
return nick_color_away;
|
||||
|
||||
if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist))
|
||||
{
|
||||
if (weechat_strcasecmp (nick->name, server->nick) == 0)
|
||||
return nick_color_self;
|
||||
else
|
||||
return irc_nick_find_color_name (nick->name);
|
||||
}
|
||||
|
||||
return nick_color_bar_fg;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_nicklist_add: add nick to buffer nicklist
|
||||
*/
|
||||
@@ -421,13 +469,12 @@ irc_nick_nicklist_add (struct t_irc_server *server,
|
||||
{
|
||||
int prefix_color;
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
|
||||
prefix_color = irc_nick_get_prefix_color (server, nick);
|
||||
weechat_nicklist_add_nick (channel->buffer, ptr_group,
|
||||
nick->name,
|
||||
(nick->away) ?
|
||||
"weechat.color.nicklist_away" : "bar_fg",
|
||||
irc_nick_get_color_for_nicklist (server, nick),
|
||||
nick->prefix,
|
||||
irc_nick_get_prefix_color_name (prefix_color),
|
||||
1);
|
||||
@@ -469,28 +516,6 @@ irc_nick_nicklist_set (struct t_irc_channel *channel,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_get_prefix_color_name: return name of color with a prefix number
|
||||
*/
|
||||
|
||||
const char *
|
||||
irc_nick_get_prefix_color_name (int prefix_color)
|
||||
{
|
||||
static char *color_for_prefix[] = {
|
||||
"chat",
|
||||
"irc.color.nick_prefix_op",
|
||||
"irc.color.nick_prefix_halfop",
|
||||
"irc.color.nick_prefix_voice",
|
||||
"irc.color.nick_prefix_user",
|
||||
};
|
||||
|
||||
if ((prefix_color >= 0) && (prefix_color <= 4))
|
||||
return color_for_prefix[prefix_color];
|
||||
|
||||
/* no color by default (should not happen) */
|
||||
return color_for_prefix[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_new: allocate a new nick for a channel and add it to the nick list
|
||||
*/
|
||||
@@ -769,8 +794,7 @@ irc_nick_set_away (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
{
|
||||
nick->away = is_away;
|
||||
irc_nick_nicklist_set (channel, nick, "color",
|
||||
(nick->away) ?
|
||||
"weechat.color.nicklist_away" : "bar_fg");
|
||||
irc_nick_get_color_for_nicklist (server, nick));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ extern int irc_nick_has_prefix_mode (struct t_irc_server *server,
|
||||
extern int irc_nick_get_prefix_color (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick);
|
||||
extern const char *irc_nick_get_prefix_color_name (int prefix_color);
|
||||
extern const char *irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick);
|
||||
extern void irc_nick_nicklist_set (struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick,
|
||||
const char *property, const char *value);
|
||||
extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel,
|
||||
const char *nickname,
|
||||
|
||||
Reference in New Issue
Block a user