summaryrefslogtreecommitdiffstats
path: root/zellij-server
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-08-02 11:41:51 +0200
committerGitHub <noreply@github.com>2023-08-02 11:41:51 +0200
commit192e6fd31ece0c73f8962f4af620a2757a2c1a2e (patch)
tree6ae03596196acf35f6c71cc4dc79c309f2917d8b /zellij-server
parent8fb90391c8bb558726c029732ac753318021e144 (diff)
feat(ui): break pane to new tab and move panes between tabs (#2664)
* prototype * some tests * break out floating pane * break out plugin panes * add keybind and fix some minor issues * remove cli * move pane to left/right tab * update ui * adjust ui * style(fmt): rustfmt * style(comment): remove commented code * update snapshots
Diffstat (limited to 'zellij-server')
-rw-r--r--zellij-server/src/panes/floating_panes/mod.rs14
-rw-r--r--zellij-server/src/panes/tiled_panes/mod.rs48
-rw-r--r--zellij-server/src/plugins/mod.rs1
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command-2.snap5
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__new_tabs_with_layout_plugin_command.snap5
-rw-r--r--zellij-server/src/pty.rs6
-rw-r--r--zellij-server/src/route.rs19
-rw-r--r--zellij-server/src/screen.rs178
-rw-r--r--zellij-server/src/tab/layout_applier.rs98
-rw-r--r--zellij-server/src/tab/mod.rs32
-rw-r--r--zellij-server/src/unit/screen_tests.rs526
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_pane_to_a_new_tab-2.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_pane_to_a_new_tab-3.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_pane_to_a_new_tab-4.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_pane_to_a_new_tab-5.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_pane_to_a_new_tab.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-2.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-3.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-4.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-5.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-6.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-7.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-8.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_pane_to_a_new_tab-2.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_pane_to_a_new_tab-3.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_pane_to_a_new_tab-4.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_pane_to_a_new_tab-5.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_pane_to_a_new_tab.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab-2.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab-3.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab-4.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab-5.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab-6.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_left-2.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_left-3.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_left-4.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_left-5.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_left.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_right-2.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_right-3.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_right-4.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_right-5.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_move_pane_to_a_new_tab_right.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_cannot_break_last_selectable_pane_to_a_new_tab-2.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_cannot_break_last_selectable_pane_to_a_new_tab.snap26
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_tab_action_default_params.snap4
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_tab_action_with_name_and_layout.snap6
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,
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/pty.rs b/zellij-server/src/pty.rs
index 84f282f8d..f571d4381 100644
--- a/zellij-server/src/pty.rs
+++ b/zellij-server/src/pty.rs
@@ -605,8 +605,10 @@ impl Pty {
default_shell.unwrap_or_else(|| self.get_default_terminal(cwd, None));
self.fill_cwd(&mut defa