From 9eda570311ffd292d333f7687074403ff46cc838 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Mon, 23 Jan 2023 21:56:39 +0100 Subject: Implement some more commands - More bug fixes for keys: You can now have mod-less keys in keymaps as binds. - Fix calculation bug with space fillouts. --- src/binding.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/binding.h') diff --git a/src/binding.h b/src/binding.h index bfde9fc..18a7278 100644 --- a/src/binding.h +++ b/src/binding.h @@ -7,20 +7,34 @@ struct keymap { uint32_t capacity; }; -enum binding_type { BindingType_Command, BindingType_Keymap }; +enum binding_type { + BindingType_Command, + BindingType_Keymap, + BindingType_DirectCommand +}; -#define BINDING(mod_, c_, command_) \ +#define BINDING_INNER(mod_, c_, command_) \ (struct binding) { \ .key = {.mod = mod_, .key = c_}, .type = BindingType_Command, \ .command = hash_command_name(command_) \ } -#define PREFIX(mod_, c_, keymap_) \ +#define ANONYMOUS_BINDING_INNER(mod_, c_, command_) \ + (struct binding) { \ + .key = {.mod = mod_, .key = c_}, .type = BindingType_DirectCommand, \ + .direct_command = command_ \ + } + +#define PREFIX_INNER(mod_, c_, keymap_) \ (struct binding) { \ .key = {.mod = mod_, .key = c_}, .type = BindingType_Keymap, \ .keymap = keymap_ \ } +#define BINDING(...) BINDING_INNER(__VA_ARGS__) +#define PREFIX(...) PREFIX_INNER(__VA_ARGS__) +#define ANONYMOUS_BINDING(...) ANONYMOUS_BINDING_INNER(__VA_ARGS__) + struct binding { struct key key; @@ -28,6 +42,7 @@ struct binding { union { uint32_t command; + struct command *direct_command; struct keymap *keymap; }; }; -- cgit v1.2.3