diff options
author | a-kenji <aks.kenji@protonmail.com> | 2021-08-21 23:27:23 +0200 |
---|---|---|
committer | a-kenji <aks.kenji@protonmail.com> | 2021-08-21 23:27:23 +0200 |
commit | 88b4063879845cf53397f60201473ce386280cfe (patch) | |
tree | 2451496e64350111d503673bcdac11a4f2b5d6a6 /zellij-utils/src/setup.rs | |
parent | 2e1775678577e8587ca0830a15810212c4b209f7 (diff) |
Add `template` section in `layout` file
It works as follows:
```
---
template:
direction: Horizontal
parts:
- direction: Vertical
split_size:
Fixed: 1
run:
plugin: tab-bar
- direction: Vertical
body: true
- direction: Vertical
split_size:
Fixed: 2
run:
plugin: status-bar
tabs:
- direction: Vertical
```
The tabs are created in the body section of the template.
Diffstat (limited to 'zellij-utils/src/setup.rs')
-rw-r--r-- | zellij-utils/src/setup.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index fe941ec86..c680822de 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -6,7 +6,7 @@ use crate::{ }, input::{ config::{Config, ConfigError}, - layout::{Layout, MainLayout}, + layout::{LayoutFromYaml, LayoutTemplate}, options::Options, }, }; @@ -153,7 +153,7 @@ impl Setup { /// 2. config options (`config.yaml`) pub fn from_options( opts: &CliArgs, - ) -> Result<(Config, Option<MainLayout>, Options), ConfigError> { + ) -> Result<(Config, Option<LayoutTemplate>, Options), ConfigError> { let clean = match &opts.command { Some(Command::Setup(ref setup)) => setup.clean, _ => false, @@ -176,7 +176,7 @@ impl Setup { .layout_dir .clone() .or_else(|| get_layout_dir(opts.config_dir.clone().or_else(find_default_config_dir))); - let layout_result = Layout::from_path_or_default( + let layout_result = LayoutFromYaml::from_path_or_default( opts.layout.as_ref(), opts.layout_path.as_ref(), layout_dir, @@ -188,15 +188,7 @@ impl Setup { return Err(e); } } - .map(|layout| layout.construct_main_layout()); - - let layout = match layout { - None => None, - Some(Ok(layout)) => Some(layout), - Some(Err(e)) => { - return Err(e); - } - }; + .map(|layout| layout.construct_layout_template()); if let Some(Command::Setup(ref setup)) = &opts.command { setup.from_cli(opts, &config_options).map_or_else( |