diff options
author | Aram Drevekenin <aram@poor.dev> | 2024-02-26 10:48:02 +0100 |
---|---|---|
committer | Aram Drevekenin <aram@poor.dev> | 2024-02-26 10:48:02 +0100 |
commit | 5071b54b26eb6bede1760e1dd5540c8959b108f5 (patch) | |
tree | f5a7aa488ece8f21c17350bb3ec14ceaf15f60a7 /zellij-utils | |
parent | af17598f3d121fe0373d7f766b17cd437ce0ab49 (diff) | |
parent | 27bffbf1533b4b2d3c10b1305557c75ddd121374 (diff) |
Merge branch 'main' into plugin-aliasesplugin-aliases
Diffstat (limited to 'zellij-utils')
18 files changed, 1283 insertions, 7 deletions
diff --git a/zellij-utils/assets/config/default.kdl b/zellij-utils/assets/config/default.kdl index 16a3450b8..c8e61bf43 100644 --- a/zellij-utils/assets/config/default.kdl +++ b/zellij-utils/assets/config/default.kdl @@ -148,6 +148,8 @@ keybinds { bind "Ctrl g" { SwitchToMode "Locked"; } bind "Ctrl q" { Quit; } bind "Alt n" { NewPane; } + bind "Alt i" { MoveTab "Left"; } + bind "Alt o" { MoveTab "Right"; } bind "Alt h" "Alt Left" { MoveFocusOrTab "Left"; } bind "Alt l" "Alt Right" { MoveFocusOrTab "Right"; } bind "Alt j" "Alt Down" { MoveFocus "Down"; } diff --git a/zellij-utils/assets/plugins/compact-bar.wasm b/zellij-utils/assets/plugins/compact-bar.wasm Binary files differindex a0911ddb6..1b4fac46a 100755 --- a/zellij-utils/assets/plugins/compact-bar.wasm +++ b/zellij-utils/assets/plugins/compact-bar.wasm diff --git a/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm b/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm Binary files differindex 6dba31da3..b5056f248 100755 --- a/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm +++ b/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm diff --git a/zellij-utils/assets/plugins/session-manager.wasm b/zellij-utils/assets/plugins/session-manager.wasm Binary files differindex 109987c0f..00bb30ff3 100755 --- a/zellij-utils/assets/plugins/session-manager.wasm +++ b/zellij-utils/assets/plugins/session-manager.wasm diff --git a/zellij-utils/assets/plugins/status-bar.wasm b/zellij-utils/assets/plugins/status-bar.wasm Binary files differindex 59859deef..31916ecdb 100755 --- a/zellij-utils/assets/plugins/status-bar.wasm +++ b/zellij-utils/assets/plugins/status-bar.wasm diff --git a/zellij-utils/assets/plugins/strider.wasm b/zellij-utils/assets/plugins/strider.wasm Binary files differindex 9ba73f7ad..11024a361 100755 --- a/zellij-utils/assets/plugins/strider.wasm +++ b/zellij-utils/assets/plugins/strider.wasm diff --git a/zellij-utils/assets/plugins/tab-bar.wasm b/zellij-utils/assets/plugins/tab-bar.wasm Binary files differindex 1b4ff1734..b25aef5cf 100755 --- a/zellij-utils/assets/plugins/tab-bar.wasm +++ b/zellij-utils/assets/plugins/tab-bar.wasm diff --git a/zellij-utils/assets/prost/api.action.rs b/zellij-utils/assets/prost/api.action.rs index 4096b0740..fe2c2144a 100644 --- a/zellij-utils/assets/prost/api.action.rs +++ b/zellij-utils/assets/prost/api.action.rs @@ -5,7 +5,7 @@ pub struct Action { pub name: i32, #[prost( oneof = "action::OptionalPayload", - tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47" + tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48" )] pub optional_payload: ::core::option::Option<action::OptionalPayload>, } @@ -106,6 +106,8 @@ pub mod action { LaunchPluginPayload(super::LaunchOrFocusPluginPayload), #[prost(message, tag = "47")] MessagePayload(super::CliPipePayload), + #[prost(enumeration = "super::MoveTabDirection", tag = "48")] + MoveTabPayload(i32), } } #[allow(clippy::derive_partial_eq_without_eq)] @@ -341,6 +343,32 @@ impl SearchOption { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] +pub enum MoveTabDirection { + Left = 0, + Right = 1, +} +impl MoveTabDirection { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + MoveTabDirection::Left => "Left", + MoveTabDirection::Right => "Right", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option<Self> { + match value { + "Left" => Some(Self::Left), + "Right" => Some(Self::Right), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] pub enum ActionName { Quit = 0, Write = 1, @@ -425,6 +453,7 @@ pub enum ActionName { RenameSession = 80, LaunchPlugin = 81, CliPipe = 82, + MoveTab = 83, } impl ActionName { /// String value of the enum field names used in the ProtoBuf definition. @@ -516,6 +545,7 @@ impl ActionName { ActionName::RenameSession => "RenameSession", ActionName::LaunchPlugin => "LaunchPlugin", ActionName::CliPipe => "CliPipe", + ActionName::MoveTab => "MoveTab", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -604,6 +634,7 @@ impl ActionName { "RenameSession" => Some(Self::RenameSession), "LaunchPlugin" => Some(Self::LaunchPlugin), "CliPipe" => Some(Self::CliPipe), + "MoveTab" => Some(Self::MoveTab), _ => None, } } 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( < |