diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-02 13:56:35 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-02 13:56:35 +0100 |
commit | 5aa82a85e3e0e972ed14455cf6cabf3efd259ada (patch) | |
tree | be884f0322f0971496622a976d81593b0f5313e3 /src | |
parent | 94ddf61d2000e5824f12f4e892be6a6d2dbf1c25 (diff) | |
download | weechat-5aa82a85e3e0e972ed14455cf6cabf3efd259ada.zip |
Add option irc.look.display_channel_modes_hide_key to hide channel key in channel modes (bug #23961)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-bar-item.c | 22 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 27 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 1 |
3 files changed, 47 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index 6f84e3ea6..495c80701 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -172,8 +172,8 @@ char * irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { - char buf[512], buf_name[256], modes[128]; - const char *name; + char buf[512], buf_name[256], modes[128], *modes_without_args; + const char *name, *pos_space, *pos_key; int part_from_channel, display_server; struct t_gui_buffer *buffer; struct t_irc_server *server; @@ -230,12 +230,28 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, && 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)) + { + 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); + } + } + } snprintf (modes, sizeof (modes), "%s(%s%s%s)", IRC_COLOR_BAR_DELIM, IRC_COLOR_ITEM_CHANNEL_MODES, - channel->modes, + (modes_without_args) ? modes_without_args : channel->modes, IRC_COLOR_BAR_DELIM); + if (modes_without_args) + free (modes_without_args); } } } diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index e6de7672c..50dcc552b 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -56,6 +56,7 @@ 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; @@ -232,6 +233,24 @@ irc_config_change_look_display_channel_modes (void *data, } /* + * 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 */ @@ -1365,6 +1384,14 @@ irc_config_init () 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", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index b4a45ef5d..96603a3c5 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -78,6 +78,7 @@ 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; |