mirror of
https://github.com/weechat/weechat.git
synced 2026-06-24 20:06:38 +02:00
fset: hook command /key
When command /key is called without arguments, and if fset plugin is loaded, fset displays all key options (filter: `weechat.key*`).
This commit is contained in:
@@ -8356,7 +8356,7 @@ command_init ()
|
||||
hook_command (
|
||||
NULL, "key",
|
||||
N_("bind/unbind keys"),
|
||||
N_("list|listdefault|listdiff [<context>]"
|
||||
N_("[list|listdefault|listdiff] [<context>]"
|
||||
" || bind <key> [<command> [<args>]]"
|
||||
" || bindctxt <context> <key> [<command> [<args>]]"
|
||||
" || unbind <key>"
|
||||
|
||||
@@ -454,7 +454,6 @@ fset_command_run_set_cb (const void *pointer, void *data,
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
/* ignore /set command if issued on fset buffer */
|
||||
if (fset_buffer && (buffer == fset_buffer))
|
||||
@@ -575,6 +574,44 @@ end:
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hooks execution of command "/key".
|
||||
*/
|
||||
|
||||
int
|
||||
fset_command_run_key_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer, const char *command)
|
||||
{
|
||||
const char *ptr_args;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
if (strncmp (command, "/key", 4) != 0)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
ptr_args = strchr (command, ' ');
|
||||
while (ptr_args && (ptr_args[0] == ' '))
|
||||
{
|
||||
ptr_args++;
|
||||
}
|
||||
|
||||
if (!ptr_args || !ptr_args[0])
|
||||
{
|
||||
fset_option_filter_options ("weechat.key*");
|
||||
if (!fset_buffer)
|
||||
fset_buffer_open ();
|
||||
fset_buffer_set_localvar_filter ();
|
||||
fset_buffer_refresh (1);
|
||||
weechat_buffer_set (fset_buffer, "display", "1");
|
||||
return WEECHAT_RC_OK_EAT;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hooks fset commands.
|
||||
*/
|
||||
@@ -807,4 +844,5 @@ fset_command_init ()
|
||||
" || *|c:|f:|s:|d|d:|d=|d==|=|==|%(fset_options)",
|
||||
&fset_command_fset, NULL, NULL);
|
||||
weechat_hook_command_run ("/set", &fset_command_run_set_cb, NULL, NULL);
|
||||
weechat_hook_command_run ("/key", &fset_command_run_key_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user