Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom keybindings for caret movement #198

Open
PaddiM8 opened this issue Apr 13, 2022 · 3 comments
Open

Custom keybindings for caret movement #198

PaddiM8 opened this issue Apr 13, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@PaddiM8
Copy link

PaddiM8 commented Apr 13, 2022

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.

@kindermannhubert
Copy link
Collaborator

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 kindermannhubert added the enhancement New feature or request label Apr 13, 2022
@PaddiM8
Copy link
Author

PaddiM8 commented Apr 13, 2022

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.

@kindermannhubert
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants