diff options
Diffstat (limited to 'src/plugins/irc/irc-completion.c')
-rw-r--r-- | src/plugins/irc/irc-completion.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index 1df549157..4848d54d2 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -212,6 +212,45 @@ irc_completion_server_nicks_cb (const void *pointer, void *data, } /* + * Adds prefix modes filters to completion list. + */ + +int +irc_completion_server_prefix_modes_filter_cb (const void *pointer, void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + const char *ptr_prefix_modes; + char str_filter[16]; + int i; + + IRC_BUFFER_GET_SERVER_CHANNEL(buffer); + + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) completion_item; + + ptr_prefix_modes = irc_server_get_prefix_modes (ptr_server); + if (!ptr_prefix_modes) + return WEECHAT_RC_OK; + + for (i = 0; ptr_prefix_modes[i]; i++) + { + snprintf (str_filter, sizeof (str_filter), "-%c", ptr_prefix_modes[i]); + weechat_completion_list_add (completion, str_filter, + 1, WEECHAT_LIST_POS_END); + } + + /* add filter on regular users at the end */ + weechat_completion_list_add (completion, "-*", + 1, WEECHAT_LIST_POS_END); + + return WEECHAT_RC_OK; +} + +/* * Adds servers to completion list. */ @@ -938,6 +977,10 @@ irc_completion_init () weechat_hook_completion ("irc_server_nicks", N_("nicks on all channels of current IRC server"), &irc_completion_server_nicks_cb, NULL, NULL); + weechat_hook_completion ("irc_server_prefix_modes_filter", + N_("arguments to filter by prefix mode " + "(for example: \"-o\", \"-h\", \"-v\", \"-*\")"), + &irc_completion_server_prefix_modes_filter_cb, NULL, NULL); weechat_hook_completion ("irc_servers", N_("IRC servers (internal names)"), &irc_completion_servers_cb, NULL, NULL); |