mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-24 01:34:38 +03:00
Defining sync keybind using default.yaml
This commit is contained in:
parent
62662464e3
commit
f6df6e9dc8
@ -97,6 +97,8 @@ keybinds:
|
||||
key: [Char: 'r',]
|
||||
- action: [CloseFocus,]
|
||||
key: [Char: 'x',]
|
||||
- action: [ToggleActiveSyncPanes]
|
||||
key: [Char: 's']
|
||||
- action: [ToggleFocusFullscreen,]
|
||||
key: [Char: 'f',]
|
||||
- action: [FocusPreviousPane,]
|
||||
|
@ -105,279 +105,6 @@ impl Keybinds {
|
||||
keybinds
|
||||
}
|
||||
|
||||
/// Returns the default keybinds for a given [`InputMode`].
|
||||
fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
||||
let mut defaults = HashMap::new();
|
||||
|
||||
match *mode {
|
||||
InputMode::Normal => {
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('r'),
|
||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('s'),
|
||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
||||
|
||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
||||
}
|
||||
InputMode::Locked => {
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
}
|
||||
InputMode::Resize => {
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('r'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('s'),
|
||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
||||
defaults.insert(
|
||||
Key::Char('\n'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Char(' '),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
|
||||
defaults.insert(Key::Char('h'), vec![Action::Resize(Direction::Left)]);
|
||||
defaults.insert(Key::Char('j'), vec![Action::Resize(Direction::Down)]);
|
||||
defaults.insert(Key::Char('k'), vec![Action::Resize(Direction::Up)]);
|
||||
defaults.insert(Key::Char('l'), vec![Action::Resize(Direction::Right)]);
|
||||
|
||||
defaults.insert(Key::Left, vec![Action::Resize(Direction::Left)]);
|
||||
defaults.insert(Key::Down, vec![Action::Resize(Direction::Down)]);
|
||||
defaults.insert(Key::Up, vec![Action::Resize(Direction::Up)]);
|
||||
defaults.insert(Key::Right, vec![Action::Resize(Direction::Right)]);
|
||||
|
||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
||||
}
|
||||
InputMode::Pane => {
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Ctrl('p'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Ctrl('r'),
|
||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('s'),
|
||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
||||
defaults.insert(
|
||||
Key::Char('\n'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Char(' '),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
|
||||
defaults.insert(Key::Char('h'), vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Char('j'), vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Char('k'), vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Char('l'), vec![Action::MoveFocus(Direction::Right)]);
|
||||
|
||||
defaults.insert(Key::Left, vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Down, vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Up, vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Right, vec![Action::MoveFocus(Direction::Right)]);
|
||||
|
||||
defaults.insert(Key::Char('p'), vec![Action::SwitchFocus]);
|
||||
defaults.insert(Key::Char('n'), vec![Action::NewPane(None)]);
|
||||
defaults.insert(Key::Char('d'), vec![Action::NewPane(Some(Direction::Down))]);
|
||||
defaults.insert(
|
||||
Key::Char('r'),
|
||||
vec![Action::NewPane(Some(Direction::Right))],
|
||||
);
|
||||
defaults.insert(Key::Char('x'), vec![Action::CloseFocus]);
|
||||
defaults.insert(Key::Char('s'), vec![Action::ToggleActiveSyncPanes]);
|
||||
defaults.insert(Key::Char('f'), vec![Action::ToggleFocusFullscreen]);
|
||||
|
||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
||||
}
|
||||
InputMode::Tab => {
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('r'),
|
||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Ctrl('t'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Ctrl('s'),
|
||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
||||
defaults.insert(
|
||||
Key::Char('\n'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Char(' '),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
|
||||
defaults.insert(Key::Char('h'), vec![Action::GoToPreviousTab]);
|
||||
defaults.insert(Key::Char('j'), vec![Action::GoToNextTab]);
|
||||
defaults.insert(Key::Char('k'), vec![Action::GoToPreviousTab]);
|
||||
defaults.insert(Key::Char('l'), vec![Action::GoToNextTab]);
|
||||
|
||||
defaults.insert(Key::Left, vec![Action::GoToPreviousTab]);
|
||||
defaults.insert(Key::Down, vec![Action::GoToNextTab]);
|
||||
defaults.insert(Key::Up, vec![Action::GoToPreviousTab]);
|
||||
defaults.insert(Key::Right, vec![Action::GoToNextTab]);
|
||||
|
||||
defaults.insert(Key::Char('n'), vec![Action::NewTab]);
|
||||
defaults.insert(Key::Char('x'), vec![Action::CloseTab]);
|
||||
|
||||
defaults.insert(
|
||||
Key::Char('r'),
|
||||
vec![
|
||||
Action::SwitchToMode(InputMode::RenameTab),
|
||||
Action::TabNameInput(vec![0]),
|
||||
],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
for i in '1'..='9' {
|
||||
defaults.insert(Key::Char(i), vec![Action::GoToTab(i.to_digit(10).unwrap())]);
|
||||
}
|
||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
||||
}
|
||||
InputMode::Scroll => {
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('r'),
|
||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('s'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
||||
defaults.insert(
|
||||
Key::Char('\n'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Char(' '),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
|
||||
defaults.insert(Key::Char('j'), vec![Action::ScrollDown]);
|
||||
defaults.insert(Key::Char('k'), vec![Action::ScrollUp]);
|
||||
|
||||
defaults.insert(Key::Ctrl('f'), vec![Action::PageScrollDown]);
|
||||
defaults.insert(Key::Ctrl('b'), vec![Action::PageScrollUp]);
|
||||
defaults.insert(Key::PageDown, vec![Action::PageScrollDown]);
|
||||
defaults.insert(Key::PageUp, vec![Action::PageScrollUp]);
|
||||
|
||||
defaults.insert(Key::Down, vec![Action::ScrollDown]);
|
||||
defaults.insert(Key::Up, vec![Action::ScrollUp]);
|
||||
|
||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
||||
}
|
||||
InputMode::RenameTab => {
|
||||
defaults.insert(Key::Char('\n'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Esc,
|
||||
vec![
|
||||
Action::TabNameInput(vec![0x1b]),
|
||||
Action::SwitchToMode(InputMode::Tab),
|
||||
],
|
||||
);
|
||||
|
||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
||||
}
|
||||
}
|
||||
ModeKeybinds(defaults)
|
||||
}
|
||||
|
||||
/// Converts a [`Key`] terminal event to a sequence of [`Action`]s according to the current
|
||||
/// [`InputMode`] and [`Keybinds`].
|
||||
pub fn key_to_actions(
|
||||
|
Loading…
Reference in New Issue
Block a user