diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-24 19:00:32 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-24 19:00:32 +0200 |
commit | 6737859330cc582649edfd07b3d6664220ce7a96 (patch) | |
tree | 9ebca172daf70e7c2b3eb7b68fab907e7e9196e3 | |
parent | fd07b2888f6f885da92b2faa44f62fe031c1d3e8 (diff) | |
download | weechat-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_*".
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | src/plugins/fset/fset-buffer.c | 17 | ||||
-rw-r--r-- | src/plugins/fset/fset-buffer.h | 2 | ||||
-rw-r--r-- | src/plugins/fset/fset-config.c | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 2fe4e08ce..6725ec3da 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -40,6 +40,7 @@ Bug fixes:: * core: fix cursor position after `/plugin list -i` or `/plugin list -il` * core: display focus hashtable for debug even if no key is matching + * fset: add local key bindings during the buffer creation * fset: remove extra spaces between min and max values when second format is used * fset: fix mouse actions when second format is used * fset: apply option fset.color.help_description (issue #1988) 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); } /* |