diff options
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | config.c | 2 | ||||
-rw-r--r-- | main.c | 18 | ||||
-rw-r--r-- | ted.c | 13 | ||||
-rw-r--r-- | ted.cfg | 3 | ||||
-rw-r--r-- | ted.h | 4 |
6 files changed, 36 insertions, 13 deletions
@@ -71,9 +71,13 @@ Comments begin with `#`, and all other lines are of the form `key = value`. By default ted's settings will automatically update when you save the config file. The `core` section's settings should be pretty familiar (font size, etc.) or should have comments on the previous line -explaining what they do. Keyboard shortcuts are of the form `key combo = action`, where `action` is an argument (number or string), +explaining what they do. + +Keyboard shortcuts are of the form `key combo = action`, where `action` is an argument (number or string), followed by a command. The commands match the things in the command palette (Ctrl+Shift+p), but `:` is added to the beginning to make -it clear it's a command. Colors are formatted like `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, where r, g, b, and a are red, green, +it clear it's a command. + +Colors are formatted like `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, where r, g, b, and a are red, green, blue, and alpha (transparency/opacity). You can use a [color picker](https://www.google.com/search?q=color+picker) to help you out. The extensions section is fairly self-explanatory. @@ -156,6 +160,7 @@ Then, open windows\_installer\\ted\\ted.sln, and build. <tr><td>1.0r3</td> <td>Better TeX syntax highlighting, move to cursor on backspace/delete</td> <td>2022 Jul 7</td></tr> <tr><td>1.1</td> <td>Minor fixes, syntax highlighting for JavaScript, Java, and Go</td> <td>2022 Jul 22</td></tr> <tr><td>1.2</td> <td>Bug fixes, per-language settings</td> <td>2022 Jul 29</td></tr> +<tr><td>1.2r1</td> <td>Mouse X1/X2 bug fix, support for X1/X2 commands.</td> <td>2022 Aug 19</td></tr> </table> ## License @@ -107,6 +107,8 @@ static u32 config_parse_key_combo(ConfigReader *cfg, char const *str) { {"Question Mark", "?", SDL_SCANCODE_SLASH, 1}, {"Question", 0, SDL_SCANCODE_SLASH, 1}, {"Tilde", "~", SDL_SCANCODE_GRAVE, 1}, + {"X1", "x1", SCANCODE_MOUSE_X1, 0}, + {"X2", "x2", SCANCODE_MOUSE_X2, 0} }; // @OPTIMIZE: sort key_names (and split keyname1/2); do a binary search @@ -597,6 +597,13 @@ int main(int argc, char **argv) { Uint32 button = event.button.button; u8 times = event.button.clicks; // number of clicks float x = (float)event.button.x, y = (float)event.button.y; + + if (button == SDL_BUTTON_X1) { + ted_press_key(ted, SCANCODE_MOUSE_X1, key_modifier); + } else if (button == SDL_BUTTON_X2) { + ted_press_key(ted, SCANCODE_MOUSE_X2, key_modifier); + } + if (button < arr_count(ted->nmouse_clicks) && ted->nmouse_clicks[button] < arr_count(ted->mouse_clicks[button])) { v2 pos = V2(x, y); @@ -667,16 +674,7 @@ int main(int argc, char **argv) { case SDL_KEYDOWN: { SDL_Scancode scancode = event.key.keysym.scancode; SDL_Keymod modifier = event.key.keysym.mod; - 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); - } - } + ted_press_key(ted, scancode, modifier); } break; case SDL_TEXTINPUT: { char *text = event.text.text; @@ -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); + } + } +} @@ -142,6 +142,9 @@ Alt+7 = 6 :tab-switch Alt+8 = 7 :tab-switch Alt+9 = 8 :tab-switch Alt+0 = 9 :tab-switch +# (for if you have those fancy extra buttons on your mouse) +X1 = :tab-prev +X2 = :tab-next Ctrl++ = 3 :increase-text-size Ctrl+- = 3 :decrease-text-size @@ -113,7 +113,9 @@ ENUM_U8 { #define SYNTAX_LINK SYNTAX_CONSTANT // for markdown -#define SCANCODE_COUNT 0x120 // SDL scancodes should be less than this value. +#define SCANCODE_MOUSE_X1 (SDL_NUM_SCANCODES) +#define SCANCODE_MOUSE_X2 (SDL_NUM_SCANCODES+1) +#define SCANCODE_COUNT (SDL_NUM_SCANCODES+2) // a "key combo" is some subset of {control, shift, alt} + some key. #define KEY_COMBO_COUNT (SCANCODE_COUNT << 3) #define KEY_MODIFIER_CTRL_BIT 0 |