PrettyPrompt icon indicating copy to clipboard operation
PrettyPrompt copied to clipboard

Custom keybindings for caret movement

Open PaddiM8 opened this issue 2 years ago • 3 comments

I haven't found a way to change the keybinds for caret movement and other things like that, and it would be nice to be able to be able to change them to emacs-style. I know there is a GetKeyPressCallbacks function, but it doesn't seem to allow you to set the caret position.

PaddiM8 avatar Apr 13 '22 13:04 PaddiM8

Keybindings for caret movement are not currently configurable. See: KeyBindings.cs

Should it be used also for text selection (same as e.g. Shift+RightArrow)?

kindermannhubert avatar Apr 13 '22 13:04 kindermannhubert

Hm well I guess it would probably be good to be able to customise as many keybinds as possible.

On my local copy of the code, I did some experimentation and made KeyPressCallbackAsync take a class that communicates with Document under the hood, in order to then be able to set the caret position and some other things from a key press callback. I also made user-assigned key binds set key.Handled to true while also evaluating before the hard-coded ones, to allow for users to overwrite the hard-coded key binds. I'm not familiar enough with the code to know the best way to do this myself though.

PaddiM8 avatar Apr 13 '22 14:04 PaddiM8

The correct way to do this is to extend KeyBindings.cs and use the new keyBinding at all places where Arrow keys are now explicitly used in PrettyPrompt code. At each place, one has to decide whether to use the new 'moveKeyBindings' or not instead of Arrow keys.

kindermannhubert avatar Apr 14 '22 17:04 kindermannhubert