diff options
| author | Brooks Rady <b.j.rady@gmail.com> | 2021-04-28 16:27:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-28 16:27:06 +0100 |
| commit | 3c431ee6254858e5a46fd0870e5aff47f57f64e3 (patch) | |
| tree | fc8bc45e46354debd316c0e88a1194643089014a /src/common | |
| parent | docs(changelog): Screen Config File (#399) (diff) | |
| parent | Defining sync keybind using default.yaml (diff) | |
| download | sl0ppij-3c431ee6254858e5a46fd0870e5aff47f57f64e3.tar.gz sl0ppij-3c431ee6254858e5a46fd0870e5aff47f57f64e3.tar.xz sl0ppij-3c431ee6254858e5a46fd0870e5aff47f57f64e3.zip | |
feat(ui): add the ability to synchronize input sent to panes
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/errors.rs | 2 | ||||
| -rw-r--r-- | src/common/input/actions.rs | 2 | ||||
| -rw-r--r-- | src/common/input/handler.rs | 6 | ||||
| -rw-r--r-- | src/common/mod.rs | 16 | ||||
| -rw-r--r-- | src/common/screen.rs | 4 |
5 files changed, 25 insertions, 5 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs index dd675738..c1c6753f 100644 --- a/src/common/errors.rs +++ b/src/common/errors.rs @@ -200,6 +200,7 @@ pub enum ScreenContext { PageScrollDown, ClearScroll, CloseFocusedPane, + ToggleActiveSyncPanes, ToggleActiveTerminalFullscreen, SetSelectable, SetInvisibleBorders, @@ -260,6 +261,7 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName, ScreenInstruction::TerminalResize => ScreenContext::TerminalResize, ScreenInstruction::ChangeMode(_) => ScreenContext::ChangeMode, + ScreenInstruction::ToggleActiveSyncPanes => ScreenContext::ToggleActiveSyncPanes, } } } diff --git a/src/common/input/actions.rs b/src/common/input/actions.rs index 3bcadf15..46a8e1d6 100644 --- a/src/common/input/actions.rs +++ b/src/common/input/actions.rs @@ -39,6 +39,8 @@ pub enum Action { PageScrollDown, /// Toggle between fullscreen focus pane and normal layout. ToggleFocusFullscreen, + /// Toggle between sending text commands to all panes and normal mode. + ToggleActiveSyncPanes, /// Open a new pane in the specified direction (relative to focus). /// If no direction is specified, will try to use the biggest available space. NewPane(Option<Direction>), diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 197f8315..62118722 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -244,6 +244,11 @@ impl InputHandler { .send(ScreenInstruction::SwitchTabPrev) .unwrap(); } + Action::ToggleActiveSyncPanes => { + self.send_screen_instructions + .send(ScreenInstruction::ToggleActiveSyncPanes) + .unwrap(); + } Action::CloseTab => { self.command_is_executing.closing_pane(); self.send_screen_instructions @@ -293,6 +298,7 @@ pub fn get_mode_info(mode: InputMode) -> ModeInfo { keybinds.push(("d".to_string(), "Down split".to_string())); keybinds.push(("r".to_string(), "Right split".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())); } InputMode::Tab => { diff --git a/src/common/mod.rs b/src/common/mod.rs index ec2efe58..0a04e3ff 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -320,10 +320,11 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) { command_is_executing.done_opening_new_pane(); } ScreenInstruction::WriteCharacter(bytes) => { - screen - .get_active_tab_mut() - .unwrap() - .write_to_active_terminal(bytes); + let active_tab = screen.get_active_tab_mut().unwrap(); + match active_tab.is_sync_panes_active() { + true => active_tab.write_to_terminals_on_current_tab(bytes), + false => active_tab.write_to_active_terminal(bytes), + } } ScreenInstruction::ResizeLeft => { screen.get_active_tab_mut().unwrap().resize_left(); @@ -444,6 +445,13 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) { ScreenInstruction::ChangeMode(mode_info) => { screen.change_mode(mode_info); } + ScreenInstruction::ToggleActiveSyncPanes => { + screen + .get_active_tab_mut() + .unwrap() + .toggle_sync_panes_is_active(); + screen.update_tabs(); + } ScreenInstruction::Quit => { break; } diff --git a/src/common/screen.rs b/src/common/screen.rs index a2f41574..bc68f2ea 100644 --- a/src/common/screen.rs +++ b/src/common/screen.rs @@ -51,6 +51,7 @@ pub enum ScreenInstruction { NewTab(RawFd), SwitchTabNext, SwitchTabPrev, + ToggleActiveSyncPanes, CloseTab, GoToTab(u32), UpdateTabName(Vec<u8>), @@ -285,7 +286,7 @@ impl Screen { self.update_tabs(); } - fn update_tabs(&self) { + pub fn update_tabs(&self) { let mut tab_data = vec![]; let active_tab_index = self.active_tab_index.unwrap(); for tab in self.tabs.values() { @@ -293,6 +294,7 @@ impl Screen { position: tab.position, name: tab.name.clone(), active: active_tab_index == tab.index, + is_sync_panes_active: tab.is_sync_panes_active(), }); } self.send_plugin_instructions |
