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

How to use ToggleNextPane with Ctrl + Tab? #1962

Open
RoneoOrg opened this issue Nov 22, 2022 · 8 comments
Open

How to use ToggleNextPane with Ctrl + Tab? #1962

RoneoOrg opened this issue Nov 22, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@RoneoOrg
Copy link

RoneoOrg commented Nov 22, 2022

Hi there,

I want to navigate between panes with Ctrl + Tab .

To do so, I set this in ~/.config/zellij/config.kdl:

keybinds {
    normal {
        bind "Ctrl: Tab" { FocusNextPane; }

(I'm new to the .kbl syntax and most of the doc and issues are written for Yaml)

Problem

I get the following error when saving the config file and restarting zellij:

  $ zellij
  × Failed to parse Zellij configuration
   ╭─[~/.config/zellij/config.kdl:5:1]
      ...
 6 │         bind "Ctrl Tab" { FocusNextPane; }
   ·         ─────────────────┬─────────────────
   ·                          ╰── Invalid key: 'Ctrl Tab'

I also tried the following syntaxes: "Ctrl: Tab" and "Ctrl: 'Tab'"

Note that other keybindings work fine, for example bind "Tab" { FocusNextPane; } works perfectly.

It seems to be specific to the Ctrl + Tab combination. What am I missing?

Technical details

zellij --version: 0.33.0
stty size: 55 211
uname -av: Linux linux 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux
gnome-terminal --version: GNOME Terminal 3.38.3 using VTE 0.62.3 +BIDI +GNUTLS +ICU +SYSTEMD

Any hint is welcome, Thanks !

@RoneoOrg RoneoOrg added the bug Something isn't working label Nov 22, 2022
@mnpqraven
Copy link

I don't think you can bind Ctrl + Tab as a valid combination. I was using Ctrl Tab with tmux and when I was trying out zellij I realized that I can't set that keybind too.

@naosense
Copy link
Contributor

I'm wondering if it's not supported in kdl configuration or not supported in zj

@naosense
Copy link
Contributor

After i checked the code base, i found this

(Some("Ctrl"), Some(main_key)) => {
let mut key_chars = main_key.chars();
let key_count = main_key.chars().count();
if key_count == 1 {
let key_char = key_chars.next().unwrap();
Ok(Key::Ctrl(key_char))
} else {
Err(format!("Failed to parse key: {}", key_str).into())
}

Hey @imsnif , sorry to bother, why the main_key must be single character key?

@imsnif
Copy link
Member

imsnif commented Nov 28, 2022

Hey @naosense - sorry for the late reply! I was moving to a new apartment over the weekend and was very busy.

While it is possible to change the Key struct to allow for other combinations, the real limitation is in what we can read from STDIN. Things like ctrl+tab may be possible, but I'm not 100% sure.

Before changing the struct, I'd recommend doing some manual tests and seeing what sort of input ctrl+tab (or any other key we'd like to check) gives us. You can add a log::info line after this line here: https://github.com/zellij-org/zellij/blob/main/zellij-client/src/stdin_handler.rs#L44 and see.

Even if this doesn't work and we don't see a difference between ctrl+tab and eg. just tab, it might be an issue with termwiz, our STDIN parsing library. If that's the case, we'll see what (if anything) we can do.

@naosense
Copy link
Contributor

naosense commented Nov 29, 2022

Hey @imsnif, i added log after here

let buf = os_input.read_from_stdin();

and here
current_buffer.append(&mut buf.to_vec());

test ctrl+tab and ctrl + fxx, and both got nothing, while it did work when pressing ctrl+a, printing 1 . I am a little confused, can't OS read combination like ctrl+tab and ctrl + fxx, which has nothing to do with termwiz?

@imsnif
Copy link
Member

imsnif commented Nov 30, 2022

This is one of our big problems, I'm afraid @naosense :/ STDIN by default cannot represent a lot of key combinations we'd like to use, and this is one of them. There are certain protocols http://www.leonerd.org.uk/hacks/fixterms/ that will allow us to bind this and more, but the terminal emulator would have to support this as well (and a lot of them don't, at least not by default).

Another option is to read directly from the keyboard and not from STDIN, then we can do whatever we like, but this won't work over SSH (that's what tmux does and it causes a lot of confusion).

So... no good solution here I'm afraid.

@musjj
Copy link

musjj commented Dec 23, 2023

@imsnif

AFAIK, kitty's keyboard protocol is the best one out there for supporting special key sequences, way better than the fixterms solution (a nice overview here).

Both Helix and Neovim supports kitty's keyboard protocol:

Nushell too: nushell/nushell#10540

Terminals I know that implements it (other than kitty): wezterm, foot and rio. Some more here

It's not the most universal thing out there, but it's a very solid protocol with plenty of implementations in the wild. I think it'd be pretty reasonable to support it.

@imsnif
Copy link
Member

imsnif commented Dec 28, 2023

A week ago, I would have said that I don't think this is true @musjj

The threshold for me is always either one of:

  1. libvte implemented it - meaning all the major linux terminals have it (gnome-terminal, konsole, xfce-terminal, etc.)
  2. Alacritty implemented it - the most popular unassociated OSS terminal

But yesterday, Alacritty implemented it: https://github.com/alacritty/alacritty/releases/tag/v0.13.0

So yes, I agree. We should implement support for it. I hope to get to it early this year (2024), no promises though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants