summaryrefslogtreecommitdiffstats
path: root/zellij-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'zellij-utils/src')
-rw-r--r--zellij-utils/src/errors.rs2
-rw-r--r--zellij-utils/src/input/actions.rs1
-rw-r--r--zellij-utils/src/kdl/mod.rs23
-rw-r--r--zellij-utils/src/plugin_api/action.proto7
-rw-r--r--zellij-utils/src/plugin_api/action.rs52
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap234
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap234
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap234
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap234
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap234
10 files changed, 1249 insertions, 6 deletions
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index 5b3233998..0677f611f 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -291,6 +291,8 @@ pub enum ScreenContext {
GoToTabName,
UpdateTabName,
UndoRenameTab,
+ MoveTabLeft,
+ MoveTabRight,
TerminalResize,
TerminalPixelDimensions,
TerminalBackgroundColor,
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index 9ad63e05d..18ed0a8da 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -209,6 +209,7 @@ pub enum Action {
ToggleTab,
TabNameInput(Vec<u8>),
UndoRenameTab,
+ MoveTab(Direction),
/// Run specified command in new pane.
Run(RunCommandAction),
/// Detach session and exit
diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs
index 763e5b1cd..23d7e69ea 100644
--- a/zellij-utils/src/kdl/mod.rs
+++ b/zellij-utils/src/kdl/mod.rs
@@ -453,6 +453,24 @@ impl Action {
})?;
Ok(Action::MoveFocusOrTab(direction))
},
+ "MoveTab" => {
+ let direction = Direction::from_str(string.as_str()).map_err(|_| {
+ ConfigError::new_kdl_error(
+ format!("Invalid direction: '{}'", string),
+ action_node.span().offset(),
+ action_node.span().len(),
+ )
+ })?;
+ if direction.is_vertical() {
+ Err(ConfigError::new_kdl_error(
+ format!("Invalid horizontal direction: '{}'", string),
+ action_node.span().offset(),
+ action_node.span().len(),
+ ))
+ } else {
+ Ok(Action::MoveTab(direction))
+ }
+ },
"MovePane" => {
if string.is_empty() {
return Ok(Action::MovePane(None));
@@ -738,6 +756,11 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
action_arguments,
kdl_action
),
+ "MoveTab" => parse_kdl_action_char_or_string_arguments!(
+ action_name,
+ action_arguments,
+ kdl_action
+ ),
"MoveFocusOrTab" => parse_kdl_action_char_or_string_arguments!(
action_name,
action_arguments,
diff --git a/zellij-utils/src/plugin_api/action.proto b/zellij-utils/src/plugin_api/action.proto
index 0ed5b3b7a..d59da4ad6 100644
--- a/zellij-utils/src/plugin_api/action.proto
+++ b/zellij-utils/src/plugin_api/action.proto
@@ -54,6 +54,7 @@ message Action {
string rename_session_payload = 45;
LaunchOrFocusPluginPayload launch_plugin_payload = 46;
CliPipePayload message_payload = 47;
+ MoveTabDirection move_tab_payload = 48;
}
}
@@ -91,6 +92,11 @@ enum SearchOption {
Wrap = 2;
}
+enum MoveTabDirection {
+ Left = 0;
+ Right = 1;
+}
+
message LaunchOrFocusPluginPayload {
string plugin_url = 1;
bool should_float = 2;
@@ -236,6 +242,7 @@ enum ActionName {
RenameSession = 80;
LaunchPlugin = 81;
CliPipe = 82;
+ MoveTab = 83;
}
message Position {
diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs
index 0e5f0f62e..5673d1f9a 100644
--- a/zellij-utils/src/plugin_api/action.rs
+++ b/zellij-utils/src/plugin_api/action.rs
@@ -2,12 +2,13 @@ pub use super::generated_api::api::{
action::{
action::OptionalPayload, Action as ProtobufAction, ActionName as ProtobufActionName,
DumpScreenPayload, EditFilePayload, GoToTabNamePayload, IdAndName,
- LaunchOrFocusPluginPayload, MovePanePayload, NameAndValue as ProtobufNameAndValue,
- NewFloatingPanePayload, NewPanePayload, NewPluginPanePayload, NewTiledPanePayload,
- PaneIdAndShouldFloat, PluginConfiguration as ProtobufPluginConfiguration,
- Position as ProtobufPosition, RunCommandAction as ProtobufRunCommandAction,
- ScrollAtPayload, SearchDirection as ProtobufSearchDirection,
- SearchOption as ProtobufSearchOption, SwitchToModePayload, WriteCharsPayload, WritePayload,
+ LaunchOrFocusPluginPayload, MovePanePayload, MoveTabDirection as ProtobufMoveTabDirection,
+ NameAndValue as ProtobufNameAndValue, NewFloatingPanePayload, NewPanePayload,
+ NewPluginPanePayload, NewTiledPanePayload, PaneIdAndShouldFloat,
+ PluginConfiguration as ProtobufPluginConfiguration, Position as ProtobufPosition,
+ RunCommandAction as ProtobufRunCommandAction, ScrollAtPayload,
+ SearchDirection as ProtobufSearchDirection, SearchOption as ProtobufSearchOption,
+ SwitchToModePayload, WriteCharsPayload, WritePayload,
},
input_mode::InputMode as ProtobufInputMode,
resize::{Resize as ProtobufResize, ResizeDirection as ProtobufResizeDirection},
@@ -359,6 +360,15 @@ impl TryFrom<ProtobufAction> for Action {
Some(_) => Err("UndoRenameTab should not have a payload"),
None => Ok(Action::UndoRenameTab),
},
+ Some(ProtobufActionName::MoveTab) => match protobuf_action.optional_payload {
+ Some(OptionalPayload::MoveTabPayload(move_tab_payload)) => {
+ let direction: Direction = ProtobufMoveTabDirection::from_i32(move_tab_payload)
+ .ok_or("Malformed move tab direction for Action::MoveTab")?
+ .try_into()?;
+ Ok(Action::MoveTab(direction))
+ },
+ _ => Err("Wrong payload for Action::MoveTab"),
+ },
Some(ProtobufActionName::Run) => match protobuf_action.optional_payload {
Some(OptionalPayload::RunPayload(run_command_action)) => {
let run_command_action = run_command_action.try_into()?;
@@ -990,6 +1000,13 @@ impl TryFrom<Action> for ProtobufAction {
name: ProtobufActionName::UndoRenameTab as i32,
optional_payload: None,
}),
+ Action::MoveTab(direction) => {
+ let direction: ProtobufMoveTabDirection = direction.try_into()?;
+ Ok(ProtobufAction {
+ name: ProtobufActionName::MoveTab as i32,
+ optional_payload: Some(OptionalPayload::MoveTabPayload(direction as i32)),
+ })
+ },
Action::Run(run_command_action) => {
let run_command_action: ProtobufRunCommandAction = run_command_action.try_into()?;
Ok(ProtobufAction {
@@ -1309,6 +1326,29 @@ impl TryFrom<SearchDirection> for ProtobufSearchDirection {
}
}
+impl TryFrom<ProtobufMoveTabDirection> for Direction {
+ type Error = &'static str;
+ fn try_from(
+ protobuf_move_tab_direction: ProtobufMoveTabDirection,
+ ) -> Result<Self, &'static str> {
+ match protobuf_move_tab_direction {
+ ProtobufMoveTabDirection::Left => Ok(Direction::Left),
+ ProtobufMoveTabDirection::Right => Ok(Direction::Right),
+ }
+ }
+}
+
+impl TryFrom<Direction> for ProtobufMoveTabDirection {
+ type Error = &'static str;
+ fn try_from(direction: Direction) -> Result<Self, &'static str> {
+ match direction {
+ Direction::Left => Ok(ProtobufMoveTabDirection::Left),
+ Direction::Right => Ok(ProtobufMoveTabDirection::Right),
+ _ => Err("Wrong direction for ProtobufMoveTabDirection"),
+ }
+ }
+}
+
impl TryFrom<ProtobufRunCommandAction> for RunCommandAction {
type Error = &'static str;
fn try_from(
diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap
index 657b0aee4..18eaddceb 100644
--- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap
+++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap
@@ -61,6 +61,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -97,6 +106,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -402,6 +420,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -438,6 +465,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -745,6 +781,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -781,6 +826,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -1134,6 +1188,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -1170,6 +1233,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -1406,6 +1478,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -1442,6 +1523,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -1618,6 +1708,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -1654,6 +1753,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -1909,6 +2017,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -1945,6 +2062,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -2121,6 +2247,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -2157,6 +2292,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -2330,6 +2474,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -2366,6 +2519,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -2570,6 +2732,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -2606,6 +2777,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -2847,6 +3027,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -2883,6 +3072,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -3053,6 +3251,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -3089,6 +3296,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -3427,6 +3643,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -3463,6 +3688,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap
index 2ae24fd40..89f544ff0 100644
--- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap
+++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap
@@ -61,6 +61,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -97,6 +106,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -402,6 +420,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -438,6 +465,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -745,6 +781,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -781,6 +826,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -1134,6 +1188,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -1170,6 +1233,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -1406,6 +1478,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(
'j',
),
): [
@@ -1442,6 +1523,15 @@ Config {
),
],
Alt(
+ Char(
+ 'o',
+ ),
+ ): [
+ MoveTab(
+ Right,
+ ),
+ ],
+ Alt(
Direction(
Left,
),
@@ -1618,6 +1708,15 @@ Config {
],
Alt(
Char(
+ 'i',
+ ),
+ ): [
+ MoveTab(
+ Left,
+ ),
+ ],
+ Alt(
+ Char(