diff options
| author | Albert Cervin <albert@acervin.com> | 2022-12-06 12:58:51 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2022-12-06 12:58:51 +0100 |
| commit | 66d50bd7b04922a91fbe3e4d49c68070ec1a7b14 (patch) | |
| tree | 87600e117f4262555bcc875b09e050536cbee492 /src/binding.c | |
| parent | 78410b18e5d4d117b714eb9f34c689920c32a985 (diff) | |
| download | dged-66d50bd7b04922a91fbe3e4d49c68070ec1a7b14.tar.gz dged-66d50bd7b04922a91fbe3e4d49c68070ec1a7b14.tar.xz dged-66d50bd7b04922a91fbe3e4d49c68070ec1a7b14.zip | |
Add minibuffer
Diffstat (limited to 'src/binding.c')
| -rw-r--r-- | src/binding.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/binding.c b/src/binding.c index 953c0d8..191bc0d 100644 --- a/src/binding.c +++ b/src/binding.c @@ -34,8 +34,8 @@ void keymap_destroy(struct keymap *keymap) { keymap->nbindings = 0; } -struct command *lookup_key(struct keymap *keymaps, uint32_t nkeymaps, - struct key *key, struct commands *commands) { +struct lookup_result lookup_key(struct keymap *keymaps, uint32_t nkeymaps, + struct key *key, struct commands *commands) { // lookup in order in the keymaps for (uint32_t kmi = 0; kmi < nkeymaps; ++kmi) { struct keymap *keymap = &keymaps[kmi]; @@ -44,14 +44,21 @@ struct command *lookup_key(struct keymap *keymaps, uint32_t nkeymaps, struct binding *binding = &keymap->bindings[bi]; if (key->c == binding->key.c && key->mod == binding->key.mod) { if (binding->type == BindingType_Command) { - return lookup_command_by_hash(commands, binding->command); + return (struct lookup_result){ + .found = true, + .type = BindingType_Command, + .command = lookup_command_by_hash(commands, binding->command), + }; } else if (binding->type == BindingType_Keymap) { - // TODO - return NULL; + return (struct lookup_result){ + .found = true, + .type = BindingType_Keymap, + .keymap = binding->keymap, + }; } } } } - return NULL; + return (struct lookup_result){.found = false}; } |
