summaryrefslogtreecommitdiffstats
path: root/zellij-utils/src
diff options
context:
space:
mode:
authorOleks Gnatovskyi <22867443+alekspickle@users.noreply.github.com>2023-03-29 23:04:57 +0200
committerGitHub <noreply@github.com>2023-03-29 23:04:57 +0200
commitbdb39b19a6117dc344b1dfee27df778f5386bb62 (patch)
treee3adf519f4c1641bfbdbaa61929a5c8e776a3043 /zellij-utils/src
parent638f2ad4ff5d2e80bb7cee16e8c0512fcbb52caf (diff)
feat(terminal): cli and bindable action to clear all buffers for a specific pane (#2239)
* fix typo * Add clear screen action * add proper test * added bindable action; remove pointless default impl * add default binding * use imsnif's variant * remove commented example config * remove log line --------- Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'zellij-utils/src')
-rw-r--r--zellij-utils/src/cli.rs2
-rw-r--r--zellij-utils/src/errors.rs1
-rw-r--r--zellij-utils/src/input/actions.rs3
-rw-r--r--zellij-utils/src/kdl/mod.rs2
4 files changed, 8 insertions, 0 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs
index f232438b9..aa8a27ea3 100644
--- a/zellij-utils/src/cli.rs
+++ b/zellij-utils/src/cli.rs
@@ -212,6 +212,8 @@ pub enum CliAction {
},
/// Rotate the location of the previous pane backwards
MovePaneBackwards,
+ /// Clear all buffers for a focused pane
+ Clear,
/// Dump the focused pane to a file
DumpScreen {
path: PathBuf,
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index 8a0f63317..e23c22bb0 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -255,6 +255,7 @@ pub enum ScreenContext {
MovePaneRight,
MovePaneLeft,
Exit,
+ ClearScreen,
DumpScreen,
EditScrollback,
ScrollUp,
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index 8e614d6de..d75897918 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -120,6 +120,8 @@ pub enum Action {
MoveFocusOrTab(Direction),
MovePane(Option<Direction>),
MovePaneBackwards,
+ /// Clear all buffers of a current screen
+ ClearScreen,
/// Dumps the screen to a file
DumpScreen(String, bool),
/// Scroll up in focus pane.
@@ -255,6 +257,7 @@ impl Action {
CliAction::MoveFocusOrTab { direction } => Ok(vec![Action::MoveFocusOrTab(direction)]),
CliAction::MovePane { direction } => Ok(vec![Action::MovePane(direction)]),
CliAction::MovePaneBackwards => Ok(vec![Action::MovePaneBackwards]),
+ CliAction::Clear => Ok(vec![Action::ClearScreen]),
CliAction::DumpScreen { path, full } => Ok(vec![Action::DumpScreen(
path.as_os_str().to_string_lossy().into(),
full,
diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs
index 64fe0bac4..1bd1356c1 100644
--- a/zellij-utils/src/kdl/mod.rs
+++ b/zellij-utils/src/kdl/mod.rs
@@ -68,6 +68,7 @@ macro_rules! parse_kdl_action_arguments {
"ToggleMouseMode" => Ok(Action::ToggleMouseMode),
"PreviousSwapLayout" => Ok(Action::PreviousSwapLayout),
"NextSwapLayout" => Ok(Action::NextSwapLayout),
+ "Clear" => Ok(Action::ClearScreen),
_ => Err(ConfigError::new_kdl_error(
format!("Unsupported action: {:?}", $action_name),
$action_node.span().offset(),
@@ -689,6 +690,7 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
},
"Detach" => parse_kdl_action_arguments!(action_name, action_arguments, kdl_action),
"Copy" => parse_kdl_action_arguments!(action_name, action_arguments, kdl_action),
+ "Clear" => parse_kdl_action_arguments!(action_name, action_arguments, kdl_action),
"Confirm" => parse_kdl_action_arguments!(action_name, action_arguments, kdl_action),
"Deny" => parse_kdl_action_arguments!(action_name, action_arguments, kdl_action),
"Write" => parse_kdl_action_u8_arguments!(action_name, action_arguments, kdl_action),