summaryrefslogtreecommitdiff
path: root/ted.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-08-19 17:30:54 -0400
committerpommicket <pommicket@gmail.com>2022-08-19 17:30:54 -0400
commitb37150e7ae111808be79714eba52dad34b975689 (patch)
tree9501f5cbfaa1535e35bd71f1a7d4f72c0121dba6 /ted.c
parent81e1801ef0d61fe4e29db8b352b1fadff75503fb (diff)
X1/X2 commands
Diffstat (limited to 'ted.c')
-rw-r--r--ted.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ted.c b/ted.c
index 52ce7ed..eba5aad 100644
--- a/ted.c
+++ b/ted.c
@@ -392,3 +392,16 @@ void ted_load_configs(Ted *ted, bool reloading) {
ted_load_fonts(ted);
}
}
+
+void ted_press_key(Ted *ted, SDL_Scancode scancode, SDL_Keymod modifier) {
+ u32 key_combo = (u32)scancode << 3 |
+ (u32)((modifier & (KMOD_LCTRL|KMOD_RCTRL)) != 0) << KEY_MODIFIER_CTRL_BIT |
+ (u32)((modifier & (KMOD_LSHIFT|KMOD_RSHIFT)) != 0) << KEY_MODIFIER_SHIFT_BIT |
+ (u32)((modifier & (KMOD_LALT|KMOD_RALT)) != 0) << KEY_MODIFIER_ALT_BIT;
+ if (key_combo < KEY_COMBO_COUNT) {
+ KeyAction *action = &ted_active_settings(ted)->key_actions[key_combo];
+ if (action->command) {
+ command_execute(ted, action->command, action->argument);
+ }
+ }
+}