New feature: Synchronize text sent to panes
This commit is contained in:
parent
fe1f0ba3c4
commit
1a84c5f4ec
7 changed files with 325 additions and 4 deletions
|
|
@ -68,6 +68,7 @@ pub struct Tab {
|
||||||
max_panes: Option<usize>,
|
max_panes: Option<usize>,
|
||||||
full_screen_ws: PositionAndSize,
|
full_screen_ws: PositionAndSize,
|
||||||
fullscreen_is_active: bool,
|
fullscreen_is_active: bool,
|
||||||
|
synchronize_is_active: bool,
|
||||||
os_api: Box<dyn OsApi>,
|
os_api: Box<dyn OsApi>,
|
||||||
pub send_pty_instructions: SenderWithContext<PtyInstruction>,
|
pub send_pty_instructions: SenderWithContext<PtyInstruction>,
|
||||||
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
|
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
|
||||||
|
|
@ -249,6 +250,7 @@ impl Tab {
|
||||||
active_terminal: pane_id,
|
active_terminal: pane_id,
|
||||||
full_screen_ws: *full_screen_ws,
|
full_screen_ws: *full_screen_ws,
|
||||||
fullscreen_is_active: false,
|
fullscreen_is_active: false,
|
||||||
|
synchronize_is_active: false,
|
||||||
os_api,
|
os_api,
|
||||||
send_app_instructions,
|
send_app_instructions,
|
||||||
send_pty_instructions,
|
send_pty_instructions,
|
||||||
|
|
@ -592,6 +594,25 @@ impl Tab {
|
||||||
terminal_output.handle_pty_bytes(bytes);
|
terminal_output.handle_pty_bytes(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn write_to_terminals_on_current_tab(&mut self, input_bytes: Vec<u8>) {
|
||||||
|
let pane_ids = self.get_pane_ids();
|
||||||
|
pane_ids.iter().for_each(|pane_id| {
|
||||||
|
match pane_id {
|
||||||
|
PaneId::Terminal(pid) => {
|
||||||
|
self.write_to_pane_id(input_bytes.clone(), *pid);
|
||||||
|
}
|
||||||
|
PaneId::Plugin(_) => {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pub fn write_to_pane_id(&mut self, mut input_bytes: Vec<u8>, pid:RawFd) {
|
||||||
|
self.os_api
|
||||||
|
.write_to_tty_stdin(pid, &mut input_bytes)
|
||||||
|
.expect("failed to write to terminal");
|
||||||
|
self.os_api
|
||||||
|
.tcdrain(pid)
|
||||||
|
.expect("failed to drain terminal");
|
||||||
|
}
|
||||||
pub fn write_to_active_terminal(&mut self, input_bytes: Vec<u8>) {
|
pub fn write_to_active_terminal(&mut self, input_bytes: Vec<u8>) {
|
||||||
match self.get_active_pane_id() {
|
match self.get_active_pane_id() {
|
||||||
Some(PaneId::Terminal(active_terminal_id)) => {
|
Some(PaneId::Terminal(active_terminal_id)) => {
|
||||||
|
|
@ -677,6 +698,12 @@ impl Tab {
|
||||||
pub fn toggle_fullscreen_is_active(&mut self) {
|
pub fn toggle_fullscreen_is_active(&mut self) {
|
||||||
self.fullscreen_is_active = !self.fullscreen_is_active;
|
self.fullscreen_is_active = !self.fullscreen_is_active;
|
||||||
}
|
}
|
||||||
|
pub fn is_sync_panes_active(&self) -> bool {
|
||||||
|
self.synchronize_is_active
|
||||||
|
}
|
||||||
|
pub fn toggle_sync_panes_is_active(&mut self) {
|
||||||
|
self.synchronize_is_active = !self.synchronize_is_active;
|
||||||
|
}
|
||||||
pub fn render(&mut self) {
|
pub fn render(&mut self) {
|
||||||
if self.active_terminal.is_none() {
|
if self.active_terminal.is_none() {
|
||||||
// we might not have an active terminal if we closed the last pane
|
// we might not have an active terminal if we closed the last pane
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,7 @@ pub enum ScreenContext {
|
||||||
PageScrollDown,
|
PageScrollDown,
|
||||||
ClearScroll,
|
ClearScroll,
|
||||||
CloseFocusedPane,
|
CloseFocusedPane,
|
||||||
|
ToggleActiveSyncPanes,
|
||||||
ToggleActiveTerminalFullscreen,
|
ToggleActiveTerminalFullscreen,
|
||||||
SetSelectable,
|
SetSelectable,
|
||||||
SetInvisibleBorders,
|
SetInvisibleBorders,
|
||||||
|
|
@ -260,6 +261,7 @@ impl From<&ScreenInstruction> for ScreenContext {
|
||||||
ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName,
|
ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName,
|
||||||
ScreenInstruction::TerminalResize => ScreenContext::TerminalResize,
|
ScreenInstruction::TerminalResize => ScreenContext::TerminalResize,
|
||||||
ScreenInstruction::ChangeMode(_) => ScreenContext::ChangeMode,
|
ScreenInstruction::ChangeMode(_) => ScreenContext::ChangeMode,
|
||||||
|
ScreenInstruction::ToggleActiveSyncPanes => ScreenContext::ToggleActiveSyncPanes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ pub enum Action {
|
||||||
PageScrollDown,
|
PageScrollDown,
|
||||||
/// Toggle between fullscreen focus pane and normal layout.
|
/// Toggle between fullscreen focus pane and normal layout.
|
||||||
ToggleFocusFullscreen,
|
ToggleFocusFullscreen,
|
||||||
|
/// Toggle between sending text commands to all panes and normal mode.
|
||||||
|
ToggleActiveSyncPanes,
|
||||||
/// Open a new pane in the specified direction (relative to focus).
|
/// Open a new pane in the specified direction (relative to focus).
|
||||||
/// If no direction is specified, will try to use the biggest available space.
|
/// If no direction is specified, will try to use the biggest available space.
|
||||||
NewPane(Option<Direction>),
|
NewPane(Option<Direction>),
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,12 @@ impl InputHandler {
|
||||||
.send(ScreenInstruction::SwitchTabPrev)
|
.send(ScreenInstruction::SwitchTabPrev)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
Action::ToggleActiveSyncPanes => {
|
||||||
|
self.send_screen_instructions
|
||||||
|
.send(ScreenInstruction::ToggleActiveSyncPanes)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
}
|
||||||
Action::CloseTab => {
|
Action::CloseTab => {
|
||||||
self.command_is_executing.closing_pane();
|
self.command_is_executing.closing_pane();
|
||||||
self.send_screen_instructions
|
self.send_screen_instructions
|
||||||
|
|
@ -293,6 +299,7 @@ pub fn get_mode_info(mode: InputMode) -> ModeInfo {
|
||||||
keybinds.push(("d".to_string(), "Down split".to_string()));
|
keybinds.push(("d".to_string(), "Down split".to_string()));
|
||||||
keybinds.push(("r".to_string(), "Right split".to_string()));
|
keybinds.push(("r".to_string(), "Right split".to_string()));
|
||||||
keybinds.push(("x".to_string(), "Close".to_string()));
|
keybinds.push(("x".to_string(), "Close".to_string()));
|
||||||
|
keybinds.push(("s".to_string(), "Sync".to_string()));
|
||||||
keybinds.push(("f".to_string(), "Fullscreen".to_string()));
|
keybinds.push(("f".to_string(), "Fullscreen".to_string()));
|
||||||
}
|
}
|
||||||
InputMode::Tab => {
|
InputMode::Tab => {
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,279 @@ impl Keybinds {
|
||||||
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
|
/// Converts a [`Key`] terminal event to a sequence of [`Action`]s according to the current
|
||||||
/// [`InputMode`] and [`Keybinds`].
|
/// [`InputMode`] and [`Keybinds`].
|
||||||
pub fn key_to_actions(
|
pub fn key_to_actions(
|
||||||
|
|
|
||||||
|
|
@ -320,10 +320,12 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||||
command_is_executing.done_opening_new_pane();
|
command_is_executing.done_opening_new_pane();
|
||||||
}
|
}
|
||||||
ScreenInstruction::WriteCharacter(bytes) => {
|
ScreenInstruction::WriteCharacter(bytes) => {
|
||||||
screen
|
let active_tab = screen.get_active_tab_mut().unwrap();
|
||||||
.get_active_tab_mut()
|
match active_tab.is_sync_panes_active() {
|
||||||
.unwrap()
|
true => active_tab.write_to_terminals_on_current_tab(bytes),
|
||||||
.write_to_active_terminal(bytes);
|
false => active_tab
|
||||||
|
.write_to_active_terminal(bytes),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ScreenInstruction::ResizeLeft => {
|
ScreenInstruction::ResizeLeft => {
|
||||||
screen.get_active_tab_mut().unwrap().resize_left();
|
screen.get_active_tab_mut().unwrap().resize_left();
|
||||||
|
|
@ -444,9 +446,16 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||||
ScreenInstruction::ChangeMode(mode_info) => {
|
ScreenInstruction::ChangeMode(mode_info) => {
|
||||||
screen.change_mode(mode_info);
|
screen.change_mode(mode_info);
|
||||||
}
|
}
|
||||||
|
ScreenInstruction::ToggleActiveSyncPanes => {
|
||||||
|
screen
|
||||||
|
.get_active_tab_mut()
|
||||||
|
.unwrap()
|
||||||
|
.toggle_sync_panes_is_active();
|
||||||
|
}
|
||||||
ScreenInstruction::Quit => {
|
ScreenInstruction::Quit => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ pub enum ScreenInstruction {
|
||||||
NewTab(RawFd),
|
NewTab(RawFd),
|
||||||
SwitchTabNext,
|
SwitchTabNext,
|
||||||
SwitchTabPrev,
|
SwitchTabPrev,
|
||||||
|
ToggleActiveSyncPanes,
|
||||||
CloseTab,
|
CloseTab,
|
||||||
GoToTab(u32),
|
GoToTab(u32),
|
||||||
UpdateTabName(Vec<u8>),
|
UpdateTabName(Vec<u8>),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue