diff options
Diffstat (limited to 'zellij-server')
49 files changed, 1621 insertions, 117 deletions
diff --git a/zellij-server/src/panes/floating_panes/mod.rs b/zellij-server/src/panes/floating_panes/mod.rs index 98c6046bf..2de5b74eb 100644 --- a/zellij-server/src/panes/floating_panes/mod.rs +++ b/zellij-server/src/panes/floating_panes/mod.rs @@ -898,4 +898,18 @@ impl FloatingPanes { } pane_infos } + pub fn set_geom_for_pane_with_run(&mut self, run: Option<Run>, geom: PaneGeom) { + match self + .panes + .iter_mut() + .find(|(_, p)| p.invoked_with() == &run) + { + Some((_, pane)) => { + pane.set_geom(geom); + }, + None => { + log::error!("Failed to find pane with run: {:?}", run); + }, + } + } } diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs index f0a6e8436..9aca1af4a 100644 --- a/zellij-server/src/panes/tiled_panes/mod.rs +++ b/zellij-server/src/panes/tiled_panes/mod.rs @@ -182,9 +182,13 @@ impl TiledPanes { let has_room_for_new_pane = pane_grid .find_room_for_new_pane(cursor_height_width_ratio) .is_some(); - has_room_for_new_pane || pane_grid.has_room_for_new_stacked_pane() + has_room_for_new_pane || pane_grid.has_room_for_new_stacked_pane() || self.panes.is_empty() } fn add_pane(&mut self, pane_id: PaneId, mut pane: Box<dyn Pane>, should_relayout: bool) { + if self.panes.is_empty() { + self.panes.insert(pane_id, pane); + return; + } let cursor_height_width_ratio = self.cursor_height_width_ratio(); let mut pane_grid = TiledPaneGrid::new( &mut self.panes, @@ -250,6 +254,19 @@ impl TiledPanes { }) .collect() } + pub fn non_selectable_pane_geoms_inside_viewport(&self) -> Vec<Viewport> { + self.panes + .values() + .filter_map(|p| { + let geom = p.position_and_size(); + if !p.selectable() && is_inside_viewport(&self.viewport.borrow(), p) { + Some(geom.into()) + } else { + None + } + }) + .collect() + } pub fn first_selectable_pane_id(&self) -> Option<PaneId> { self.panes .iter() @@ -587,8 +604,6 @@ impl TiledPanes { pub fn focused_pane_id(&self, client_id: ClientId) -> Option<PaneId> { self.active_panes.get(&client_id).copied() } - // FIXME: Really not a fan of allowing this... Someone with more energy - // than me should clean this up someday... #[allow(clippy::borrowed_box)] pub fn get_pane(&self, pane_id: PaneId) -> Option<&Box<dyn Pane>> { self.panes.get(&pane_id) @@ -735,6 +750,29 @@ impl TiledPanes { pub fn get_panes(&self) -> impl Iterator<Item = (&PaneId, &Box<dyn Pane>)> { self.panes.iter() } + pub fn set_geom_for_pane_with_run( + &mut self, + run: Option<Run>, + geom: PaneGeom, + borderless: bool, + ) { + match self + .panes + .iter_mut() + .find(|(_, p)| p.invoked_with() == &run) + { + Some((_, pane)) => { + pane.set_geom(geom); + pane.set_borderless(borderless); + if self.draw_pane_frames { + pane.set_content_offset(Offset::frame(1)); + } + }, + None => { + log::error!("Failed to find pane with run: {:?}", run); + }, + } + } pub fn resize(&mut self, new_screen_size: Size) { // this is blocked out to appease the borrow checker { @@ -1501,11 +1539,11 @@ impl TiledPanes { self.set_pane_frames(self.draw_pane_frames); // recalculate pane frames and update size closed_pane } else { - self.panes.remove(&pane_id); + let closed_pane = self.panes.remove(&pane_id); // this is a bit of a roundabout way to say: this is the last pane and so the tab // should be destroyed self.active_panes.clear(&mut self.panes); - None + closed_pane } } pub fn hold_pane( diff --git a/zellij-server/src/plugins/mod.rs b/zellij-server/src/plugins/mod.rs index 7791880f2..f36bdc2d2 100644 --- a/zellij-server/src/plugins/mod.rs +++ b/zellij-server/src/plugins/mod.rs @@ -228,6 +228,7 @@ pub(crate) fn plugin_thread_main( }; let mut extracted_floating_plugins: Vec<Option<Run>> = floating_panes_layout .iter() + .filter(|f| !f.already_running) .map(|f| f.run.clone()) .collect(); extracted_run_instructions.append(&mut extracted_floating_plugins); diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command-2.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command-2.snap index e165dab10..43571f91f 100644 --- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command-2.snap +++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command-2.snap @@ -1,6 +1,6 @@ --- source: zellij-server/src/plugins/./unit/plugin_tests.rs -assertion_line: 521 +assertion_line: 735 expression: "format!(\"{:#?}\", second_new_tab_event)" --- Some( @@ -24,6 +24,7 @@ Some( children_are_stacked: false, is_expanded_in_stack: false, exclude_from_sync: None, + run_instructions_to_ignore: [], }, TiledPaneLayout { children_split_direction: Horizontal, @@ -37,6 +38,7 @@ Some( children_are_stacked: false, is_expanded_in_stack: false, exclude_from_sync: None, + run_instructions_to_ignore: [], }, ], split_size: None, @@ -47,6 +49,7 @@ Some( children_are_stacked: false, is_expanded_in_stack: false, exclude_from_sync: None, + run_instructions_to_ignore: [], }, ), [], diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command.snap index af83de326..5e9a17cb3 100644 --- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command.snap +++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command.snap @@ -1,6 +1,6 @@ --- source: zellij-server/src/plugins/./unit/plugin_tests.rs -assertion_line: 520 +assertion_line: 734 expression: "format!(\"{:#?}\", first_new_tab_event)" --- Some( @@ -24,6 +24,7 @@ Some( children_are_stacked: false, is_expanded_in_stack: false, |