From 5ede25dc37ceb192032524ac9200bb1ca95e5863 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 23:37:36 +0200 Subject: Add `tabs` to `layouts` fixes #603, fixes #349 * The layout has now a unique `tabs` section, that can be used, like the `parts` section, everything that is not inside the tabs section is assumed to be present on every single tab that is opened. This is a BREAKING CHANGE for people that use custom `layouts` already, since the `tabs` section is not optional - for clarity and intentionality reasons. The functionality to specify multiple tabs is already there, but is still gated behind a panic, until #621 is fixed. So for now one tab can be specified to load on startup. * The `NewTab` action can optionally be bound to open a layout that is assumed to be in the new `tabs` section This is a BREAKING CHANGE for people that have the `NewTab` action already bound in the config file: ``` - action: [NewTab, ] key: [F: 5,] ``` must now be specified as: ``` - action: [NewTab: ,] key: [F: 5,] ``` Optionally a layout that should be opened on the new tab can be specified: ``` - action: [NewTab: { direction: Vertical, parts: [ {direction: Horizontal, split_size: {Percent: 50}}, {direction: Horizontal, run: {command: {cmd: "htop"}}},], key: [F: 6,] ``` or: ``` - action: [NewTab: {direction: Vertical, run: {command: {cmd: "htop"} }},] key: [F: 7,] ``` or ``` - action: [NewTab: { direction: Vertical, parts: [ {direction: Vertical, split_size: {Percent: 25},run: {plugin: "strider" }}, {direction: Horizontal}],}, MoveFocus: Left,] key: [F: 8,] ``` --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index b3706eadd..050c0cca8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,7 +94,8 @@ pub fn main() { opts.layout.as_ref(), opts.layout_path.as_ref(), layout_dir, - ); + ) + .map(|layout| layout.construct_main_layout()); start_client( Box::new(os_input), -- cgit v1.2.3 From 806ffad5539c99380e7c0e423f4c864d8db431e2 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 23 Jul 2021 17:44:05 +0200 Subject: fixup! fix e2e fixtures --- .../layouts/parts-total-less-than-100-percent.yaml | 2 ++ .../layouts/parts-total-more-than-100-percent.yaml | 3 +++ .../fixtures/layouts/three-panes-with-nesting.yaml | 24 ++++++++++++---------- 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/tests/fixtures/layouts/parts-total-less-than-100-percent.yaml b/src/tests/fixtures/layouts/parts-total-less-than-100-percent.yaml index e1a1a6071..f0f66a323 100644 --- a/src/tests/fixtures/layouts/parts-total-less-than-100-percent.yaml +++ b/src/tests/fixtures/layouts/parts-total-less-than-100-percent.yaml @@ -9,6 +9,8 @@ - direction: Horizontal split_size: Percent: 50 + tabs: + - direction: Horizontal split_size: Percent: 80 - direction: Vertical diff --git a/src/tests/fixtures/layouts/parts-total-more-than-100-percent.yaml b/src/tests/fixtures/layouts/parts-total-more-than-100-percent.yaml index 33d942253..2b55547d4 100644 --- a/src/tests/fixtures/layouts/parts-total-more-than-100-percent.yaml +++ b/src/tests/fixtures/layouts/parts-total-more-than-100-percent.yaml @@ -9,6 +9,9 @@ - direction: Horizontal split_size: Percent: 90 + - direction: Horizontal + tabs: + - direction: Horizontal split_size: Percent: 80 - direction: Vertical diff --git a/src/tests/fixtures/layouts/three-panes-with-nesting.yaml b/src/tests/fixtures/layouts/three-panes-with-nesting.yaml index f1e0dd7e5..20a647f3d 100644 --- a/src/tests/fixtures/layouts/three-panes-with-nesting.yaml +++ b/src/tests/fixtures/layouts/three-panes-with-nesting.yaml @@ -1,16 +1,18 @@ --- direction: Horizontal -parts: - - direction: Vertical +tabs: + - direction: Horizontal parts: - - direction: Horizontal - split_size: - Percent: 20 - - direction: Horizontal + - direction: Vertical + parts: + - direction: Horizontal + split_size: + Percent: 20 + - direction: Horizontal + split_size: + Percent: 80 split_size: Percent: 80 - split_size: - Percent: 80 - - direction: Vertical - split_size: - Percent: 20 + - direction: Vertical + split_size: + Percent: 20 -- cgit v1.2.3