summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-nick.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-08-20 18:25:23 +0200
committerSebastien Helleu <flashcode@flashtux.org>2012-08-20 18:25:23 +0200
commita4e15e8ef40e3f9c20cde8c276798c5785cbde31 (patch)
tree36dd53f9321b2c582f3a1993b0f7568ec8d23128 /src/plugins/irc/irc-nick.c
parent1fe7d25c8d51a5798e29981f89d32a931f94a13e (diff)
downloadweechat-a4e15e8ef40e3f9c20cde8c276798c5785cbde31.zip
irc: move options weechat.look.nickmode{_empty} to irc.look.nick_mode{_empty}, add nick mode for action messages (patch from Nils Görs)
The option irc.look.nick_mode has a new type: integer with values: none/prefix/action/both (default is "prefix", which is old behaviour).
Diffstat (limited to 'src/plugins/irc/irc-nick.c')
-rw-r--r--src/plugins/irc/irc-nick.c60
1 files changed, 42 insertions, 18 deletions
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index ab33b6f1d..00b7bb24e 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -879,51 +879,75 @@ irc_nick_set_away (struct t_irc_server *server, struct t_irc_channel *channel,
}
/*
- * irc_nick_as_prefix: return string with nick to display as prefix on buffer
- * (string will end by a tab)
+ * irc_nick_mode_for_display: get nick mode for display (color + mode)
+ * if prefix == 1, return string for display in
+ * prefix, otherwise return string for display in
+ * action message (/me)
*/
-char *
-irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
- const char *nickname, const char *force_color)
+const char *
+irc_nick_mode_for_display (struct t_irc_server *server, struct t_irc_nick *nick,
+ int prefix)
{
- static char result[256];
- char prefix[2];
+ static char result[32];
+ char str_prefix[2];
+ int nick_mode;
const char *str_prefix_color;
- prefix[0] = (nick) ? nick->prefix[0] : '\0';
- prefix[1] = '\0';
- if (weechat_config_boolean (weechat_config_get ("weechat.look.nickmode")))
+ str_prefix[0] = (nick) ? nick->prefix[0] : '\0';
+ str_prefix[1] = '\0';
+
+ nick_mode = weechat_config_integer (irc_config_look_nick_mode);
+ if ((nick_mode == IRC_CONFIG_LOOK_NICK_MODE_BOTH)
+ || (prefix && (nick_mode == IRC_CONFIG_LOOK_NICK_MODE_PREFIX))
+ || (!prefix && (nick_mode == IRC_CONFIG_LOOK_NICK_MODE_ACTION)))
{
if (nick)
{
- if ((prefix[0] == ' ')
- && !weechat_config_boolean (weechat_config_get ("weechat.look.nickmode_empty")))
- prefix[0] = '\0';
+ if ((str_prefix[0] == ' ')
+ && (!prefix || !weechat_config_boolean (irc_config_look_nick_mode_empty)))
+ {
+ str_prefix[0] = '\0';
+ }
str_prefix_color = weechat_color (irc_nick_get_prefix_color_name (server, nick));
}
else
{
- prefix[0] = (weechat_config_boolean (weechat_config_get ("weechat.look.nickmode_empty"))) ?
+ str_prefix[0] = (prefix && weechat_config_boolean (irc_config_look_nick_mode_empty)) ?
' ' : '\0';
str_prefix_color = IRC_COLOR_RESET;
}
}
else
{
- prefix[0] = '\0';
+ str_prefix[0] = '\0';
str_prefix_color = IRC_COLOR_RESET;
}
- snprintf (result, sizeof (result), "%s%s%s%s%s%s%s%s\t",
+ snprintf (result, sizeof (result), "%s%s", str_prefix_color, str_prefix);
+
+ return result;
+}
+
+/*
+ * irc_nick_as_prefix: return string with nick to display as prefix on buffer
+ * (string will end by a tab)
+ */
+
+const char *
+irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
+ const char *nickname, const char *force_color)
+{
+ static char result[256];
+
+ snprintf (result, sizeof (result), "%s%s%s%s%s%s%s\t",
(weechat_config_string (irc_config_look_nick_prefix)
&& weechat_config_string (irc_config_look_nick_prefix)[0]) ?
IRC_COLOR_NICK_PREFIX : "",
(weechat_config_string (irc_config_look_nick_prefix)
&& weechat_config_string (irc_config_look_nick_prefix)[0]) ?
weechat_config_string (irc_config_look_nick_prefix) : "",
- str_prefix_color,
- prefix,
+ irc_nick_mode_for_display (server, nick, 1),
(force_color) ? force_color : ((nick) ? nick->color : ((nickname) ? irc_nick_find_color (nickname) : IRC_COLOR_CHAT_NICK)),
(nick) ? nick->name : nickname,
(weechat_config_string (irc_config_look_nick_suffix)