summaryrefslogtreecommitdiff
path: root/src/plugins/fset
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-08-24 19:00:32 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-08-24 19:00:32 +0200
commit6737859330cc582649edfd07b3d6664220ce7a96 (patch)
tree9ebca172daf70e7c2b3eb7b68fab907e7e9196e3 /src/plugins/fset
parentfd07b2888f6f885da92b2faa44f62fe031c1d3e8 (diff)
downloadweechat-6737859330cc582649edfd07b3d6664220ce7a96.zip
fset: add local key bindings during the buffer creation
This allows the user to bind or unbind keys by setting options "weechat.buffer.fset.fset.key_bind_*" and "weechat.buffer.fset.fset.key_unbind_*".
Diffstat (limited to 'src/plugins/fset')
-rw-r--r--src/plugins/fset/fset-buffer.c17
-rw-r--r--src/plugins/fset/fset-buffer.h2
-rw-r--r--src/plugins/fset/fset-config.c2
3 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/fset/fset-buffer.c b/src/plugins/fset/fset-buffer.c
index 357ba576a..c7a69ae54 100644
--- a/src/plugins/fset/fset-buffer.c
+++ b/src/plugins/fset/fset-buffer.c
@@ -1497,10 +1497,13 @@ fset_buffer_set_callbacks ()
/*
* Sets keys on fset buffer.
+ *
+ * If hashtable is not NULL, it is used to set keys, otherwise keys are directly
+ * set in the fset buffer.
*/
void
-fset_buffer_set_keys ()
+fset_buffer_set_keys (struct t_hashtable *hashtable)
{
char *keys[][2] = {
{ "up", "/fset -up" },
@@ -1534,12 +1537,18 @@ fset_buffer_set_keys ()
if (weechat_config_boolean (fset_config_look_use_keys))
{
snprintf (str_key, sizeof (str_key), "key_bind_%s", keys[i][0]);
- weechat_buffer_set (fset_buffer, str_key, keys[i][1]);
+ if (hashtable)
+ weechat_hashtable_set (hashtable, str_key, keys[i][1]);
+ else
+ weechat_buffer_set (fset_buffer, str_key, keys[i][1]);
}
else
{
snprintf (str_key, sizeof (str_key), "key_unbind_%s", keys[i][0]);
- weechat_buffer_set (fset_buffer, str_key, "");
+ if (hashtable)
+ weechat_hashtable_set (hashtable, str_key, "");
+ else
+ weechat_buffer_set (fset_buffer, str_key, "");
}
}
}
@@ -1580,6 +1589,7 @@ fset_buffer_open ()
{
weechat_hashtable_set (buffer_props, "type", "free");
weechat_hashtable_set (buffer_props, "localvar_set_type", "option");
+ fset_buffer_set_keys (buffer_props);
}
fset_buffer = weechat_buffer_new_props (
@@ -1594,7 +1604,6 @@ fset_buffer_open ()
if (!fset_buffer)
return;
- fset_buffer_set_keys ();
fset_buffer_set_localvar_filter ();
fset_buffer_selected_line = 0;
diff --git a/src/plugins/fset/fset-buffer.h b/src/plugins/fset/fset-buffer.h
index bf0b2c2bc..90a3e0066 100644
--- a/src/plugins/fset/fset-buffer.h
+++ b/src/plugins/fset/fset-buffer.h
@@ -37,7 +37,7 @@ extern int fset_buffer_window_scrolled_cb (const void *pointer,
const char *signal,
const char *type_data,
void *signal_data);
-extern void fset_buffer_set_keys ();
+extern void fset_buffer_set_keys (struct t_hashtable *hashtable);
extern void fset_buffer_set_localvar_filter ();
extern void fset_buffer_open ();
extern int fset_buffer_init ();
diff --git a/src/plugins/fset/fset-config.c b/src/plugins/fset/fset-config.c
index b166818db..886a403c9 100644
--- a/src/plugins/fset/fset-config.c
+++ b/src/plugins/fset/fset-config.c
@@ -256,7 +256,7 @@ fset_config_change_use_keys_cb (const void *pointer, void *data,
(void) option;
if (fset_buffer)
- fset_buffer_set_keys ();
+ fset_buffer_set_keys (NULL);
}
/*