aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/input
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-12-31 12:37:23 +0100
committerGitHub <noreply@github.com>2024-12-31 12:37:23 +0100
commit42adc8cd048c03d52a9f33503d75e24364adbc68 (patch)
tree943ee11e188e6512b336b603bdd5ea8eae38998b /zellij-utils/src/input
parentdocs(changelog): cursor overflow fix (diff)
downloadsl0ppij-42adc8cd048c03d52a9f33503d75e24364adbc68.tar.gz
sl0ppij-42adc8cd048c03d52a9f33503d75e24364adbc68.tar.xz
sl0ppij-42adc8cd048c03d52a9f33503d75e24364adbc68.zip
feat(ux): stack panes command (#3905)
* working across tabs and floating panes through the cli * finalize cli command * plugin api * style(fmt): rustfmt * fix: re-focus pane in stack if it was focused * style(fmt): rustfmt * remove outdated comment
Diffstat (limited to 'zellij-utils/src/input')
-rw-r--r--zellij-utils/src/input/actions.rs50
1 files changed, 49 insertions, 1 deletions
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index f6ecf096..95ec6eb2 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -6,7 +6,7 @@ use super::layout::{
SwapFloatingLayout, SwapTiledLayout, TiledPaneLayout,
};
use crate::cli::CliAction;
-use crate::data::{Direction, KeyWithModifier, Resize};
+use crate::data::{Direction, KeyWithModifier, PaneId, Resize};
use crate::data::{FloatingPaneCoordinates, InputMode};
use crate::home::{find_default_config_dir, get_layout_dir};
use crate::input::config::{Config, ConfigError, KdlError};
@@ -301,6 +301,7 @@ pub enum Action {
},
ListClients,
TogglePanePinned,
+ StackPanes(Vec<PaneId>),
}
impl Action {
@@ -742,6 +743,53 @@ impl Action {
},
CliAction::ListClients => Ok(vec![Action::ListClients]),
CliAction::TogglePanePinned => Ok(vec![Action::TogglePanePinned]),
+ CliAction::StackPanes { pane_ids } => {
+ let mut malformed_ids = vec![];
+ let pane_ids = pane_ids
+ .iter()
+ .filter_map(|stringified_pane_id| {
+ if let Some(terminal_pane_id) =
+ stringified_pane_id.strip_prefix("terminal_")
+ {
+ u32::from_str_radix(terminal_pane_id, 10)
+ .ok()
+ .or_else(|| {
+ malformed_ids.push(stringified_pane_id.to_owned());
+ None
+ })
+ .map(|id| PaneId::Terminal(id))
+ } else if let Some(plugin_pane_id) =
+ stringified_pane_id.strip_prefix("plugin_")
+ {
+ u32::from_str_radix(plugin_pane_id, 10)
+ .ok()
+ .or_else(|| {
+ malformed_ids.push(stringified_pane_id.to_owned());
+ None
+ })
+ .map(|id| PaneId::Plugin(id))
+ } else {
+ u32::from_str_radix(stringified_pane_id, 10)
+ .ok()
+ .or_else(|| {
+ malformed_ids.push(stringified_pane_id.to_owned());
+ None
+ })
+ .map(|id| PaneId::Terminal(id))
+ }
+ })
+ .collect();
+ if !malformed_ids.is_empty() {
+ Err(
+ format!(
+ "Malformed pane ids: {}, expecting a space separated list of either a bare integer (eg. 1), a terminal pane id (eg. terminal_1) or a plugin pane id (eg. plugin_1)",
+ malformed_ids.join(", ")
+ )
+ )
+ } else {
+ Ok(vec![Action::StackPanes(pane_ids)])
+ }
+ },
}
}
pub fn launches_plugin(&self, plugin_url: &str) -> bool {