feat: add initial support for multi-stroke chord keybindings in emacs mode #989
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds basic support for adding multi-stroke (chord) keybindings, e.g.:
Changes to public API:
(Breaking change) Remove the existing
pubfield ofKeybindingsso we can unify the implementation between single-keystroke bindings and multi-keystroke bindings.I did some searching on GitHub and couldn't immediately find specific cases that would be broken by this -- but of course, that doesn't prove it won't break a client. (Most of the search hits that came up seemed to be vendored/forked copies of
reedlineornushell, or similar field names in different types.)Adds
Keybindings::add_sequence_binding()andKeybindings::remove_sequence_binding()to bind (or unbind) a sequence of 1 or moreKeyCombinations to aReedlineEvent; this supports both single-keystroke bindings and multi-keystroke chord-style bindings.Retains
Keybinding::add_binding()andKeybinding::remove_binding()for backwards compatibility, replacing their bodies with simple wrapping calls to the new sequence-enlightened calls.General approach:
emacsmode first; do not worry about aligning with existing multi-keystroke processing already present in vi mode for handling commands.I'm looking for feedback on the general approach as well as the implementation before getting any deeper into this. For reference, I've demonstrated how this support could be used in
nushellvia this commit in mynushellfork. There's also a new example included in this draft PR to demonstrate and test.(Aside: This is my first feature-level contribution. I'm eager to get as much feedback as I can!)