Implement kitty's keyboard protocol - #7125
Conversation
changes retired by alacritty/alacritty#7125
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as off-topic.
This comment was marked as off-topic.
c39c3c9 to
89e5477
Compare
22b1af1 to
69c66ed
Compare
69c66ed to
d9f82e2
Compare
ada954a to
6ba6b01
Compare
6e25fc4 to
b8a634e
Compare
b7a8d63 to
a59e12d
Compare
| NamedKey::F1 => (one_based, SequenceTerminator::Normal('P')), | ||
| NamedKey::F2 => (one_based, SequenceTerminator::Normal('Q')), | ||
| NamedKey::F3 => { | ||
| // F3 in kitty protocol diverges from alacritty's terminfo. |
There was a problem hiding this comment.
Why is this? Is Kitty's default reply different without the protocol enabled?
There was a problem hiding this comment.
Kitty uses different values to us by default.
ef97f21 to
cdbdb1e
Compare
e219fa0 to
13f4e31
Compare
|
|
||
| impl SequenceBuildingContext { | ||
| /// Try building sequence from the event's emitting text. | ||
| fn try_from_textual(&self, key: &KeyEvent) -> Option<SequenceBase> { |
There was a problem hiding this comment.
I've just noticed this, but why do all these try_from impls not return Self?
There was a problem hiding this comment.
That's because we use Context to build common concepts, it's not really a builder. Alternatively we'd need to carry the value inside this builder, which is not good.
The design is simply to have common args passed across the functions. I had a version with Self but I wasn't sure about it, since it was less clear.
There was a problem hiding this comment.
It's just the name that doesn't make sense here, I'm not opposed to the mechanism.
A try_from method that takes self and doesn't return Self is just nonsense. Maybe just rename the struct to SequenceBuilder and make it try_build_textual etc?
There was a problem hiding this comment.
A try_from method that takes self and doesn't return Self is just nonsense. Maybe just rename the struct to SequenceBuilder and make it try_build_textual etc?
I guess, I applied the suggestion.
959aa36 to
8dd63da
Compare
The protocol enables robust key reporting for the applications, so they could bind more keys and the user won't have collisions with the normal control keys. Links: https://sw.kovidgoyal.net/kitty/keyboard-protocol Fixes alacritty#6378.
8dd63da to
8f4cc26
Compare
|
Thank you @kchibisov, I'm very excited to try this out! |
We've been using WezTerm for almost two years now (since 0c09547 (add wezterm, 2022-09-27)) as the main terminal program. The only drawbacks of using WezTerm are performance and increased memory usage. However neither of these drawbacks mean much in practice. Performance is more than fast enough and memory usage, though high, is stable. Interestingly, since we've switched away to WezTerm, Alacritty has merged support for the Kitty Keyboard Protocol (KKP) [1], which would presumably allow binding "C-," which was the original blocker for us [2]. If we go back to Alacritty we could also use the kkp.el Emacs package [3] so that we could use terminal Emacs with it. Sadly, this won't work for us because we always use tmux everywhere (terminal + tmux + Emacs), and tmux would itself need to understand KKP for it to seamlessly send those keyboard events over to Emacs from KKP-aware Alacritty. And tmux does not yet support KKP [4]. When tmux starts supporting KKP, we should be able to revisit this area and perhaps move back to Alacritty to pick up the performance/memory benefits and also retire our rather extensive CSI-u customizations across WezTerm [5], tmux [6] [7], and Emacs [8] in order to support "C-," and other exotic bindings inside terminal Emacs. We leave the machinery around switching terminal colors, such as script/terminal-themes/install_alacritty_colors.sh script/terminal-themes/renderAlacrittyColorYaml.dhall in place because when the time comes for switching back to Alacritty, those scripts might still be useful. [1] alacritty/alacritty#7125 [2] alacritty/alacritty#6354 [3] https://github.com/benjaminor/kkp [4] tmux/tmux#3335 [5] https://github.com/listx/syscfg/blame/07442d9f40569e55e34478e7214b5a13f46d8126/wezterm/README.org#L270 [6] https://github.com/listx/syscfg/blob/07442d9f40569e55e34478e7214b5a13f46d8126/tmux/.tmux.conf#L98 [7] tmux/tmux#2705 (comment) [8] https://github.com/listx/syscfg/blame/master/emacs/doom-cfg/README.org#L462
The protocol enables robust key reporting for the applications, so they could bind more keys and the user won't have collisions with the legacy control keys.
Fixes #6378.
Links: https://sw.kovidgoyal.net/kitty/keyboard-protocol
--
Only draft because of vte. I've also hasn't updated man pages, because the modes could be renamed. Besides everything should work...