summaryrefslogtreecommitdiff
path: root/src/plugins/fset
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-03-02 21:08:51 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-03-16 20:42:19 +0100
commit79f7c1cf83e166b42bb803df3b237ddde0fcec8c (patch)
treecd7e58b4063a91d2b73a99746e103172151ec192 /src/plugins/fset
parentccc649d06cdf5a0f9f0b837df42ac50bddcc8ebd (diff)
downloadweechat-79f7c1cf83e166b42bb803df3b237ddde0fcec8c.zip
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*`).
Diffstat (limited to 'src/plugins/fset')
-rw-r--r--src/plugins/fset/fset-command.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/plugins/fset/fset-command.c b/src/plugins/fset/fset-command.c
index 5cfb1b514..7ab4f3a5d 100644
--- a/src/plugins/fset/fset-command.c
+++ b/src/plugins/fset/fset-command.c
@@ -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))
@@ -576,6 +575,44 @@ end:
}
/*
+ * 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);
}