summaryrefslogtreecommitdiffstats
path: root/zellij-utils
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-utils
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-utils')
-rw-r--r--zellij-utils/assets/config/default.kdl3
-rw-r--r--zellij-utils/src/errors.rs3
-rw-r--r--zellij-utils/src/input/actions.rs3
-rw-r--r--zellij-utils/src/input/layout.rs30
-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.snap6
-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__env_var_expansion.snap12
-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.snap2
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_start_suspended.snap2
-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_excluded_from_sync.snap3
-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.snap8
-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.snap3
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_command_propagated_to_its_consumer_edit.snap3
-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/mod.rs3
-rw-r--r--zellij-utils/src/pane_size.rs6
-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.snap98
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap24
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap24
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_options_override_config_options-2.snap3
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap24
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap24
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap24
57 files changed, 572 insertions, 38 deletions
diff --git a/zellij-utils/assets/config/default.kdl b/zellij-utils/assets/config/default.kdl
index 57106681d..32dfb86e0 100644
--- a/zellij-utils/assets/config/default.kdl
+++ b/zellij-utils/assets/config/default.kdl
@@ -54,6 +54,9 @@ keybinds {
bind "n" { NewTab; SwitchToMode "Normal"; }
bind "x" { CloseTab; SwitchToMode "Normal"; }
bind "s" { ToggleActiveSyncTab; SwitchToMode "Normal"; }
+ bind "b" { BreakPane; SwitchToMode "Normal"; }
+ bind "]" { BreakPaneRight; SwitchToMode "Normal"; }
+ bind "[" { BreakPaneLeft; SwitchToMode "Normal"; }
bind "1" { GoToTab 1; SwitchToMode "Normal"; }
bind "2" { GoToTab 2; SwitchToMode "Normal"; }
bind "3" { GoToTab 3; SwitchToMode "Normal"; }
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index e2e3c244f..df5d02782 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -338,6 +338,9 @@ pub enum ScreenContext {
FocusPaneWithId,
RenamePane,
RenameTab,
+ BreakPane,
+ BreakPaneRight,
+ BreakPaneLeft,
}
/// Stack call representations corresponding to the different types of [`PtyInstruction`]s.
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index 568c0a2c2..4ed7f029c 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -240,6 +240,9 @@ pub enum Action {
RenameTerminalPane(u32, Vec<u8>),
RenamePluginPane(u32, Vec<u8>),
RenameTab(u32, Vec<u8>),
+ BreakPane,
+ BreakPaneRight,
+ BreakPaneLeft,
}
impl Action {
diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs
index 55e5fc69f..39d208e83 100644
--- a/zellij-utils/src/input/layout.rs
+++ b/zellij-utils/src/input/layout.rs
@@ -401,6 +401,7 @@ pub struct FloatingPaneLayout {
pub y: Option<PercentOrFixed>,
pub run: Option<Run>,
pub focus: Option<bool>,
+ pub already_running: bool,
}
impl FloatingPaneLayout {
@@ -438,6 +439,7 @@ pub struct TiledPaneLayout {
pub children_are_stacked: bool,
pub is_expanded_in_stack: bool,
pub exclude_from_sync: Option<bool>,
+ pub run_instructions_to_ignore: Vec<Option<Run>>,
}
impl TiledPaneLayout {
@@ -559,8 +561,36 @@ impl TiledPaneLayout {
let mut child_run_instructions = child.extract_run_instructions();
run_instructions.append(&mut child_run_instructions);
}
+ let mut successfully_ignored = 0;
+ for instruction_to_ignore in &self.run_instructions_to_ignore {
+ if let Some(position) = run_instructions
+ .iter()
+ .position(|i| i == instruction_to_ignore)
+ {
+ run_instructions.remove(position);
+ successfully_ignored += 1;
+ }
+ }
+ // we need to do this because if we have an ignored instruction that does not match any
+ // running instruction, we'll have an extra pane and our state will be messed up and we'll
+ // crash (this can happen for example when breaking a plugin pane into a new tab that does
+ // not have room for it but has a terminal instead)
+ if successfully_ignored < self.run_instructions_to_ignore.len() {
+ for _ in 0..self
+ .run_instructions_to_ignore
+ .len()
+ .saturating_sub(successfully_ignored)
+ {
+ if let Some(position) = run_instructions.iter().position(|i| i == &None) {
+ run_instructions.remove(position);
+ }
+ }
+ }
run_instructions
}
+ pub fn ignore_run_instruction(&mut self, run_instruction: Option<Run>) {
+ self.run_instructions_to_ignore.push(run_instruction);
+ }
pub fn with_one_pane() -> Self {
let mut default_layout = TiledPaneLayout::default();
default_layout.children = vec![TiledPaneLayout::default()];
diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap
index d01949514..9d2d9e37e 100644
--- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap
+++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap
@@ -1,6 +1,6 @@
---
source: zellij-utils/src/input/./unit/layout_test.rs
-assertion_line: 1322
+assertion_line: 1352
expression: "format!(\"{:#?}\", layout)"
---
Layout {
@@ -34,6 +34,7 @@ Layout {
children_are_stacked: false,
is_expanded_in_stack: false,
exclude_from_sync: None,
+ run_instructions_to_ignore: [],
},
TiledPaneLayout {
children_split_direction: Horizontal,
@@ -60,6 +61,7 @@ Layout {
children_are_stacked: false,
is_expanded_in_stack: false,
exclude_from_sync: None,
+ run_instructions_to_ignore: [],
},
],
split_size: None,
@@ -70,6 +72,7 @@ Layout {
children_are_stacked: false,
is_expanded_in_stack: false,
exclude_from_sync: None,
+ run_instructions_to_ignore: [],
},
[],
),
diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap
index d31f721f0..e8c140421 100644
--- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap
+++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap
@@ -1,6 +1,6 @@
---
source: zellij-utils/src/input/./unit/layout_test.rs
-assertion_line: 1287
+assertion_line: 1317
expression: "format!(\"{:#?}