-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add multi key overlay #9331
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
base: master
Are you sure you want to change the base?
Add multi key overlay #9331
Conversation
Similar to which-key in Emacs and other editors, this helps to navigate and discover multi-key mappings. Example (kitty.conf): map ctrl+h>a <action a> map ctrl+h>b <action b> multi_key_hint_delay 600 When you hit ctrl+h and hesitate for 600ms, hints overlay will appear showing what's available: a <action a> b <action b> Pressing a or b will activate the mapped action. Modifiers are supported as well, i.e. map ctrl+h>a <action a> map ctrl+h>ctrl+a <action b> map ctrl+h>shift+a <action c> Will display: a a <action a> 1 ctrl+a <action b> A shift+a <action c> 1 here is because hints overlay requires a key, but there is nothing exactly matching ctrl, so it's compromise. Nested mappings are supported as well: map ctrl+h>a>1 <action 1> map ctrl+h>a>2 <action 2> Will display two hints sequentialy.
E.g. ctrl+a>ctrl+a keeps opening overlays, because it is re-handled every time on the top level
| if text == m.Text { | ||
| continue | ||
| } | ||
| key, _, ok := strings.Cut(text, " - ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text parsing is quite ugly, to be fair. But not sure what to do - introducing structured input is not an option because of backwards compatibility. Maybe just add hotkey "tags" to every options line, e.g. : option one <ctrl+1>?
|
In principle this is fine, you can easily introduce a new mode to the hints kitten so that when it sees customize_processing is choose_entry it processes STDIN as JSON data or whatever. I haven't looked at the code yet, as I am swamped for the next few days, but a couple of points off the top of my head:
|
Cool, I'll see what I can do with JSON without breaking the world.
Yes. Once you press a, it'll pop up with b, then with c, then with d. You can see a bit of a flash, when the previous hints overlay is hidden and new displayed, but it does work. I guess with JSON I can just pass the whole tree of potential mappings, and keep it within the kitten, so no need to hide/show when moving between levels.
I'll add that.
Didn't know about this, will have a look! |
Just exploring the idea for now, wondering what you think?
Similar to
which-keyin Emacs and other editors, this helps to navigate and discover multi-key mappings. Basically when you press first part of the multi-key sequence, it'll show a hints overlay with available follow-ups. Requires quite a bit of hacking on theboss.pylevel, so not sure how you feel about it? Don't think it is possible to do via a kitten, it can't really handle keys that well as far as understand.Here is a little demo
kitty-multi-key-hint.mp4
PSA: not going to lie, I've used AI agents to draft the idea and navigate codebase. Obviously if you like the idea, happy to hand-polish the AI slop before merging.
Example (kitty.conf):
When you hit ctrl+h and hesitate for 600ms, hints overlay will appear showing what's available:
Pressing a or b will activate the mapped action.
Modifiers are supported as well, i.e.
Will display:
1 here is because hints overlay requires a key, but there is nothing exactly matching ctrl, so it's a compromise.
Nested mappings are supported as well:
Will display two hints sequentially.