summaryrefslogtreecommitdiff
path: root/src/binding.h
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2023-01-23 21:56:39 +0100
committerAlbert Cervin <albert@acervin.com>2023-01-23 21:56:39 +0100
commit9eda570311ffd292d333f7687074403ff46cc838 (patch)
tree40265e3d2c23831afaf352bb64b8d6634bae9730 /src/binding.h
parent385c9d62a5507d901ff7e54d7a4c0342cf3aff43 (diff)
downloaddged-9eda570311ffd292d333f7687074403ff46cc838.tar.gz
dged-9eda570311ffd292d333f7687074403ff46cc838.tar.xz
dged-9eda570311ffd292d333f7687074403ff46cc838.zip
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.
Diffstat (limited to 'src/binding.h')
-rw-r--r--src/binding.h21
1 files changed, 18 insertions, 3 deletions
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;
};
};