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/client | |
| 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/client')
| -rw-r--r-- | src/client/tab.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/client/tab.rs b/src/client/tab.rs index af48d3fe..f9d98ace 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -68,6 +68,7 @@ pub struct Tab { max_panes: Option<usize>, full_screen_ws: PositionAndSize, fullscreen_is_active: bool, + synchronize_is_active: bool, os_api: Box<dyn OsApi>, pub send_pty_instructions: SenderWithContext<PtyInstruction>, pub send_plugin_instructions: SenderWithContext<PluginInstruction>, @@ -249,6 +250,7 @@ impl Tab { active_terminal: pane_id, full_screen_ws: *full_screen_ws, fullscreen_is_active: false, + synchronize_is_active: false, os_api, send_app_instructions, send_pty_instructions, @@ -592,6 +594,21 @@ impl Tab { 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>) { match self.get_active_pane_id() { Some(PaneId::Terminal(active_terminal_id)) => { @@ -677,6 +694,12 @@ impl Tab { pub fn toggle_fullscreen_is_active(&mut self) { 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) { if self.active_terminal.is_none() { // we might not have an active terminal if we closed the last pane |
