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

feat(keybindings): support multiple modifiers (eg. Ctrl+Alt) and the kitty keyboard protocol #3383

Merged
merged 15 commits into from
May 27, 2024

Conversation

imsnif
Copy link
Member

@imsnif imsnif commented May 27, 2024

This PR represents the first stage in solving the "colliding keys" problem faced by many users - meaning that the default Zellij keys collide with many of their favorite applications running inside Zellij, forcing them to configure the keys or to constantly lock and unlock the Zellij UI.

This PR helps solve this issue by drastically expanding the range of bindable keys, adding multiple modifiers as well as previously unsupported modifiers such as Super. Before the next release, additional changes will be made - building on top of this - to provide defaults (for any terminal and OS, whether supporting this protocol or not) that will make this problem go away.

The main user facing changes here are:

  1. It is now possible to bind keys with multiple modifiers (eg. Ctrl Alt a)
  2. It is now possible to bind the Super key in supported terminals
  3. Virtually all keys and key combinations are now bindable (eg. Ctrl Alt Home, Alt Shift Super Insert, whatever you can imagine)
  4. On macOS (in terminals supporting the kitty keyboard protocol), Opt should work as Alt out of the box

Implementation details:

  1. The internal Key data structure was swapped for KeyWithModifier to better represent keys with multiple modifiers (this also affets the Rust SDK, see below)
  2. Support was added for the base level of the kitty keyboard protocol (https://sw.kovidgoyal.net/kitty/keyboard-protocol) without further progressive enhancements
  3. On startup, Zellij requests that its host terminal send it keys using the above protocol - but since the protocol is backwards compatible, it is still able to parse keys normally whether the terminal supports the protocol or not.
  4. Terminal apps requesting the kitty keyboard protocol will have their request respected (i.e. keys will be sent to them encoded with kitty's CSI U notation) whether the user's host terminal supports this protocol or not.

Breaking Change for (Rust) plugin developers:

While as always plugins compiled for the previous versions of Zellij should still work, plugins wishing to use the new Rust SDK will encounter the following change:

The Key structure was swapped for KeyWithModifier to account for keys possibly having multiple modifiers (and new modifiers, eg. Super). Supporting methods were added to figure out which modifiers a key has so that plugins can more easily match against them.

This should not affect other plugin SDKs, seeing as the contract (the protobuf key representation) only had modifiers added to it and was not changed in any way. Depending on their implementation, other SDK authors might need to update their data structures to match this change.

Configuration

Support for the kitty keyboard protocol can be explicitly disabled through configuration by setting support_kitty_keyboard_protocol false in the config file or when launching Zellij through the CLI. If disabled, Zellij will not request this encoding on startup, will not request it to be removed on shut down and will not encode it to terminal apps running inside its panes when they request it. It will however reply to support queries from such apps, letting them know there is no support.

@imsnif imsnif merged commit 62c37a8 into main May 27, 2024
6 checks passed
jmartindf pushed a commit to jmartindf/zellij that referenced this pull request Oct 23, 2024
…kitty keyboard protocol (zellij-org#3383)

* parse kitty keys from STDIN

* work

* work

* replace internal Key representation with the new KeyWithModifier in all the places

* work

* work

* allow disabling with config

* adjust ordering

* handle enabling/disabling properly on the client

* support multiple modifiers without kitty too

* normalize uppercase keys

* get tests to pass

* various cleanups

* style(fmt): rustfmt
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

Successfully merging this pull request may close these issues.

1 participant