1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 17:53:13 +02:00

irc: use tag "prefix_nick_ccc" (where "ccc" is color of nick) in messages displayed

This new tag is used by WeeChat to hide/replace same prefix (option weechat.look.prefix_same_nick).
This commit is contained in:
Sebastien Helleu
2012-04-03 21:24:24 +02:00
parent 5459e6595a
commit 93a77c39ba
4 changed files with 48 additions and 11 deletions
+14
View File
@@ -403,3 +403,17 @@ irc_color_modifier_cb (void *data, const char *modifier,
/* unknown modifier */
return NULL;
}
/*
* irc_color_for_tags: return color name for tags (replace "," by ":")
* Note: result must be freed after use
*/
char *
irc_color_for_tags (const char *color)
{
if (!color)
return NULL;
return weechat_string_replace (color, ",", ":");
}
+1
View File
@@ -96,5 +96,6 @@ extern char *irc_color_encode (const char *string, int keep_colors);
extern char *irc_color_modifier_cb (void *data, const char *modifier,
const char *modifier_data,
const char *string);
extern char *irc_color_for_tags (const char *color);
#endif /* __WEECHAT_IRC_COLOR_H */
+8 -2
View File
@@ -45,7 +45,7 @@ void
irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
{
struct t_irc_nick *ptr_nick;
char *text_decoded;
char *text_decoded, str_tags[256], *str_color;
text_decoded = irc_color_decode (text,
weechat_config_boolean (irc_config_network_colors_send));
@@ -61,9 +61,15 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
ptr_server->nick);
}
str_color = irc_color_for_tags (weechat_config_color (weechat_config_get ("weechat.color.chat_nick_self")));
snprintf (str_tags, sizeof (str_tags),
"notify_none,no_highlight,prefix_nick_%s",
(str_color) ? str_color : "default");
if (str_color)
free (str_color);
weechat_printf_tags (buffer,
irc_protocol_tags ("privmsg",
"notify_none,no_highlight",
str_tags,
(ptr_nick) ? ptr_nick->name : ptr_server->nick),
"%s%s",
irc_nick_as_prefix (ptr_server,
+25 -9
View File
@@ -1468,7 +1468,7 @@ IRC_PROTOCOL_CALLBACK(pong)
IRC_PROTOCOL_CALLBACK(privmsg)
{
char *pos_args, *pos_target;
char *pos_args, *pos_target, str_tags[256], *str_color;
const char *remote_nick;
int msg_op, msg_voice, is_channel, nick_is_me;
struct t_irc_channel *ptr_channel;
@@ -1559,10 +1559,14 @@ IRC_PROTOCOL_CALLBACK(privmsg)
else
{
/* standard message (to "#channel") */
str_color = irc_color_for_tags (irc_nick_find_color_name ((ptr_nick) ? ptr_nick->name : nick));
snprintf (str_tags, sizeof (str_tags),
"notify_message,prefix_nick_%s",
(str_color) ? str_color : "default");
if (str_color)
free (str_color);
weechat_printf_tags (ptr_channel->buffer,
irc_protocol_tags (command,
"notify_message",
nick),
irc_protocol_tags (command, str_tags, nick),
"%s%s",
irc_nick_as_prefix (server, ptr_nick,
(ptr_nick) ? NULL : nick,
@@ -1615,12 +1619,24 @@ IRC_PROTOCOL_CALLBACK(privmsg)
}
irc_channel_set_topic (ptr_channel, address);
if (nick_is_me)
str_color = irc_color_for_tags (weechat_config_color (weechat_config_get ("weechat.color.chat_nick_self")));
else
{
if (weechat_config_boolean (irc_config_look_color_pv_nick_like_channel))
str_color = irc_color_for_tags (irc_nick_find_color_name (nick));
else
str_color = irc_color_for_tags (weechat_config_color (weechat_config_get ("weechat.color.chat_nick_other")));
}
snprintf (str_tags, sizeof (str_tags),
(nick_is_me) ?
"notify_none,no_highlight,prefix_nick_%s" :
"notify_private,prefix_nick_%s",
(str_color) ? str_color : "default");
if (str_color)
free (str_color);
weechat_printf_tags (ptr_channel->buffer,
irc_protocol_tags (command,
(nick_is_me) ?
"notify_none,no_highlight" :
"notify_private",
nick),
irc_protocol_tags (command, str_tags, nick),
"%s%s",
irc_nick_as_prefix (server, NULL, nick,
(nick_is_me) ?