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

Configurable key bindings #28

Open
massimiliano-mantione opened this issue Apr 28, 2022 · 2 comments
Open

Configurable key bindings #28

massimiliano-mantione opened this issue Apr 28, 2022 · 2 comments

Comments

@massimiliano-mantione
Copy link

First of all, thanks for your work on zee!

I am exploring, looking for a "simple" editor to use in the terminal when I am not using my regular "IDE" editor, and zee, among the ones I tried, is the one that is actually able to work on huge files without becoming unresponsive :-)
(I want a "simple" editor but I want to be able to use it without fear on any file I stumble upon)
So, thanks for that!

That said, while I understand your focus on "emacs-compatible experience", I am unwilling to abandon the keybindings I am used to, or to be forced to use different keybindings with different editors.

I had a look at the source code and I see no way to load keybindings from a file.
I see there is a toml file that is looked up at startup but AFAICS it only provides an index into a theme.

About keybindings, AFAICS they are hardcoded in the various Component::bindings implementations.

Assuming that I did not make gross mistakes reading the code, would you accept a PR that:

  • implements a way to deserialize KeyPattern instances from strings
  • using that, implements a way to load "keybinding mappings" from the config file, falling back to the hardcoded defaults
  • passes this "mapping table" to the various Component::bindings implementations so that bindings will not be hard-coded anymore (they would be created from the loaded mapping table)

The "keybinding mappings table" would be a dictionary with commands ('static &str) as keys, where each command is one of "left", "start-of-line"...
For each command, there would be a Message, and a SmallVec of KeyPattern (the key patterns that would trigger the command).
This would make it possible to implement all the Component::bindings functions taking the mappings they need from the table instead of using hardcoded values like they do now.

I imagine that the performance impact of creating the bindings this way would be negligible.

Does this make sense?
If it does, and if you would accept this feature, I might write the PR in the next weeks (slowly, as I have a full-time job and a family).

@mcobzarenco
Copy link
Collaborator

Thank you for trying zee and for the detailed issue description, very helpful and nice to see this is already useful for someone 🙂 Editing very large files with breeze is certainly a main goal of zee and one of the reasons I started it.

Configurable key bindings, not to mention extensibility more generally, are very important and at the top of the roadmap. I added the Component::bindings abstraction recently to address a few things, one of which is configurable key bindings. Defining the bindings in code is just a stop gap solution.

@dumblob
Copy link

dumblob commented Jul 18, 2022

@massimiliano-mantione while at it, would you also consider modal key bindings support?

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

No branches or pull requests

3 participants