1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 23:36:37 +02:00

irc: add option irc.look.item_channel_modes_hide_args (task #12070, task #12163, closes #48)

This option replaces the option irc.look.item_channel_modes_hide_key.
It is now a string, so channel modes arguments can be hidden using many
channel modes (or all, with "*").
This commit is contained in:
Sébastien Helleu
2014-04-04 12:32:59 +02:00
parent 79533566c6
commit de4ce8eeb6
23 changed files with 214 additions and 97 deletions
+4 -8
View File
@@ -260,7 +260,7 @@ irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item,
struct t_hashtable *extra_info)
{
char modes[128], *modes_without_args;
const char *pos_space, *pos_key;
const char *pos_space;
int part_from_channel;
struct t_irc_server *server;
struct t_irc_channel *channel;
@@ -287,17 +287,13 @@ irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item,
&& (strcmp (channel->modes, "+") != 0))
{
modes_without_args = NULL;
if (weechat_config_boolean (irc_config_look_item_channel_modes_hide_key))
if (!irc_config_display_channel_modes_arguments (channel->modes))
{
pos_space = strchr(channel->modes, ' ');
if (pos_space)
{
pos_key = strchr(channel->modes, 'k');
if (pos_key && (pos_key < pos_space))
{
modes_without_args = weechat_strndup (channel->modes,
pos_space - channel->modes);
}
modes_without_args = weechat_strndup (channel->modes,
pos_space - channel->modes);
}
}
snprintf (modes, sizeof (modes),
+51 -10
View File
@@ -71,7 +71,7 @@ struct t_config_option *irc_config_look_highlight_channel;
struct t_config_option *irc_config_look_highlight_pv;
struct t_config_option *irc_config_look_highlight_tags_restrict;
struct t_config_option *irc_config_look_item_away_message;
struct t_config_option *irc_config_look_item_channel_modes_hide_key;
struct t_config_option *irc_config_look_item_channel_modes_hide_args;
struct t_config_option *irc_config_look_item_display_server;
struct t_config_option *irc_config_look_item_nick_modes;
struct t_config_option *irc_config_look_item_nick_prefix;
@@ -246,6 +246,45 @@ irc_config_set_nick_colors ()
&irc_config_num_nick_colors);
}
/*
* Checks if channel modes arguments must be displayed or hidden
* (according to option irc.look.item_channel_modes_hide_args).
*
* Returns:
* 1: channel modes arguments must be displayed
* 0: channel modes arguments must be hidden
*/
int
irc_config_display_channel_modes_arguments (const char *modes)
{
char *pos_space, *pos;
const char *ptr_mode;
pos_space = strchr (modes, ' ');
if (!pos_space)
return 1;
ptr_mode = weechat_config_string (irc_config_look_item_channel_modes_hide_args);
if (!ptr_mode)
return 1;
/* "*" means hide all arguments */
if (strcmp (ptr_mode, "*") == 0)
return 0;
while (ptr_mode[0])
{
pos = strchr (modes, ptr_mode[0]);
if (pos && (pos < pos_space))
return 0;
ptr_mode++;
}
/* arguments are displayed by default */
return 1;
}
/*
* Callback for changes on option "weechat.color.chat_nick_colors".
*/
@@ -445,12 +484,12 @@ irc_config_change_look_item_away_message (void *data,
}
/*
* Callback for changes on option "irc.look.item_channel_modes_hide_key".
* Callback for changes on option "irc.look.item_channel_modes_hide_args".
*/
void
irc_config_change_look_item_channel_modes_hide_key (void *data,
struct t_config_option *option)
irc_config_change_look_item_channel_modes_hide_args (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
@@ -2357,13 +2396,15 @@ irc_config_init ()
N_("display server away message in away bar item"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&irc_config_change_look_item_away_message, NULL, NULL, NULL);
irc_config_look_item_channel_modes_hide_key = weechat_config_new_option (
irc_config_look_item_channel_modes_hide_args = weechat_config_new_option (
irc_config_file, ptr_section,
"item_channel_modes_hide_key", "boolean",
N_("hide channel key in channel modes (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);
"item_channel_modes_hide_args", "string",
N_("hide channel modes arguments if at least one of these modes is in "
"channel modes (\"*\" to always hide all arguments, empty value to "
"never hide arguments); example: \"kf\" to hide arguments if \"k\" "
"or \"f\" are in channel modes"),
NULL, 0, 0, "k", NULL, 0, NULL, NULL,
&irc_config_change_look_item_channel_modes_hide_args, NULL, NULL, NULL);
irc_config_look_item_display_server = weechat_config_new_option (
irc_config_file, ptr_section,
"item_display_server", "integer",
+2 -1
View File
@@ -119,7 +119,7 @@ extern struct t_config_option *irc_config_look_highlight_channel;
extern struct t_config_option *irc_config_look_highlight_pv;
extern struct t_config_option *irc_config_look_highlight_tags_restrict;
extern struct t_config_option *irc_config_look_item_away_message;
extern struct t_config_option *irc_config_look_item_channel_modes_hide_key;
extern struct t_config_option *irc_config_look_item_channel_modes_hide_args;
extern struct t_config_option *irc_config_look_item_display_server;
extern struct t_config_option *irc_config_look_item_nick_modes;
extern struct t_config_option *irc_config_look_item_nick_prefix;
@@ -196,6 +196,7 @@ extern char **irc_config_nicks_hide_password;
extern int irc_config_num_nicks_hide_password;
extern void irc_config_set_nick_colors ();
extern int irc_config_display_channel_modes_arguments (const char *modes);
extern int irc_config_server_check_value_cb (void *data,
struct t_config_option *option,
const char *value);