diff options
Diffstat (limited to 'key-bindings.c')
-rw-r--r-- | key-bindings.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/key-bindings.c b/key-bindings.c index 9e198123..f11bb430 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -232,6 +232,38 @@ key_bindings_remove(const char *name, key_code key) } void +key_bindings_reset(const char *name, key_code key) +{ + struct key_table *table; + struct key_binding *bd, *dd; + + table = key_bindings_get_table(name, 0); + if (table == NULL) + return; + + bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS); + if (bd == NULL) + return; + + dd = key_bindings_get_default(table, bd->key); + if (dd == NULL) { + key_bindings_remove(name, bd->key); + return; + } + + cmd_list_free(bd->cmdlist); + bd->cmdlist = dd->cmdlist; + bd->cmdlist->references++; + + free((void *)bd->note); + if (dd->note != NULL) + bd->note = xstrdup(dd->note); + else + bd->note = NULL; + bd->flags = dd->flags; +} + +void key_bindings_remove_table(const char *name) { struct key_table *table; @@ -248,6 +280,23 @@ key_bindings_remove_table(const char *name) } } +void +key_bindings_reset_table(const char *name) +{ + struct key_table *table; + struct key_binding *bd, *bd1; + + table = key_bindings_get_table(name, 0); + if (table == NULL) + return; + if (RB_EMPTY(&table->default_key_bindings)) { + key_bindings_remove_table(name); + return; + } + RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1) + key_bindings_reset(name, bd->key); +} + static enum cmd_retval key_bindings_init_done(__unused struct cmdq_item *item, __unused void *data) { |