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

Allow adding custom keybindings #31

Open
xoich opened this issue Dec 17, 2022 · 3 comments
Open

Allow adding custom keybindings #31

xoich opened this issue Dec 17, 2022 · 3 comments

Comments

@xoich
Copy link

xoich commented Dec 17, 2022

Hello, it seems this is not possible at the moment, but that it could be allowed by enabling the injection of custom procs to the Noise.procs list. Let me know what you think, thank you.

@jangko
Copy link
Owner

jangko commented Dec 18, 2022

well, the current design is using keycode map directly to action code.
what we need is adding enum of actions e.g. {...MOVE_LEFT, CUT, COPY, PASTE, MOVE_RIGHT...}.
and then map key code to this finite set of actions.
but the real challenge is designing new format of the keycode that can be easily and efficiently mapped to actions.
worst case we might also need runtime table, but I think it is possible to use simple array if we can arrange it in clever way.

@xoich
Copy link
Author

xoich commented Dec 18, 2022

customizing the existing keybindings might be needed too, but I was not thinking about that, but about adding new ones:

For example a library user might want to:

  • Add a keybinding to edit the current line in a text editor.
  • If the line represents a LaTeX math formula, one might want a keybinding that previews it by popping up the rendering in a new window.

@jangko
Copy link
Owner

jangko commented Dec 19, 2022

the mechanism to add additional keybinding is already there. you only need to add a public api to make it available to users.

additional keybindings can be put into this EditProc chain.

procs: seq[EditProc]

but because nim-noise was designed with simplicity in mind at that time, you need to consider how to handle user data. user data typically can be handled using nim closure, object inheritance, or explicit user data when registering the additional keybinding proc.

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

2 participants