diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-02-25 09:48:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-25 09:48:47 +0100 |
| commit | 6e0dd8e51cae440c1453c983740abc6869c46029 (patch) | |
| tree | 7b7a4aaef1fc5df6ad7c56e572aad50f19858f46 /zellij-utils | |
| parent | fix: respect user's cursor choice in web client even when terminal overrides ... (diff) | |
| download | sl0ppij-6e0dd8e51cae440c1453c983740abc6869c46029.tar.gz sl0ppij-6e0dd8e51cae440c1453c983740abc6869c46029.tar.xz sl0ppij-6e0dd8e51cae440c1453c983740abc6869c46029.zip | |
Atomic show hide floating panes (#4764)
* atomic show/hide floating panes (cli, plugin API, keybinding)
* rustfmt
* add pr
Diffstat (limited to 'zellij-utils')
| -rw-r--r-- | zellij-utils/assets/prost/api.action.rs | 24 | ||||
| -rw-r--r-- | zellij-utils/assets/prost/api.plugin_command.rs | 58 | ||||
| -rw-r--r-- | zellij-utils/assets/prost_ipc/client_server_contract.rs | 18 | ||||
| -rw-r--r-- | zellij-utils/src/cli.rs | 14 | ||||
| -rw-r--r-- | zellij-utils/src/client_server_contract/common_types.proto | 8 | ||||
| -rw-r--r-- | zellij-utils/src/data.rs | 6 | ||||
| -rw-r--r-- | zellij-utils/src/input/actions.rs | 14 | ||||
| -rw-r--r-- | zellij-utils/src/ipc/protobuf_conversion.rs | 47 | ||||
| -rw-r--r-- | zellij-utils/src/kdl/mod.rs | 30 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/action.proto | 12 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/action.rs | 37 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.proto | 26 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.rs | 62 |
13 files changed, 328 insertions, 28 deletions
diff --git a/zellij-utils/assets/prost/api.action.rs b/zellij-utils/assets/prost/api.action.rs index 61acbc50..1d2908a1 100644 --- a/zellij-utils/assets/prost/api.action.rs +++ b/zellij-utils/assets/prost/api.action.rs @@ -302,7 +302,7 @@ pub struct OverrideLayoutPayload { pub struct Action { #[prost(enumeration="ActionName", tag="1")] 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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57")] + #[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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59")] pub optional_payload: ::core::option::Option<action::OptionalPayload>, } /// Nested message and enum types in `Action`. @@ -416,6 +416,10 @@ pub mod action { CloseTabByIdPayload(u64), #[prost(message, tag="57")] RenameTabByIdPayload(super::TabIdAndName), + #[prost(message, tag="58")] + ShowFloatingPanesPayload(super::ShowFloatingPanesPayload), + #[prost(message, tag="59")] + HideFloatingPanesPayload(super::HideFloatingPanesPayload), } } #[allow(clippy::derive_partial_eq_without_eq)] @@ -448,6 +452,18 @@ pub struct TabIdAndName { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct ShowFloatingPanesPayload { + #[prost(uint32, optional, tag="1")] + pub tab_id: ::core::option::Option<u32>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HideFloatingPanesPayload { + #[prost(uint32, optional, tag="1")] + pub tab_id: ::core::option::Option<u32>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct PaneIdAndShouldFloat { #[prost(uint32, tag="1")] pub pane_id: u32, @@ -1084,6 +1100,8 @@ pub enum ActionName { GoToTabById = 95, CloseTabById = 96, RenameTabById = 97, + ShowFloatingPanes = 98, + HideFloatingPanes = 99, } impl ActionName { /// String value of the enum field names used in the ProtoBuf definition. @@ -1187,6 +1205,8 @@ impl ActionName { ActionName::GoToTabById => "GoToTabById", ActionName::CloseTabById => "CloseTabById", ActionName::RenameTabById => "RenameTabById", + ActionName::ShowFloatingPanes => "ShowFloatingPanes", + ActionName::HideFloatingPanes => "HideFloatingPanes", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1287,6 +1307,8 @@ impl ActionName { "GoToTabById" => Some(Self::GoToTabById), "CloseTabById" => Some(Self::CloseTabById), "RenameTabById" => Some(Self::RenameTabById), + "ShowFloatingPanes" => Some(Self::ShowFloatingPanes), + "HideFloatingPanes" => Some(Self::HideFloatingPanes), _ => None, } } diff --git a/zellij-utils/assets/prost/api.plugin_command.rs b/zellij-utils/assets/prost/api.plugin_command.rs index bab1d81b..d89da18b 100644 --- a/zellij-utils/assets/prost/api.plugin_command.rs +++ b/zellij-utils/assets/prost/api.plugin_command.rs @@ -3,7 +3,7 @@ pub struct PluginCommand { #[prost(enumeration="CommandName", tag="1")] pub name: i32, - #[prost(oneof="plugin_command::Payload", 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, 49, 50, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154")] + #[prost(oneof="plugin_command::Payload", 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, 49, 50, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156")] pub payload: ::core::option::Option<plugin_command::Payload>, } /// Nested message and enum types in `PluginCommand`. @@ -291,6 +291,10 @@ pub mod plugin_command { OpenTerminalPaneInPlaceOfPaneIdPayload(super::OpenTerminalPaneInPlaceOfPaneIdPayload), #[prost(message, tag="154")] OpenEditPaneInPlaceOfPaneIdPayload(super::OpenEditPaneInPlaceOfPaneIdPayload), + #[prost(message, tag="155")] + HideFloatingPanesPayload(super::HideFloatingPanesPayload), + #[prost(message, tag="156")] + ShowFloatingPanesPayload(super::ShowFloatingPanesPayload), } } #[allow(clippy::derive_partial_eq_without_eq)] @@ -1718,6 +1722,52 @@ pub struct OpenEditPaneInPlaceOfPaneIdResponse { #[prost(message, optional, tag="1")] pub pane_id: ::core::option::Option<PaneId>, } +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HideFloatingPanesPayload { + #[prost(uint32, optional, tag="1")] + pub tab_id: ::core::option::Option<u32>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ShowFloatingPanesPayload { + #[prost(uint32, optional, tag="1")] + pub tab_id: ::core::option::Option<u32>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ShowFloatingPanesResponse { + #[prost(oneof="show_floating_panes_response::Result", tags="1, 2")] + pub result: ::core::option::Option<show_floating_panes_response::Result>, +} +/// Nested message and enum types in `ShowFloatingPanesResponse`. +pub mod show_floating_panes_response { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(bool, tag="1")] + Success(bool), + #[prost(string, tag="2")] + Error(::prost::alloc::string::String), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HideFloatingPanesResponse { + #[prost(oneof="hide_floating_panes_response::Result", tags="1, 2")] + pub result: ::core::option::Option<hide_floating_panes_response::Result>, +} +/// Nested message and enum types in `HideFloatingPanesResponse`. +pub mod hide_floating_panes_response { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(bool, tag="1")] + Success(bool), + #[prost(string, tag="2")] + Error(::prost::alloc::string::String), + } +} #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum CommandName { @@ -1904,6 +1954,8 @@ pub enum CommandName { OpenCommandPaneInPlaceOfPaneId = 201, OpenTerminalPaneInPlaceOfPaneId = 202, OpenEditPaneInPlaceOfPaneId = 203, + HideFloatingPanes = 204, + ShowFloatingPanes = 205, } impl CommandName { /// String value of the enum field names used in the ProtoBuf definition. @@ -2095,6 +2147,8 @@ impl CommandName { CommandName::OpenCommandPaneInPlaceOfPaneId => "OpenCommandPaneInPlaceOfPaneId", CommandName::OpenTerminalPaneInPlaceOfPaneId => "OpenTerminalPaneInPlaceOfPaneId", CommandName::OpenEditPaneInPlaceOfPaneId => "OpenEditPaneInPlaceOfPaneId", + CommandName::HideFloatingPanes => "HideFloatingPanes", + CommandName::ShowFloatingPanes => "ShowFloatingPanes", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -2283,6 +2337,8 @@ impl CommandName { "OpenCommandPaneInPlaceOfPaneId" => Some(Self::OpenCommandPaneInPlaceOfPaneId), "OpenTerminalPaneInPlaceOfPaneId" => Some(Self::OpenTerminalPaneInPlaceOfPaneId), "OpenEditPaneInPlaceOfPaneId" => Some(Self::OpenEditPaneInPlaceOfPaneId), + "HideFloatingPanes" => Some(Self::HideFloatingPanes), + "ShowFloatingPanes" => Some(Self::ShowFloatingPanes), _ => None, } } diff --git a/zellij-utils/assets/prost_ipc/client_server_contract.rs b/zellij-utils/assets/prost_ipc/client_server_contract.rs index 5d58692f..c61229e9 100644 --- a/zellij-utils/assets/prost_ipc/client_server_contract.rs +++ b/zellij-utils/assets/prost_ipc/client_server_contract.rs @@ -119,7 +119,7 @@ pub struct RgbColor { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Action { - #[prost(oneof="action::ActionType", tags="1, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105")] + #[prost(oneof="action::ActionType", tags="1, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107")] pub action_type: ::core::option::Option<action::ActionType>, } /// Nested message and enum types in `Action`. @@ -337,6 +337,10 @@ pub mod action { ListTabs(super::ListTabsAction), #[prost(message, tag="105")] CurrentTabInfo(super::CurrentTabInfoAction), + #[prost(message, tag="106")] + ShowFloatingPanes(super::ShowFloatingPanesAction), + #[prost(message, tag="107")] + HideFloatingPanes(super::HideFloatingPanesAction), } } // Action message definitions (all 92 variants) @@ -432,6 +436,18 @@ pub struct ToggleFloatingPanesAction { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct ShowFloatingPanesAction { + #[prost(uint32, optional, tag="1")] + pub tab_id: ::core::option::Option<u32>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HideFloatingPanesAction { + #[prost(uint32, optional, tag="1")] + pub tab_id: ::core::option::Option<u32>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct CloseFocusAction { } #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index 7b64e147..f8bf79ac 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -905,6 +905,20 @@ pub enum CliAction { TogglePaneEmbedOrFloating, /// Toggle the visibility of all floating panes in the current Tab, open one if none exist ToggleFloatingPanes, + /// Show all floating panes in the specified tab (or active tab if tab_id is not provided). + /// + /// Returns exit code 0 if state was changed, 2 if already visible, 1 if tab not found. + ShowFloatingPanes { + #[clap(short, long, value_parser)] + tab_id: Option<usize>, + }, + /// Hide all floating panes in the specified tab (or active tab if tab_id is not provided). + /// + /// Returns exit code 0 if state was changed, 2 if already hidden, 1 if tab not found. + HideFloatingPanes { + #[clap(short, long, value_parser)] + tab_id: Option<usize>, + }, /// Close the focused pane. ClosePane, /// Renames the focused pane diff --git a/zellij-utils/src/client_server_contract/common_types.proto b/zellij-utils/src/client_server_contract/common_types.proto index 3a9e854b..46f1b812 100644 --- a/zellij-utils/src/client_server_contract/common_types.proto +++ b/zellij-utils/src/client_server_contract/common_types.proto @@ -241,6 +241,8 @@ message Action { RenameTabByIdAction rename_tab_by_id = 103; ListTabsAction list_tabs = 104; CurrentTabInfoAction current_tab_info = 105; + ShowFloatingPanesAction show_floating_panes = 106; + HideFloatingPanesAction hide_floating_panes = 107; } } @@ -269,6 +271,12 @@ message TogglePaneFramesAction {} message ToggleActiveSyncTabAction {} message TogglePaneEmbedOrFloatingAction {} message ToggleFloatingPanesAction {} +message ShowFloatingPanesAction { + optional uint32 tab_id = 1; +} +message HideFloatingPanesAction { + optional uint32 tab_id = 1; +} message CloseFocusAction {} message UndoRenamePaneAction {} message NoOpAction {} diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index 675cbcfe..74dfdfe7 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -3461,6 +3461,12 @@ pub enum PluginCommand { OpenCommandPaneInPlaceOfPaneId(PaneId, CommandToRun, bool, Context), // bool = close_replaced_pane OpenTerminalPaneInPlaceOfPaneId(PaneId, FileToOpen, bool), OpenEditPaneInPlaceOfPaneId(PaneId, FileToOpen, bool, Context), + HideFloatingPanes { + tab_id: Option<usize>, + }, + ShowFloatingPanes { + tab_id: Option<usize>, + }, } // Response type for plugin API methods that open a pane in a new tab diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index 025b0535..2841ea53 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -273,6 +273,14 @@ pub enum Action { TogglePaneEmbedOrFloating, /// Toggle the visibility of all floating panes (if any) in the current Tab ToggleFloatingPanes, + /// Show all floating panes in the specified tab (or active tab if tab_id is None) + ShowFloatingPanes { + tab_id: Option<usize>, + }, + /// Hide all floating panes in the specified tab (or active tab if tab_id is None) + HideFloatingPanes { + tab_id: Option<usize>, + }, /// Close the focus pane. CloseFocus, PaneNameInput { @@ -941,6 +949,12 @@ impl Action { CliAction::SwitchMode { input_mode } => Ok(vec![Action::SwitchToMode { input_mode }]), CliAction::TogglePaneEmbedOrFloating => Ok(vec![Action::TogglePaneEmbedOrFloating]), CliAction::ToggleFloatingPanes => Ok(vec![Action::ToggleFloatingPanes]), + CliAction::ShowFloatingPanes { tab_id } => { + Ok(vec![Action::ShowFloatingPanes { tab_id }]) + }, + CliAction::HideFloatingPanes { tab_id } => { + Ok(vec![Action::HideFloatingPanes { tab_id }]) + }, CliAction::ClosePane => Ok(vec![Action::CloseFocus]), CliAction::RenamePane { name } => Ok(vec