mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 09:43:13 +02:00
irc: add count and mode filter in command /names (closes #98)
This commit is contained in:
@@ -211,6 +211,45 @@ irc_completion_server_nicks_cb (const void *pointer, void *data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
Reference in New Issue
Block a user