summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-completion.c
diff options
context:
space:
mode:
authorSimmo Saan <simmo.saan@gmail.com>2018-03-24 17:01:50 +0100
committerSébastien Helleu <flashcode@flashtux.org>2018-03-24 17:01:50 +0100
commitd77e1ea49950f1f537194368cc4d003bb8667d41 (patch)
tree62c4cddaa9af9f59417e3d262b05b10e012d13f8 /src/plugins/irc/irc-completion.c
parentb2f971d4b046ae49b01f926f5617a0542c21d5d3 (diff)
downloadweechat-d77e1ea49950f1f537194368cc4d003bb8667d41.zip
irc: add indexed ban list, add completion for /unban and /unquiet (closes #597, task #11374, task #10876)
Diffstat (limited to 'src/plugins/irc/irc-completion.c')
-rw-r--r--src/plugins/irc/irc-completion.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index b9d53633e..e3b2f834d 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -31,6 +31,7 @@
#include "irc-completion.h"
#include "irc-config.h"
#include "irc-ignore.h"
+#include "irc-modelist.h"
#include "irc-nick.h"
#include "irc-notify.h"
#include "irc-server.h"
@@ -421,6 +422,47 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data,
}
/*
+ * Adds modelist masks current channel to completion list.
+ */
+
+int
+irc_completion_modelist_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ char *pos;
+ struct t_irc_modelist *ptr_modelist;
+ struct t_irc_modelist_item *ptr_item;
+
+ IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+
+ pos = strchr (completion_item, ':');
+ if (pos)
+ pos++;
+
+ if (pos && pos[0] && ptr_channel)
+ {
+ ptr_modelist = irc_modelist_search (ptr_channel, pos[0]);
+ if (ptr_modelist)
+ {
+ for (ptr_item = ptr_modelist->items; ptr_item; ptr_item = ptr_item->next_item)
+ {
+ weechat_hook_completion_list_add (completion,
+ ptr_item->mask,
+ 0, WEECHAT_LIST_POS_END);
+ }
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Adds topic of current channel to completion list.
*/
@@ -758,6 +800,10 @@ irc_completion_init ()
weechat_hook_completion ("irc_channel_nicks_hosts",
N_("nicks and hostnames of current IRC channel"),
&irc_completion_channel_nicks_hosts_cb, NULL, NULL);
+ weechat_hook_completion ("irc_modelist",
+ N_("modelist masks of current IRC channel; "
+ "required argument: modelist mode"),
+ &irc_completion_modelist_cb, NULL, NULL);
weechat_hook_completion ("irc_channel_topic",
N_("topic of current IRC channel"),
&irc_completion_channel_topic_cb, NULL, NULL);