diff options
Diffstat (limited to 'zellij-utils')
-rw-r--r-- | zellij-utils/assets/layouts/default.yaml | 6 | ||||
-rw-r--r-- | zellij-utils/assets/layouts/disable-status-bar.yaml | 3 | ||||
-rw-r--r-- | zellij-utils/assets/layouts/strider.yaml | 9 | ||||
-rw-r--r-- | zellij-utils/src/input/command.rs | 1 | ||||
-rw-r--r-- | zellij-utils/src/input/layout.rs | 36 |
5 files changed, 45 insertions, 10 deletions
diff --git a/zellij-utils/assets/layouts/default.yaml b/zellij-utils/assets/layouts/default.yaml index 9be7af2a7..96bf1809c 100644 --- a/zellij-utils/assets/layouts/default.yaml +++ b/zellij-utils/assets/layouts/default.yaml @@ -4,9 +4,11 @@ parts: - direction: Vertical split_size: Fixed: 1 - plugin: tab-bar + run: + plugin: tab-bar - direction: Vertical - direction: Vertical split_size: Fixed: 2 - plugin: status-bar + run: + plugin: status-bar diff --git a/zellij-utils/assets/layouts/disable-status-bar.yaml b/zellij-utils/assets/layouts/disable-status-bar.yaml index fd9c97da6..b990ba500 100644 --- a/zellij-utils/assets/layouts/disable-status-bar.yaml +++ b/zellij-utils/assets/layouts/disable-status-bar.yaml @@ -4,5 +4,6 @@ parts: - direction: Vertical split_size: Fixed: 1 - plugin: tab-bar + run: + plugin: tab-bar - direction: Vertical diff --git a/zellij-utils/assets/layouts/strider.yaml b/zellij-utils/assets/layouts/strider.yaml index 5dc9b08f9..9bbe5772f 100644 --- a/zellij-utils/assets/layouts/strider.yaml +++ b/zellij-utils/assets/layouts/strider.yaml @@ -4,15 +4,18 @@ parts: - direction: Vertical split_size: Fixed: 1 - plugin: tab-bar + run: + plugin: tab-bar - direction: Vertical parts: - direction: Horizontal split_size: Percent: 20 - plugin: strider + run: + plugin: strider - direction: Horizontal - direction: Vertical split_size: Fixed: 2 - plugin: status-bar + run: + plugin: status-bar diff --git a/zellij-utils/src/input/command.rs b/zellij-utils/src/input/command.rs index b66c7500e..2054f208d 100644 --- a/zellij-utils/src/input/command.rs +++ b/zellij-utils/src/input/command.rs @@ -11,6 +11,7 @@ pub enum TerminalAction { #[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq, Eq)] pub struct RunCommand { + #[serde(alias = "cmd")] pub command: PathBuf, #[serde(default)] pub args: Vec<String>, diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index 16309db1d..a48c35219 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -8,7 +8,11 @@ // place. // If plugins should be able to depend on the layout system // then [`zellij-utils`] could be a proper place. -use crate::{input::config::ConfigError, pane_size::PositionAndSize, setup}; +use crate::{ + input::{command::RunCommand, config::ConfigError}, + pane_size::PositionAndSize, + setup, +}; use crate::{serde, serde_yaml}; use serde::{Deserialize, Serialize}; @@ -31,12 +35,21 @@ pub enum SplitSize { #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(crate = "self::serde")] +pub enum Run { + #[serde(rename = "plugin")] + Plugin(Option<PathBuf>), + #[serde(rename = "command")] + Command(RunCommand), +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(crate = "self::serde")] pub struct Layout { pub direction: Direction, #[serde(default)] pub parts: Vec<Layout>, pub split_size: Option<SplitSize>, - pub plugin: Option<PathBuf>, + pub run: Option<Run>, } type LayoutResult = Result<Layout, ConfigError>; @@ -127,13 +140,28 @@ impl Layout { let mut total_panes = 0; total_panes += self.parts.len(); for part in self.parts.iter() { - if part.plugin.is_none() { - total_panes += part.total_terminal_panes(); + match part.run { + Some(Run::Command(_)) | None => { + total_panes += part.total_terminal_panes(); + } + Some(Run::Plugin(_)) => {} } } total_panes } + pub fn extract_run_instructions(&self) -> Vec<Option<Run>> { + let mut run_instructions = vec![]; + if self.parts.is_empty() { + run_instructions.push(self.run.clone()); + } + for part in self.parts.iter() { + let mut current_runnables = part.extract_run_instructions(); + run_instructions.append(&mut current_runnables); + } + run_instructions + } + pub fn position_panes_in_space( &self, space: &PositionAndSize, |