mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 00:33:13 +02:00
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).
This commit is contained in:
@@ -344,19 +344,23 @@ irc_command_me_channel_display (struct t_irc_server *server,
|
||||
const char *arguments)
|
||||
{
|
||||
char *string;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
string = (arguments && arguments[0]) ?
|
||||
irc_color_decode (arguments,
|
||||
weechat_config_boolean (irc_config_network_colors_receive)) : NULL;
|
||||
ptr_nick = irc_nick_search (server, channel, server->nick);
|
||||
weechat_printf_tags (channel->buffer,
|
||||
irc_protocol_tags ("privmsg",
|
||||
"irc_action,notify_none,no_highlight",
|
||||
server->nick),
|
||||
"%s%s%s%s %s",
|
||||
"%s%s%s%s%s%s%s",
|
||||
weechat_prefix ("action"),
|
||||
irc_nick_mode_for_display (server, ptr_nick, 0),
|
||||
IRC_COLOR_CHAT_NICK_SELF,
|
||||
server->nick,
|
||||
IRC_COLOR_RESET,
|
||||
(string) ? IRC_COLOR_RESET : "",
|
||||
(string) ? " " : "",
|
||||
(string) ? string : "");
|
||||
if (string)
|
||||
free (string);
|
||||
|
||||
@@ -62,6 +62,8 @@ struct t_config_option *irc_config_look_new_channel_position;
|
||||
struct t_config_option *irc_config_look_new_pv_position;
|
||||
struct t_config_option *irc_config_look_nick_prefix;
|
||||
struct t_config_option *irc_config_look_nick_suffix;
|
||||
struct t_config_option *irc_config_look_nick_mode;
|
||||
struct t_config_option *irc_config_look_nick_mode_empty;
|
||||
struct t_config_option *irc_config_look_nick_color_force;
|
||||
struct t_config_option *irc_config_look_nick_color_stop_chars;
|
||||
struct t_config_option *irc_config_look_nick_completion_smart;
|
||||
@@ -2074,6 +2076,21 @@ irc_config_init ()
|
||||
"nick_suffix", "string",
|
||||
N_("text to display after nick in chat window"),
|
||||
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_nick_mode = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"nick_mode", "integer",
|
||||
N_("display nick mode (op, voice, ...) before nick (none = never, "
|
||||
"prefix = in prefix only (default), action = in action messages "
|
||||
"only, both = prefix + action messages)"),
|
||||
"none|prefix|action|both", 0, 0, "prefix",
|
||||
NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_nick_mode_empty = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"nick_mode_empty", "boolean",
|
||||
N_("display a space if nick mode is enabled but nick has no mode (not "
|
||||
"op, voice, ...)"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
irc_config_look_nick_color_force = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"nick_color_force", "string",
|
||||
|
||||
@@ -55,6 +55,14 @@ enum t_irc_config_look_notice_as_pv
|
||||
IRC_CONFIG_LOOK_NOTICE_AS_PV_ALWAYS,
|
||||
};
|
||||
|
||||
enum t_irc_config_look_nick_mode
|
||||
{
|
||||
IRC_CONFIG_LOOK_NICK_MODE_NONE = 0,
|
||||
IRC_CONFIG_LOOK_NICK_MODE_PREFIX,
|
||||
IRC_CONFIG_LOOK_NICK_MODE_ACTION,
|
||||
IRC_CONFIG_LOOK_NICK_MODE_BOTH,
|
||||
};
|
||||
|
||||
enum t_irc_config_nick_completion
|
||||
{
|
||||
IRC_CONFIG_NICK_COMPLETION_SMART_OFF = 0,
|
||||
@@ -87,6 +95,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_mode;
|
||||
extern struct t_config_option *irc_config_look_nick_mode_empty;
|
||||
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;
|
||||
|
||||
@@ -946,8 +946,9 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
"irc_action,notify_none,no_highlight" :
|
||||
"irc_action,notify_message",
|
||||
nick),
|
||||
"%s%s%s%s%s%s",
|
||||
"%s%s%s%s%s%s%s",
|
||||
weechat_prefix ("action"),
|
||||
irc_nick_mode_for_display (server, ptr_nick, 0),
|
||||
(ptr_nick) ? ptr_nick->color : ((nick) ? irc_nick_find_color (nick) : IRC_COLOR_CHAT_NICK),
|
||||
nick,
|
||||
(pos_args) ? IRC_COLOR_RESET : "",
|
||||
|
||||
+42
-18
@@ -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)
|
||||
|
||||
@@ -85,10 +85,13 @@ extern void irc_nick_count (struct t_irc_server *server,
|
||||
extern void irc_nick_set_away (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick, int is_away);
|
||||
extern char *irc_nick_as_prefix (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname,
|
||||
const char *force_color);
|
||||
extern const char *irc_nick_mode_for_display (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
int prefix);
|
||||
extern const char *irc_nick_as_prefix (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname,
|
||||
const char *force_color);
|
||||
extern const char *irc_nick_color_for_message (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname);
|
||||
|
||||
Reference in New Issue
Block a user