zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
20.55k stars 637 forks source link

Feature Request: Block key press passing #2452

Open Nemoos-0 opened 1 year ago

Nemoos-0 commented 1 year ago

I will explain my use case to make the feature request clear.

I remapped the keybindings in order to avoid using the Ctrl and Alt keys for all actions. So the default mode is locked, by pressing Ctrl + A I go to normal mode and from there I can press just one letter to go to the different modes:

When I am not in locked mode and I press a key with no action bound to it, the key press is sent to the shell. This is a problem since some key presses will go to the shell and some will go to zellij, making it unclear to which program I am sending key presses to.

I would like an option to avoid sending not mapped key presses to the shell when I am not in locked mode.

Here is an idea on how the configuration file might look like:

keybinds clear-defaults=true {
    locked {
        bind "Ctrl A" { SwitchToMode "normal"; }
    }

    shared_except "locked" {
        bind "Esc" { SwitchToMode "locked"; }
    }

    normal catch-unbind=true { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        // Modes
        bind "r" { SwitchToMode "resize"; }
        bind "p" { SwitchToMode "pane"; }
        bind "m" { SwitchToMode "move"; }
        bind "t" { SwitchToMode "tab"; }
        bind "s" { SwitchToMode "scroll"; }
        bind "/" { SwitchToMode "entersearch"; SearchInput 0; }

        // Layout
        bind "]" { NextSwapLayout; }
        bind "[" { PreviousSwapLayout; }

        bind "d" { Detach; }
        bind "Q" { Quit; }
    }
}

I understand that my use case may be limited, but it would be cool if this feature could be implemented in the future.

averagechris commented 1 year ago

I'd love a similar feature. I'm implementing the super ergonomic workflows from Doom Emacs (and Spacemacs) with zellij. Being able to stop unbound keys from being sent through in certain modes would make that fully possible. If I keep using zellij and get comfy with it, I'd be game to take a shot at implementing this.