aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/tab
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2025-06-26 13:51:17 +0200
committerGitHub <noreply@github.com>2025-06-26 13:51:17 +0200
commit11015c8fe4db1a8ffe77e0c569f0e026c53d9776 (patch)
tree82c8513128e4be58cf6ac991b9872c9b44be5b46 /zellij-server/src/tab
parentdocs(changelog): terminal performance (diff)
downloadsl0ppij-11015c8fe4db1a8ffe77e0c569f0e026c53d9776.tar.gz
sl0ppij-11015c8fe4db1a8ffe77e0c569f0e026c53d9776.tar.xz
sl0ppij-11015c8fe4db1a8ffe77e0c569f0e026c53d9776.zip
feat(plugin-api): allow replacing pane with existing pane (#4246)
* work * make the api work * some cleanups * close pane * style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/tab')
-rw-r--r--zellij-server/src/tab/mod.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs
index 0e4ee7fe..683a3d4a 100644
--- a/zellij-server/src/tab/mod.rs
+++ b/zellij-server/src/tab/mod.rs
@@ -1617,6 +1617,30 @@ impl Tab {
}
Ok(())
}
+ pub fn close_pane_and_replace_with_other_pane(
+ &mut self,
+ pane_id_to_replace: PaneId,
+ pane_to_replace_with: Box<dyn Pane>,
+ ) {
+ let mut replaced_pane = if self.floating_panes.panes_contain(&pane_id_to_replace) {
+ self.floating_panes
+ .replace_pane(pane_id_to_replace, pane_to_replace_with)
+ .ok()
+ } else {
+ self.tiled_panes
+ .replace_pane(pane_id_to_replace, pane_to_replace_with)
+ };
+ if let Some(replaced_pane) = replaced_pane.take() {
+ let pane_id = replaced_pane.pid();
+ let _ = self.senders.send_to_pty(PtyInstruction::ClosePane(pane_id));
+ let _ = self.senders.send_to_plugin(PluginInstruction::Update(vec![(
+ None,
+ None,
+ Event::PaneClosed(pane_id.into()),
+ )]));
+ drop(replaced_pane);
+ }
+ }
pub fn horizontal_split(
&mut self,
pid: PaneId,