diff options
author | Theo Salzmann <dev@on3iro.de> | 2023-04-18 16:33:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 16:33:20 +0200 |
commit | 525928b18a05d8662b5de7e85987428d84c0cb7d (patch) | |
tree | 03654c4d59cc6c1902ac90f3b497f2892c58f749 /zellij-server/src/tab | |
parent | c7bd2ce9222d328369216ba287c57752910e0e88 (diff) |
feat: Add layout configuration to exclude panes from tab sync (#2314)
Diffstat (limited to 'zellij-server/src/tab')
-rw-r--r-- | zellij-server/src/tab/layout_applier.rs | 6 | ||||
-rw-r--r-- | zellij-server/src/tab/mod.rs | 31 |
2 files changed, 30 insertions, 7 deletions
diff --git a/zellij-server/src/tab/layout_applier.rs b/zellij-server/src/tab/layout_applier.rs index ef475c07e..a89a42dc4 100644 --- a/zellij-server/src/tab/layout_applier.rs +++ b/zellij-server/src/tab/layout_applier.rs @@ -235,6 +235,9 @@ impl<'a> LayoutApplier<'a> { layout.run.clone(), ); new_plugin.set_borderless(layout.borderless); + if let Some(exclude_from_sync) = layout.exclude_from_sync { + new_plugin.set_exclude_from_sync(exclude_from_sync); + } self.tiled_panes .add_pane_with_existing_geom(PaneId::Plugin(pid), Box::new(new_plugin)); set_focus_pane_id(layout, PaneId::Plugin(pid)); @@ -262,6 +265,9 @@ impl<'a> LayoutApplier<'a> { layout.run.clone(), ); new_pane.set_borderless(layout.borderless); + if let Some(exclude_from_sync) = layout.exclude_from_sync { + new_pane.set_exclude_from_sync(exclude_from_sync); + } if let Some(held_command) = hold_for_command { new_pane.hold(None, true, held_command.clone()); } diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index d61eb1a4c..65228b83a 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -371,6 +371,9 @@ pub trait Pane { fn load_pane_name(&mut self); fn set_borderless(&mut self, borderless: bool); fn borderless(&self) -> bool; + fn set_exclude_from_sync(&mut self, exclude_from_sync: bool); + fn exclude_from_sync(&self) -> bool; + // TODO: this should probably be merged with the mouse_right_click fn handle_right_click(&mut self, _to: &Position, _client_id: ClientId) {} fn mouse_left_click(&self, _position: &Position, _is_held: bool) -> Option<String> { @@ -1656,15 +1659,29 @@ impl Tab { let err_context = || format!("failed to write to pane with id {pane_id:?}"); let mut should_update_ui = false; + let is_sync_panes_active = self.is_sync_panes_active(); + + let active_terminal = self + .floating_panes + .get_mut(&pane_id) + .or_else(|| self.tiled_panes.get_pane_mut(pane_id)) + .or_else(|| self.suppressed_panes.get_mut(&pane_id)) + .ok_or_else(|| anyhow!(format!("failed to find pane with id {pane_id:?}"))) + .with_context(err_context)?; + + // We always write for non-synced terminals. + // However if the terminal is part of a tab-sync, we need to + // check if the terminal should receive input or not (depending on its + // 'exclude_from_sync' configuration). + let should_not_write_to_terminal = + is_sync_panes_active && active_terminal.exclude_from_sync(); + + if should_not_write_to_terminal { + return Ok(should_update_ui); + } + match pane_id { PaneId::Terminal(active_terminal_id) => { - let active_terminal = self - .floating_panes - .get_mut(&pane_id) - .or_else(|| self.tiled_panes.get_pane_mut(pane_id)) - .or_else(|| self.suppressed_panes.get_mut(&pane_id)) - .ok_or_else(|| anyhow!(format!("failed to find pane with id {pane_id:?}"))) - .with_context(err_context)?; match active_terminal.adjust_input_to_terminal(input_bytes) { Some(AdjustedInput::WriteBytesToTerminal(adjusted_input)) => { self.senders |