ulyssa / modalkit

A Rust library for building modal editing applications
Apache License 2.0
49 stars 5 forks source link

Add duplicate bindings for terminals that support enhanced keys #139

Closed ulyssa closed 2 months ago

ulyssa commented 2 months ago

I enabled the Kitty keyboard enhancements in ulyssa/iamb#272, but this broke using some keybindings like <C-I> and <C-[> since they no longer get sent as <Tab> and <Esc> respectively. These (and similar) should have duplicate entries in the Vim and Emacs keybindings so that enabling improved keypresses doesn't break using them. The key parsing code should also stop pretending that these are always the same keys, since people could reasonable want to set up custom mappings for one but not the other when using a terminal that supports sending the CSI u sequences.

There is a little bit of trickiness here: the crossterm representation for some keypresses like Alt+Shift+J sometimes uses j (Kitty keyboard enhancement protocol) and sometimes uses J (non-enhanced). I've tried to help avoid running into issues with this difference by normalizing keys and modifiers in TerminalKey::new.