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

Add option irc.look.item_nick_prefix, rename some IRC options for bar items

This commit is contained in:
Sebastien Helleu
2010-02-06 12:14:45 +01:00
parent fa8ff80fc1
commit bd1b6c1794
23 changed files with 356 additions and 242 deletions
+38 -9
View File
@@ -30,6 +30,7 @@
#include "irc-config.h"
#include "irc-server.h"
#include "irc-channel.h"
#include "irc-nick.h"
/*
@@ -226,12 +227,12 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
(part_from_channel) ? IRC_COLOR_BAR_DELIM : "",
(part_from_channel) ? ")" : "");
if (!part_from_channel
&& weechat_config_boolean (irc_config_look_display_channel_modes)
&& weechat_config_boolean (irc_config_look_item_channel_modes)
&& channel->modes && channel->modes[0]
&& (strcmp (channel->modes, "+") != 0))
{
modes_without_args = NULL;
if (weechat_config_boolean (irc_config_look_display_channel_modes_hide_key))
if (weechat_config_boolean (irc_config_look_item_channel_modes_hide_key))
{
pos_space = strchr(channel->modes, ' ');
if (pos_space)
@@ -400,8 +401,10 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
{
struct t_gui_buffer *buffer;
struct t_irc_server *server;
char *buf;
int length;
struct t_irc_channel *channel;
struct t_irc_nick *ptr_nick;
char *buf, prefix[2], str_prefix_color[64], str_prefix[64];
int length, prefix_color;
/* make C compiler happy */
(void) data;
@@ -414,20 +417,45 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
if (buffer)
{
irc_buffer_get_server_channel (buffer, &server, NULL);
irc_buffer_get_server_channel (buffer, &server, &channel);
if (!server || !server->nick)
return NULL;
length = strlen (server->nick) + 64 +
/* build prefix */
str_prefix[0] = '\0';
if (channel)
{
ptr_nick = irc_nick_search (channel, server->nick);
if (ptr_nick)
{
prefix[0] = '\0';
prefix[1] = '\0';
irc_nick_get_gui_infos (ptr_nick, &prefix[0], &prefix_color,
NULL, NULL);
if (prefix[0] != ' ')
{
snprintf (str_prefix_color, sizeof (str_prefix_color),
"weechat.color.nicklist_prefix%d",
prefix_color);
snprintf (str_prefix, sizeof (str_prefix), "%s%s",
weechat_color(weechat_config_string(weechat_config_get(str_prefix_color))),
prefix);
}
}
}
/* build bar item */
length = 64 + strlen (server->nick) + 64 +
((server->nick_modes) ? strlen (server->nick_modes) : 0) + 64 + 1;
buf = malloc (length);
if (buf)
{
if (weechat_config_boolean (irc_config_look_display_nick_modes)
if (weechat_config_boolean (irc_config_look_item_nick_modes)
&& server->nick_modes && server->nick_modes[0])
{
snprintf (buf, length, "%s%s%s(%s%s%s)",
snprintf (buf, length, "%s%s%s%s(%s%s%s)",
str_prefix,
IRC_COLOR_INPUT_NICK,
server->nick,
IRC_COLOR_BAR_DELIM,
@@ -437,7 +465,8 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
}
else
{
snprintf (buf, length, "%s%s",
snprintf (buf, length, "%s%s%s",
str_prefix,
IRC_COLOR_INPUT_NICK,
server->nick);
}
+7 -5
View File
@@ -337,7 +337,8 @@ irc_channel_is_channel (const char *string)
*/
void
irc_channel_remove_away (struct t_irc_channel *channel)
irc_channel_remove_away (struct t_irc_server *server,
struct t_irc_channel *channel)
{
struct t_irc_nick *ptr_nick;
@@ -345,7 +346,7 @@ irc_channel_remove_away (struct t_irc_channel *channel)
{
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
irc_nick_set (channel, ptr_nick, 0, IRC_NICK_AWAY);
irc_nick_set (server, channel, ptr_nick, 0, IRC_NICK_AWAY);
}
}
}
@@ -369,7 +370,7 @@ irc_channel_check_away (struct t_irc_server *server,
"WHO %s", channel->name);
}
else
irc_channel_remove_away (channel);
irc_channel_remove_away (server, channel);
}
}
@@ -378,7 +379,8 @@ irc_channel_check_away (struct t_irc_server *server,
*/
void
irc_channel_set_away (struct t_irc_channel *channel, const char *nick_name,
irc_channel_set_away (struct t_irc_server *server,
struct t_irc_channel *channel, const char *nick_name,
int is_away)
{
struct t_irc_nick *ptr_nick;
@@ -387,7 +389,7 @@ irc_channel_set_away (struct t_irc_channel *channel, const char *nick_name,
{
ptr_nick = irc_nick_search (channel, nick_name);
if (ptr_nick)
irc_nick_set_away (channel, ptr_nick, is_away);
irc_nick_set_away (server, channel, ptr_nick, is_away);
}
}
+4 -2
View File
@@ -85,10 +85,12 @@ extern void irc_channel_free_all (struct t_irc_server *server);
extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
const char *channel_name);
extern int irc_channel_is_channel (const char *string);
extern void irc_channel_remove_away (struct t_irc_channel *channel);
extern void irc_channel_remove_away (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_check_away (struct t_irc_server *server,
struct t_irc_channel *channel, int force);
extern void irc_channel_set_away (struct t_irc_channel *channel,
extern void irc_channel_set_away (struct t_irc_server *server,
struct t_irc_channel *channel,
const char *nick_name,
int is_away);
extern void irc_channel_nick_speaking_add (struct t_irc_channel *channel,
+83 -61
View File
@@ -55,13 +55,14 @@ 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_completion_smart;
struct t_config_option *irc_config_look_display_away;
struct t_config_option *irc_config_look_display_channel_modes;
struct t_config_option *irc_config_look_display_channel_modes_hide_key;
struct t_config_option *irc_config_look_display_ctcp_blocked;
struct t_config_option *irc_config_look_display_ctcp_reply;
struct t_config_option *irc_config_look_display_ctcp_unknown;
struct t_config_option *irc_config_look_display_nick_modes;
struct t_config_option *irc_config_look_display_old_topic;
struct t_config_option *irc_config_look_item_channel_modes;
struct t_config_option *irc_config_look_item_channel_modes_hide_key;
struct t_config_option *irc_config_look_item_nick_modes;
struct t_config_option *irc_config_look_item_nick_prefix;
struct t_config_option *irc_config_look_hide_nickserv_pwd;
struct t_config_option *irc_config_look_highlight_tags;
struct t_config_option *irc_config_look_item_display_server;
@@ -216,53 +217,68 @@ irc_config_change_look_server_buffer (void *data,
}
/*
* irc_config_change_look_display_channel_modes: called when the "display
* channel modes" option is
* changed
* irc_config_change_look_item_channel_modes: called when the "display
* channel modes" option is changed
*/
void
irc_config_change_look_display_channel_modes (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_name");
}
/*
* irc_config_change_look_display_channel_modes_hide_key: called when the
* "display channel modes
* hide key" option is
* changed
*/
void
irc_config_change_look_display_channel_modes_hide_key (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_name");
}
/*
* irc_config_change_look_display_nick_modes: called when the "display
* nick modes" option is changed
*/
void
irc_config_change_look_display_nick_modes (void *data,
irc_config_change_look_item_channel_modes (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_name");
}
/*
* irc_config_change_look_item_channel_modes_hide_key: called when the
* "display channel modes
* hide key" option is
* changed
*/
void
irc_config_change_look_item_channel_modes_hide_key (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_name");
}
/*
* irc_config_change_look_item_nick_modes: called when the "display nick modes"
* option is changed
*/
void
irc_config_change_look_item_nick_modes (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("input_prompt");
}
/*
* irc_config_change_look_item_nick_prefix: called when the "display nick
* prefix" option is changed
*/
void
irc_config_change_look_item_nick_prefix (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("input_prompt");
}
@@ -1378,20 +1394,6 @@ irc_config_init ()
N_("display message when (un)marking as away"),
"off|local|channel", 0, 0, "local", NULL, 0, NULL, NULL, NULL, NULL,
NULL, NULL);
irc_config_look_display_channel_modes = weechat_config_new_option (
irc_config_file, ptr_section,
"display_channel_modes", "boolean",
N_("display channel modes in \"buffer_name\" bar item"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&irc_config_change_look_display_channel_modes, NULL, NULL, NULL);
irc_config_look_display_channel_modes_hide_key = weechat_config_new_option (
irc_config_file, ptr_section,
"display_channel_modes_hide_key", "boolean",
N_("hide channel key if modes are displayed in \"buffer_name\" bar "
"item (this will hide all channel modes arguments if mode +k is "
"set on channel)"),
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
&irc_config_change_look_display_channel_modes_hide_key, NULL, NULL, NULL);
irc_config_look_display_ctcp_blocked = weechat_config_new_option (
irc_config_file, ptr_section,
"display_ctcp_blocked", "boolean",
@@ -1410,18 +1412,38 @@ irc_config_init ()
N_("display CTCP message even if it is unknown CTCP"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
irc_config_look_display_nick_modes = weechat_config_new_option (
irc_config_file, ptr_section,
"display_nick_modes", "boolean",
N_("display nick modes in \"input_prompt\" bar item"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&irc_config_change_look_display_nick_modes, NULL, NULL, NULL);
irc_config_look_display_old_topic = weechat_config_new_option (
irc_config_file, ptr_section,
"display_old_topic", "boolean",
N_("display old topic when channel topic is changed"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
irc_config_look_item_channel_modes = weechat_config_new_option (
irc_config_file, ptr_section,
"item_channel_modes", "boolean",
N_("display channel modes in \"buffer_name\" bar item"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&irc_config_change_look_item_channel_modes, NULL, NULL, NULL);
irc_config_look_item_channel_modes_hide_key = weechat_config_new_option (
irc_config_file, ptr_section,
"item_channel_modes_hide_key", "boolean",
N_("hide channel key if modes are displayed in \"buffer_name\" bar "
"item (this will hide all channel modes arguments if mode +k is "
"set on channel)"),
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
&irc_config_change_look_item_channel_modes_hide_key, NULL, NULL, NULL);
irc_config_look_item_nick_modes = weechat_config_new_option (
irc_config_file, ptr_section,
"item_nick_modes", "boolean",
N_("display nick modes in \"input_prompt\" bar item"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&irc_config_change_look_item_nick_modes, NULL, NULL, NULL);
irc_config_look_item_nick_prefix = weechat_config_new_option (
irc_config_file, ptr_section,
"item_nick_prefix", "boolean",
N_("display nick prefix in \"input_prompt\" bar item"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&irc_config_change_look_item_nick_prefix, NULL, NULL, NULL);
irc_config_look_hide_nickserv_pwd = weechat_config_new_option (
irc_config_file, ptr_section,
"hide_nickserv_pwd", "boolean",
+4 -3
View File
@@ -77,13 +77,14 @@ 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_completion_smart;
extern struct t_config_option *irc_config_look_display_away;
extern struct t_config_option *irc_config_look_display_channel_modes;
extern struct t_config_option *irc_config_look_display_channel_modes_hide_key;
extern struct t_config_option *irc_config_look_display_ctcp_blocked;
extern struct t_config_option *irc_config_look_display_ctcp_reply;
extern struct t_config_option *irc_config_look_display_ctcp_unknown;
extern struct t_config_option *irc_config_look_display_nick_modes;
extern struct t_config_option *irc_config_look_display_old_topic;
extern struct t_config_option *irc_config_look_item_channel_modes;
extern struct t_config_option *irc_config_look_item_channel_modes_hide_key;
extern struct t_config_option *irc_config_look_item_nick_modes;
extern struct t_config_option *irc_config_look_item_nick_prefix;
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;
+9 -8
View File
@@ -35,7 +35,8 @@
*/
void
irc_mode_channel_set_nick (struct t_irc_channel *channel, const char *nick,
irc_mode_channel_set_nick (struct t_irc_server *server,
struct t_irc_channel *channel, const char *nick,
char set_flag, int flag)
{
struct t_irc_nick *ptr_nick;
@@ -44,7 +45,7 @@ irc_mode_channel_set_nick (struct t_irc_channel *channel, const char *nick,
{
ptr_nick = irc_nick_search (channel, nick);
if (ptr_nick)
irc_nick_set (channel, ptr_nick, (set_flag == '+'), flag);
irc_nick_set (server, channel, ptr_nick, (set_flag == '+'), flag);
}
}
@@ -122,7 +123,7 @@ irc_mode_channel_set (struct t_irc_server *server,
ptr_arg = ((current_arg >= 0) && (current_arg < argc)) ?
argv[current_arg] : NULL;
if (irc_mode_nick_prefix_allowed (server, '~'))
irc_mode_channel_set_nick (channel, ptr_arg,
irc_mode_channel_set_nick (server, channel, ptr_arg,
set_flag, IRC_NICK_CHANADMIN);
current_arg++;
break;
@@ -135,7 +136,7 @@ irc_mode_channel_set (struct t_irc_server *server,
ptr_arg = ((current_arg >= 0) && (current_arg < argc)) ?
argv[current_arg] : NULL;
if (irc_mode_nick_prefix_allowed (server, '%'))
irc_mode_channel_set_nick (channel, ptr_arg,
irc_mode_channel_set_nick (server, channel, ptr_arg,
set_flag, IRC_NICK_HALFOP);
current_arg++;
break;
@@ -172,7 +173,7 @@ irc_mode_channel_set (struct t_irc_server *server,
ptr_arg = ((current_arg >= 0) && (current_arg < argc)) ?
argv[current_arg] : NULL;
if (irc_mode_nick_prefix_allowed (server, '@'))
irc_mode_channel_set_nick (channel, ptr_arg,
irc_mode_channel_set_nick (server, channel, ptr_arg,
set_flag, IRC_NICK_OP);
current_arg++;
break;
@@ -180,7 +181,7 @@ irc_mode_channel_set (struct t_irc_server *server,
ptr_arg = ((current_arg >= 0) && (current_arg < argc)) ?
argv[current_arg] : NULL;
if (irc_mode_nick_prefix_allowed (server, '~'))
irc_mode_channel_set_nick (channel, ptr_arg,
irc_mode_channel_set_nick (server, channel, ptr_arg,
set_flag, IRC_NICK_CHANOWNER);
current_arg++;
break;
@@ -188,7 +189,7 @@ irc_mode_channel_set (struct t_irc_server *server,
ptr_arg = ((current_arg >= 0) && (current_arg < argc)) ?
argv[current_arg] : NULL;
if (irc_mode_nick_prefix_allowed (server, '-'))
irc_mode_channel_set_nick (channel, ptr_arg,
irc_mode_channel_set_nick (server, channel, ptr_arg,
set_flag, IRC_NICK_CHANUSER);
current_arg++;
break;
@@ -196,7 +197,7 @@ irc_mode_channel_set (struct t_irc_server *server,
ptr_arg = ((current_arg >= 0) && (current_arg < argc)) ?
argv[current_arg] : NULL;
if (irc_mode_nick_prefix_allowed (server, '+'))
irc_mode_channel_set_nick (channel, ptr_arg,
irc_mode_channel_set_nick (server, channel, ptr_arg,
set_flag, IRC_NICK_VOICE);
current_arg++;
break;
+7 -4
View File
@@ -336,7 +336,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
*/
void
irc_nick_set (struct t_irc_channel *channel,
irc_nick_set (struct t_irc_server *server, struct t_irc_channel *channel,
struct t_irc_nick *nick, int set, int flag)
{
char prefix[2], str_prefix_color[64];
@@ -367,6 +367,9 @@ irc_nick_set (struct t_irc_channel *channel,
(nick->flags & IRC_NICK_AWAY) ?
"weechat.color.nicklist_away" : "bar_fg",
prefix, str_prefix_color, 1);
if (strcmp (nick->name, server->nick) == 0)
weechat_bar_item_update ("input_prompt");
}
/*
@@ -507,8 +510,8 @@ irc_nick_count (struct t_irc_channel *channel, int *total, int *count_op,
*/
void
irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick,
int is_away)
irc_nick_set_away (struct t_irc_server *server, struct t_irc_channel *channel,
struct t_irc_nick *nick, int is_away)
{
if ((weechat_config_integer (irc_config_network_away_check) > 0)
&& ((weechat_config_integer (irc_config_network_away_check_max_nicks) == 0) ||
@@ -517,7 +520,7 @@ irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick,
if (((is_away) && (!(nick->flags & IRC_NICK_AWAY))) ||
((!is_away) && (nick->flags & IRC_NICK_AWAY)))
{
irc_nick_set (channel, nick, is_away, IRC_NICK_AWAY);
irc_nick_set (server, channel, nick, is_away, IRC_NICK_AWAY);
}
}
}
+8 -2
View File
@@ -62,6 +62,10 @@ struct t_irc_nick
extern int irc_nick_valid (struct t_irc_channel *channel,
struct t_irc_nick *nick);
extern const char *irc_nick_find_color (const char *nickname);
extern void irc_nick_get_gui_infos (struct t_irc_nick *nick,
char *prefix, int *prefix_color,
struct t_gui_buffer *buffer,
struct t_gui_nick_group **group);
extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
struct t_irc_channel *channel,
const char *nickname,
@@ -76,7 +80,8 @@ extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
extern void irc_nick_change (struct t_irc_server *server,
struct t_irc_channel *channel,
struct t_irc_nick *nick, const char *new_nick);
extern void irc_nick_set (struct t_irc_channel *channel,
extern void irc_nick_set (struct t_irc_server *server,
struct t_irc_channel *channel,
struct t_irc_nick *nick, int set, int flag);
extern void irc_nick_free (struct t_irc_channel *channel,
struct t_irc_nick *nick);
@@ -86,7 +91,8 @@ extern struct t_irc_nick *irc_nick_search (struct t_irc_channel *channel,
extern void irc_nick_count (struct t_irc_channel *channel, int *total,
int *count_op, int *count_halfop, int *count_voice,
int *count_normal);
extern void irc_nick_set_away (struct t_irc_channel *channel,
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_nick *nick, const char *nickname,
const char *force_color);
+1 -1
View File
@@ -2922,7 +2922,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, const char *command,
if (ptr_nick->host)
snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]);
if (pos_attr)
irc_nick_set_away (ptr_channel, ptr_nick,
irc_nick_set_away (server, ptr_channel, ptr_nick,
(pos_attr[0] == 'G') ? 1 : 0);
}
}
+2 -2
View File
@@ -2969,7 +2969,7 @@ irc_server_remove_away ()
for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
irc_channel_remove_away (ptr_channel);
irc_channel_remove_away (ptr_server, ptr_channel);
}
}
}
@@ -3013,7 +3013,7 @@ irc_server_set_away (struct t_irc_server *server, const char *nick, int is_away)
{
/* set away flag for nick on channel */
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
irc_channel_set_away (ptr_channel, nick, is_away);
irc_channel_set_away (server, ptr_channel, nick, is_away);
/* set/del "away" local variable */
if (is_away)