summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-04-03 18:04:06 +0200
committerGitHub <noreply@github.com>2023-04-03 18:04:06 +0200
commit3a428effed2327b8f82bd8cd328f385032e5bc06 (patch)
treeb100fa9b9bb49583e8efee7567973ded1e8b87ae
parent63d6711a8dad531b3188b32fa19642c76cb7eec6 (diff)
feat(panes): allow defining an expanded stacked pane (#2343)
* feat(panes): allow defining an expanded stacked pane * style(fmt): rustfmt
-rw-r--r--zellij-server/src/panes/tiled_panes/mod.rs43
-rw-r--r--zellij-server/src/panes/tiled_panes/stacked_panes.rs10
-rw-r--r--zellij-server/src/tab/layout_applier.rs21
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__can_define_expanded_pane_in_stack.snap26
-rw-r--r--zellij-server/src/tab/unit/tab_integration_tests.rs32
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_tab_action_default_params.snap5
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_tab_action_with_name_and_layout.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_rename_tab.snap7
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_undo_rename_tab.snap7
-rw-r--r--zellij-utils/src/input/layout.rs6
-rw-r--r--zellij-utils/src/input/unit/layout_test.rs29
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_a_stack_with_an_expanded_pane.snap79
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_node.snap6
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_template.snap7
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_load_swap_layouts_from_a_different_file.snap38
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__children_not_as_first_child_of_pane_template.snap14
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__children_not_as_first_child_of_tab_template.snap14
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__combined_tab_and_pane_template_both_with_children.snap19
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_added_to_cwd_in_template.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_override_cwd_in_template.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd.snap6
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_pane_templates.snap9
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_tab_templates.snap8
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_given_to_panes_without_cwd.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor_overrides_global_cwd_in_layout_file.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_prepended_to_panes_with_cwd.snap5
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_with_tab_cwd_given_to_panes_without_cwd.snap6
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_start_suspended.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_default_tab_template.snap22
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_nested_branched_pane_templates.snap13
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_nested_pane_templates.snap10
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_pane_templates.snap24
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_tab_and_pane_templates.snap9
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_tabs_and_floating_panes.snap7
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_is_overriden_by_its_consumers_bare_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_overriden_by_its_consumers_command_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_remains_when_its_consumer_command_does_not_have_a_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_is_overriden_by_its_consumers_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_receives_its_consumers_bare_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_cwd_overriden_by_its_consumers_bare_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_with_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_without_cwd.snap4
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_edit.snap2
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_command_propagated_to_its_consumer_edit.snap2
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_given_to_panes_without_cwd.snap6
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_prepended_to_panes_with_cwd.snap6
-rw-r--r--zellij-utils/src/kdl/kdl_layout_parser.rs32
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_layout_options-2.snap3
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments-2.snap78
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_options_override_config_options-2.snap3
56 files changed, 649 insertions, 56 deletions
diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs
index 89a329bb4..4cc7279d7 100644
--- a/zellij-server/src/panes/tiled_panes/mod.rs
+++ b/zellij-server/src/panes/tiled_panes/mod.rs
@@ -423,7 +423,7 @@ impl TiledPanes {
.unwrap_or(false)
{
let _ = StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
- .focus_pane(&pane_id);
+ .expand_pane(&pane_id);
}
self.active_panes
.insert(client_id, pane_id, &mut self.panes);
@@ -446,7 +446,7 @@ impl TiledPanes {
{
let _ =
StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
- .focus_pane(&pane_id);
+ .expand_pane(&pane_id);
}
self.active_panes
.insert(client_id, *pane_id, &mut self.panes);
@@ -465,7 +465,7 @@ impl TiledPanes {
&mut self.panes,
&self.panes_to_hide,
)
- .focus_pane(&pane_id);
+ .expand_pane(&pane_id);
}
self.active_panes
.insert(client_id, pane_id, &mut self.panes);
@@ -477,6 +477,33 @@ impl TiledPanes {
self.set_force_render();
self.reapply_pane_frames();
}
+ pub fn expand_pane_in_stack(&mut self, pane_id: PaneId) -> Vec<PaneId> {
+ // returns all pane ids in stack
+ match StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
+ .expand_pane(&pane_id)
+ {
+ Ok(all_panes_in_stack) => {
+ let connected_clients: Vec<ClientId> =
+ self.connected_clients.borrow().iter().copied().collect();
+ for client_id in connected_clients {
+ if let Some(focused_pane_id_for_client) = self.active_panes.get(&client_id) {
+ if all_panes_in_stack.contains(focused_pane_id_for_client) {
+ self.active_panes
+ .insert(client_id, pane_id, &mut self.panes);
+ self.set_pane_active_at(pane_id);
+ }
+ }
+ }
+ self.set_force_render();
+ self.reapply_pane_frames();
+ all_panes_in_stack
+ },
+ Err(e) => {
+ log::error!("Failed to expand pane in stack: {:?}", e);
+ vec![]
+ },
+ }
+ }
pub fn focus_pane(&mut self, pane_id: PaneId, client_id: ClientId) {
if self
.panes
@@ -485,7 +512,7 @@ impl TiledPanes {
.unwrap_or(false)
{
let _ = StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
- .focus_pane(&pane_id);
+ .expand_pane(&pane_id);
self.reapply_pane_frames();
}
@@ -826,7 +853,7 @@ impl TiledPanes {
.unwrap_or(false)
{
let _ = StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
- .focus_pane(&next_active_pane_id);
+ .expand_pane(&next_active_pane_id);
self.reapply_pane_frames();
}
@@ -858,7 +885,7 @@ impl TiledPanes {
.unwrap_or(false)
{
let _ = StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
- .focus_pane(&next_active_pane_id);
+ .expand_pane(&next_active_pane_id);
self.reapply_pane_frames();
}
for client_id in connected_clients {
@@ -1166,7 +1193,7 @@ impl TiledPanes {
.unwrap_or(false)
{
let _ = StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
- .focus_pane(&new_position_id);
+ .expand_pane(&new_position_id);
self.reapply_pane_frames();
}
@@ -1430,7 +1457,7 @@ impl TiledPanes {
.unwrap_or(false)
{
let _ = StackedPanes::new_from_btreemap(&mut self.panes, &self.panes_to_hide)
- .focus_pane(&next_active_pane_id);
+ .expand_pane(&next_active_pane_id);
self.reapply_pane_frames();
}
for (client_id, active_pane_id) in active_panes {
diff --git a/zellij-server/src/panes/tiled_panes/stacked_panes.rs b/zellij-server/src/panes/tiled_panes/stacked_panes.rs
index cc0b0f151..bc5057a5b 100644
--- a/zellij-server/src/panes/tiled_panes/stacked_panes.rs
+++ b/zellij-server/src/panes/tiled_panes/stacked_panes.rs
@@ -102,9 +102,8 @@ impl<'a> StackedPanes<'a> {
}
Ok(())
}
- pub fn focus_pane(&mut self, pane_id: &PaneId) -> Result<()> {
- // this function doesn't actually change the focus (since it is controlled elsewhere)
- // but rather makes sure pane_id is flexible if it were a one-liner before
+ pub fn expand_pane(&mut self, pane_id: &PaneId) -> Result<Vec<PaneId>> {
+ // returns all the pane ids in the stack
let err_context = || format!("Failed to focus stacked pane");
let all_stacked_pane_positions =
self.positions_in_stack(pane_id).with_context(err_context)?;
@@ -158,7 +157,10 @@ impl<'a> StackedPanes<'a> {
}
}
}
- Ok(())
+ Ok(all_stacked_pane_positions