Match Zellij tab and pane navigation shortcuts
This commit is contained in:
@@ -108,7 +108,10 @@ run `psyterm --shutdown` on the remote host, for example through SSH.
|
||||
| Ctrl/Cmd+Shift+P | Open the command palette |
|
||||
| Click a tab | Switch the server's active tab |
|
||||
| `+` or Ctrl+Shift+T | Create a tab |
|
||||
| Ctrl+Shift+D | Add a pane beside the focused pane |
|
||||
| Ctrl+Shift+D or Alt+\ | Add a pane beside the focused pane |
|
||||
| Alt+Left / Right | Focus the adjacent pane, then adjacent tab at the edge |
|
||||
| Alt+Shift+[ / ] | Switch to the previous / next tab |
|
||||
| Alt+Shift+N or Alt+Shift+Right | Create a tab |
|
||||
| Ctrl+Shift+Left / Right | Focus the previous / next pane |
|
||||
| Ctrl+Shift+W | Close the focused pane and its shell |
|
||||
| Ctrl+Shift+R | Edit the pane name |
|
||||
@@ -121,6 +124,10 @@ run `psyterm --shutdown` on the remote host, for example through SSH.
|
||||
| Shift+PageUp / PageDown | Scroll one page |
|
||||
| Shift+Home / End | Jump to oldest history / live screen |
|
||||
|
||||
Navigation follows the `shared` bindings in `~/.config/zellij/config.kdl`, with
|
||||
Alt+\ from its default `locked` mode. Existing psyTerm shortcuts remain available;
|
||||
Zellij's modal Ctrl bindings are left to terminal programs.
|
||||
|
||||
The command palette searches command names and keywords as you type. Arrow keys
|
||||
or Tab select a result; Enter runs it or opens a submenu. Escape returns to the
|
||||
parent menu, then closes the palette. “Switch to tab…” and “Focus pane…” offer
|
||||
@@ -182,7 +189,7 @@ scrollback by default.
|
||||
| `protocol.rs`, `client.rs` | Versioned bounded messages, local socket / SSH transport, snapshot delivery |
|
||||
| `launcher.rs` | Server startup, private paths, lifecycle locks, and the server-owned GUI zygote |
|
||||
| `terminal.rs` | Snapshot-only GUI workspace and panes, command dispatch, focus, and animation scheduling |
|
||||
| `commands.rs`, `palette.rs` | Extensible command metadata, optional shortcuts, searchable nested menus |
|
||||
| `commands.rs`, `bindings.rs`, `palette.rs` | Extensible command metadata, optional shortcuts, searchable nested menus |
|
||||
| `pane_name.rs`, `label.rs` | Pane name editor, Unicode composition, and middle-truncated labels |
|
||||
| `render.rs`, `cursor.rs` | Cached text and batched drawing; cursor motion and blink |
|
||||
| `chrome.rs`, `colors.rs`, `fonts.rs` | Window chrome, terminal colors, font selection |
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
//! Application shortcuts, including the user's Zellij `locked`/`shared` map.
|
||||
//! Registry commands remain available even when they have no shortcut here.
|
||||
use gpui::Keystroke;
|
||||
|
||||
use crate::commands::CommandAction;
|
||||
|
||||
pub fn action_for_key(key: &Keystroke) -> Option<CommandAction> {
|
||||
let modifiers = key.modifiers;
|
||||
let name = key.key.to_lowercase();
|
||||
if (modifiers.control || modifiers.platform) && modifiers.shift && !modifiers.alt {
|
||||
return Some(match name.as_str() {
|
||||
"t" => CommandAction::NewTab,
|
||||
"d" => CommandAction::SplitPane,
|
||||
"w" => CommandAction::ClosePane,
|
||||
"r" => CommandAction::RenamePane,
|
||||
"c" => CommandAction::Copy,
|
||||
"v" => CommandAction::Paste,
|
||||
"left" => CommandAction::PreviousPane,
|
||||
"right" => CommandAction::NextPane,
|
||||
_ => return None,
|
||||
});
|
||||
}
|
||||
if !modifiers.alt || modifiers.control || modifiers.platform {
|
||||
return None;
|
||||
}
|
||||
if modifiers.shift {
|
||||
// Wayland keyboard layouts can report the shifted symbol for brackets.
|
||||
Some(match name.as_str() {
|
||||
"[" | "{" => CommandAction::PreviousTab,
|
||||
"]" | "}" => CommandAction::NextTab,
|
||||
"n" | "right" => CommandAction::NewTab,
|
||||
_ => return None,
|
||||
})
|
||||
} else {
|
||||
Some(match name.as_str() {
|
||||
// GPUI consumes Shift for punctuation, leaving Alt+{ / Alt+}.
|
||||
"{" => CommandAction::PreviousTab,
|
||||
"}" => CommandAction::NextTab,
|
||||
"left" => CommandAction::FocusLeft,
|
||||
"right" => CommandAction::FocusRight,
|
||||
"\\" => CommandAction::SplitPane,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn action(key: &str) -> Option<CommandAction> {
|
||||
action_for_key(&Keystroke::parse(key).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zellij_tab_bindings_accept_shifted_and_unshifted_brackets() {
|
||||
for key in ["alt-shift-[", "alt-shift-{", "alt-{"] {
|
||||
assert!(matches!(action(key), Some(CommandAction::PreviousTab)));
|
||||
}
|
||||
for key in ["alt-shift-]", "alt-shift-}", "alt-}"] {
|
||||
assert!(matches!(action(key), Some(CommandAction::NextTab)));
|
||||
}
|
||||
for key in ["alt-shift-n", "alt-shift-right"] {
|
||||
assert!(matches!(action(key), Some(CommandAction::NewTab)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zellij_horizontal_focus_and_existing_shortcuts_coexist() {
|
||||
assert!(matches!(action("alt-left"), Some(CommandAction::FocusLeft)));
|
||||
assert!(matches!(
|
||||
action("alt-right"),
|
||||
Some(CommandAction::FocusRight)
|
||||
));
|
||||
assert!(matches!(action("alt-\\"), Some(CommandAction::SplitPane)));
|
||||
assert!(matches!(
|
||||
action("ctrl-shift-left"),
|
||||
Some(CommandAction::PreviousPane)
|
||||
));
|
||||
assert!(matches!(action("cmd-shift-t"), Some(CommandAction::NewTab)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shell_keys_and_unconfigured_modes_remain_available() {
|
||||
for key in [
|
||||
"ctrl-c",
|
||||
"ctrl-t",
|
||||
"ctrl-p",
|
||||
"alt-h",
|
||||
"alt-ctrl-left",
|
||||
"left",
|
||||
"shift-right",
|
||||
] {
|
||||
assert!(action(key).is_none(), "{key} must reach the terminal");
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -131,7 +131,7 @@ pub fn root_items(snapshot: Option<&Snapshot>) -> Vec<PaletteItem> {
|
||||
"previous-tab",
|
||||
"Previous tab",
|
||||
"switch navigate left",
|
||||
None,
|
||||
Some("Alt+Shift+["),
|
||||
PreviousTab,
|
||||
)
|
||||
.available(tabs),
|
||||
@@ -139,7 +139,7 @@ pub fn root_items(snapshot: Option<&Snapshot>) -> Vec<PaletteItem> {
|
||||
"next-tab",
|
||||
"Next tab",
|
||||
"switch navigate right",
|
||||
None,
|
||||
Some("Alt+Shift+]"),
|
||||
NextTab,
|
||||
)
|
||||
.available(tabs),
|
||||
@@ -163,7 +163,7 @@ pub fn root_items(snapshot: Option<&Snapshot>) -> Vec<PaletteItem> {
|
||||
"focus-left",
|
||||
"Focus pane or tab left",
|
||||
"navigate previous horizontal",
|
||||
None,
|
||||
Some("Alt+Left"),
|
||||
FocusLeft,
|
||||
)
|
||||
.available(pane),
|
||||
@@ -171,7 +171,7 @@ pub fn root_items(snapshot: Option<&Snapshot>) -> Vec<PaletteItem> {
|
||||
"focus-right",
|
||||
"Focus pane or tab right",
|
||||
"navigate next horizontal",
|
||||
None,
|
||||
Some("Alt+Right"),
|
||||
FocusRight,
|
||||
)
|
||||
.available(pane),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
mod bindings;
|
||||
mod chrome;
|
||||
mod client;
|
||||
mod colors;
|
||||
|
||||
+1
-15
@@ -116,21 +116,7 @@ impl Workspace {
|
||||
{
|
||||
return;
|
||||
}
|
||||
let action = if command {
|
||||
match key.key.to_lowercase().as_str() {
|
||||
"t" => Some(CommandAction::NewTab),
|
||||
"d" => Some(CommandAction::SplitPane),
|
||||
"w" => Some(CommandAction::ClosePane),
|
||||
"r" => Some(CommandAction::RenamePane),
|
||||
"c" => Some(CommandAction::Copy),
|
||||
"v" => Some(CommandAction::Paste),
|
||||
"left" => Some(CommandAction::PreviousPane),
|
||||
"right" => Some(CommandAction::NextPane),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let action = crate::bindings::action_for_key(key);
|
||||
if let Some(action) = action {
|
||||
self.execute(action, window, cx);
|
||||
cx.stop_propagation();
|
||||
|
||||
Reference in New Issue
Block a user