diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-02-11 13:26:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-11 13:26:33 +0100 |
| commit | 13a82eea6d74d8168e538b8755131ed793a7f054 (patch) | |
| tree | bb8d2c1b6cd24bf46b84860360c48e6249e21ba1 /zellij-utils/src | |
| parent | Allow writing characters, bytes and keys to specific panes from the CLI (#4691) (diff) | |
| download | sl0ppij-13a82eea6d74d8168e538b8755131ed793a7f054.tar.gz sl0ppij-13a82eea6d74d8168e538b8755131ed793a7f054.tar.xz sl0ppij-13a82eea6d74d8168e538b8755131ed793a7f054.zip | |
CLI commands to query tab ids, names and info (#4695)
* add equivalent tab_id commands to tab_position commands (cli and plugins)
* add list-tabs and current-tab-info cli commands
* rustfmt
* add pr
Diffstat (limited to 'zellij-utils/src')
| -rw-r--r-- | zellij-utils/src/cli.rs | 49 | ||||
| -rw-r--r-- | zellij-utils/src/client_server_contract/common_types.proto | 29 | ||||
| -rw-r--r-- | zellij-utils/src/data.rs | 8 | ||||
| -rw-r--r-- | zellij-utils/src/errors.rs | 6 | ||||
| -rw-r--r-- | zellij-utils/src/input/actions.rs | 42 | ||||
| -rw-r--r-- | zellij-utils/src/ipc/protobuf_conversion.rs | 108 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/action.proto | 11 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/action.rs | 12 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.proto | 40 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.rs | 148 |
10 files changed, 400 insertions, 53 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index 376eafa1..6e99766c 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -884,6 +884,19 @@ pub enum CliAction { }, /// Remove a previously set tab name UndoRenameTab, + /// Go to tab with stable ID + GoToTabById { + id: u64, + }, + /// Close tab with stable ID + CloseTabById { + id: u64, + }, + /// Rename tab by stable ID + RenameTabById { + id: u64, + name: String, + }, /// Create a new tab, optionally with a specified tab layout and name /// /// Returns: The created tab's ID as a single number on stdout @@ -1143,6 +1156,42 @@ tail -f /tmp/my-live-logfile | zellij action pipe --name logs --plugin https://e #[clap(short, long, value_parser)] json: bool, }, + /// List all tabs with their information + /// + /// Returns: Tab information in table or JSON format + ListTabs { + /// Include state information (active, fullscreen, sync, floating visibility) + #[clap(short, long, value_parser)] + state: bool, + + /// Include dimension information (viewport, display area) + #[clap(short, long, value_parser)] + dimensions: bool, + + /// Include pane counts + #[clap(short, long, value_parser)] + panes: bool, + + /// Include layout information (swap layout name and dirty state) + #[clap(short, long, value_parser)] + layout: bool, + + /// Include all available fields + #[clap(short, long, value_parser)] + all: bool, + + /// Output as JSON + #[clap(short, long, value_parser)] + json: bool, + }, + /// Get information about the currently active tab + /// + /// Returns: Tab name and ID by default, or full info in JSON + CurrentTabInfo { + /// Output as JSON with full TabInfo + #[clap(short, long, value_parser)] + json: bool, + }, TogglePanePinned, /// Stack pane ids /// Ids are a space separated list of pane ids. diff --git a/zellij-utils/src/client_server_contract/common_types.proto b/zellij-utils/src/client_server_contract/common_types.proto index 2154dde4..512f52bd 100644 --- a/zellij-utils/src/client_server_contract/common_types.proto +++ b/zellij-utils/src/client_server_contract/common_types.proto @@ -236,6 +236,11 @@ message Action { ListPanesAction list_panes = 98; WriteCharsToPaneIdAction write_chars_to_pane_id = 99; WriteToPaneIdAction write_to_pane_id = 100; + GoToTabByIdAction go_to_tab_by_id = 101; + CloseTabByIdAction close_tab_by_id = 102; + RenameTabByIdAction rename_tab_by_id = 103; + ListTabsAction list_tabs = 104; + CurrentTabInfoAction current_tab_info = 105; } } @@ -307,6 +312,17 @@ message ListPanesAction { bool show_all = 5; bool output_json = 6; } +message ListTabsAction { + bool show_state = 1; + bool show_dimensions = 2; + bool show_panes = 3; + bool show_layout = 4; + bool show_all = 5; + bool output_json = 6; +} +message CurrentTabInfoAction { + bool output_json = 1; +} message TogglePanePinnedAction {} message TogglePaneInGroupAction {} message ToggleGroupMarkingAction {} @@ -558,6 +574,19 @@ message RenameTabAction { repeated uint32 name = 2; } +message GoToTabByIdAction { + uint64 id = 1; +} + +message CloseTabByIdAction { + uint64 id = 1; +} + +message RenameTabByIdAction { + uint64 id = 1; + string name = 2; +} + message RenameSessionAction { string name = 1; } diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index c6e95f9e..4ec7d654 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -2270,6 +2270,7 @@ pub struct PaneListEntry { } pub type ListPanesResponse = Vec<PaneListEntry>; +pub type ListTabsResponse = Vec<TabInfo>; #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] pub struct ClientInfo { @@ -3352,6 +3353,12 @@ pub enum PluginCommand { // the new tab BreakPanesToTabWithIndex(Vec<PaneId>, usize, bool), // usize - tab_index, bool - // should_change_focus_to_new_tab + SwitchTabToId(u64), // u64 - tab_id + GoToTabWithId(u64), // u64 - tab_id + CloseTabWithId(u64), // u64 - tab_id + RenameTabWithId(u64, String), // u64 - tab_id, String - new name + BreakPanesToTabWithId(Vec<PaneId>, u64, bool), // u64 - tab_id, bool - + // should_change_focus_to_target_tab ReloadPlugin(u32), // u32 - plugin pane id LoadNewPlugin { url: String, @@ -3445,6 +3452,7 @@ pub type NewTabsResponse = Vec<usize>; pub type FocusOrCreateTabResponse = Option<usize>; pub type BreakPanesToNewTabResponse = Option<usize>; pub type BreakPanesToTabWithIndexResponse = Option<usize>; +pub type BreakPanesToTabWithIdResponse = Option<usize>; // Response types for plugin API methods that create panes pub type OpenFileResponse = Option<PaneId>; diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs index 06bb6801..3b5822a8 100644 --- a/zellij-utils/src/errors.rs +++ b/zellij-utils/src/errors.rs @@ -297,6 +297,10 @@ pub enum ScreenContext { UndoRenameTab, MoveTabLeft, MoveTabRight, + GoToTabWithId, + CloseTabWithId, + RenameTabWithId, + BreakPanesToTabWithId, TerminalResize, TerminalPixelDimensions, TerminalBackgroundColor, @@ -359,6 +363,8 @@ pub enum ScreenContext { GetTabInfo, ListClientsMetadata, ListPanes, + ListTabs, + GetCurrentTabInfo, Reconfigure, RerunCommandPane, ResizePaneWithId, diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index bf77fe4d..f53a5c69 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -432,6 +432,16 @@ pub enum Action { tab_index: u32, name: Vec<u8>, }, + GoToTabById { + id: u64, + }, + CloseTabById { + id: u64, + }, + RenameTabById { + id: u64, + name: String, + }, BreakPane, BreakPaneRight, BreakPaneLeft, @@ -475,6 +485,17 @@ pub enum Action { show_all: bool, output_json: bool, }, + ListTabs { + show_state: bool, + show_dimensions: bool, + show_panes: bool, + show_layout: bool, + show_all: bool, + output_json: bool, + }, + CurrentTabInfo { + output_json: bool, + }, TogglePanePinned, StackPanes { pane_ids: Vec<PaneId>, @@ -933,6 +954,9 @@ impl Action { }, ]), CliAction::UndoRenameTab => Ok(vec![Action::UndoRenameTab]), + CliAction::GoToTabById { id } => Ok(vec![Action::GoToTabById { id }]), + CliAction::CloseTabById { id } => Ok(vec![Action::CloseTabById { id }]), + CliAction::RenameTabById { id, name } => Ok(vec![Action::RenameTabById { id, name }]), CliAction::NewTab { name, layout, @@ -1331,6 +1355,24 @@ impl Action { show_all: all, output_json: json, }]), + CliAction::ListTabs { + state, + dimensions, + panes, + layout, + all, + json, + } => Ok(vec![Action::ListTabs { + show_state: state, + show_dimensions: dimensions, + show_panes: panes, + show_layout: layout, + show_all: all, + output_json: json, + }]), + CliAction::CurrentTabInfo { json } => { + Ok(vec![Action::CurrentTabInfo { output_json: json }]) + }, CliAction::TogglePanePinned => Ok(vec![Action::TogglePanePinned]), CliAction::StackPanes { pane_ids } => { let mut malformed_ids = vec![]; diff --git a/zellij-utils/src/ipc/protobuf_conversion.rs b/zellij-utils/src/ipc/protobuf_conversion.rs index 3c127e78..656be5db 100644 --- a/zellij-utils/src/ipc/protobuf_conversion.rs +++ b/zellij-utils/src/ipc/protobuf_conversion.rs @@ -717,32 +717,32 @@ impl From<crate::input::actions::Action> use crate::client_server_contract::client_server_contract::{ action::ActionType, BreakPaneAction, BreakPaneLeftAction, BreakPaneRightAction, ChangeFloatingPaneCoordinatesAction, ClearScreenAction, CliPipeAction, - CloseFocusAction, ClosePluginPaneAction, CloseTabAction, CloseTerminalPaneAction, - ConfirmAction, CopyAction, DenyAction, DetachAction, DumpLayoutAction, - DumpScreenAction, EditFileAction, EditScrollbackAction, FocusNextPaneAction, - FocusPluginPaneWithIdAction, FocusPreviousPaneAction, FocusTerminalPaneWithIdAction, - GoToNextTabAction, GoToPreviousTabAction, GoToTabAction, GoToTabNameAction, - HalfPageScrollDownAction, HalfPageScrollUpAction, KeybindPipeAction, - LaunchOrFocusPluginAction, LaunchPluginAction, ListClientsAction, ListPanesAction, - MouseEventAction, MoveFocusAction, MoveFocusOrTabAction, MovePaneAction, - MovePaneBackwardsAction, MoveTabAction, NewBlockingPaneAction, NewFloatingPaneAction, - NewFloatingPluginPaneAction, NewInPlacePaneAction, NewInPlacePluginPaneAction, - NewPaneAction, NewStackedPaneAction, NewTabAction, NewTiledPaneAction, - NewTiledPluginPaneAction, NextSwapLayoutAction, NoOpAction, OverrideLayoutAction, - PageScrollDownAction, PageScrollUpAction, PaneIdWithPlugin, PaneNameInputAction, - PreviousSwapLayoutAction, QueryTabNamesAction, QuitAction, RenamePluginPaneAction, - RenameSessionAction, RenameTabAction, RenameTerminalPaneAction, ResizeAction, - RunAction, SaveSessionAction, ScrollDownAction, ScrollDownAtAction, - ScrollToBottomAction, ScrollToTopAction, ScrollUpAction, ScrollUpAtAction, - SearchAction, SearchInputAction, SearchToggleOptionAction, SetPaneBorderlessAction, - SkipConfirmAction, StackPanesAction, StartOrReloadPluginAction, SwitchFocusAction, - SwitchModeForAllClientsAction, SwitchSessionAction, SwitchToModeAction, - TabNameInputAction, ToggleActiveSyncTabAction, ToggleFloatingPanesAction, - ToggleFocusFullscreenAction, ToggleGroupMarkingAction, ToggleMouseModeAction, - TogglePaneBorderlessAction, TogglePaneEmbedOrFloatingAction, TogglePaneFramesAction, - TogglePaneInGroupAction, TogglePanePinnedAction, ToggleTabAction, UndoRenamePaneAction, - UndoRenameTabAction, WriteAction, WriteCharsAction, WriteCharsToPaneIdAction, - WriteToPaneIdAction, + CloseFocusAction, ClosePluginPaneAction, CloseTabAction, CloseTabByIdAction, + CloseTerminalPaneAction, ConfirmAction, CopyAction, CurrentTabInfoAction, DenyAction, + DetachAction, DumpLayoutAction, DumpScreenAction, EditFileAction, EditScrollbackAction, + FocusNextPaneAction, FocusPluginPaneWithIdAction, FocusPreviousPaneAction, + FocusTerminalPaneWithIdAction, GoToNextTabAction, GoToPreviousTabAction, GoToTabAction, + GoToTabByIdAction, GoToTabNameAction, HalfPageScrollDownAction, HalfPageScrollUpAction, + KeybindPipeAction, LaunchOrFocusPluginAction, LaunchPluginAction, ListClientsAction, + ListPanesAction, ListTabsAction, MouseEventAction, MoveFocusAction, + MoveFocusOrTabAction, MovePaneAction, MovePaneBackwardsAction, MoveTabAction, + NewBlockingPaneAction, NewFloatingPaneAction, NewFloatingPluginPaneAction, + NewInPlacePaneAction, NewInPlacePluginPaneAction, NewPaneAction, NewStackedPaneAction, + NewTabAction, NewTiledPaneAction, NewTiledPluginPaneAction, NextSwapLayoutAction, + NoOpAction, OverrideLayoutAction, PageScrollDownAction, PageScrollUpAction, + PaneIdWithPlugin, PaneNameInputAction, PreviousSwapLayoutAction, QueryTabNamesAction, + QuitAction, RenamePluginPaneAction, RenameSessionAction, RenameTabAction, + RenameTabByIdAction, RenameTerminalPaneAction, ResizeAction, RunAction, + SaveSessionAction, ScrollDownAction, ScrollDownAtAction, ScrollToBottomAction, + ScrollToTopAction, ScrollUpAction, ScrollUpAtAction, SearchAction, SearchInputAction, + SearchToggleOptionAction, SetPaneBorderlessAction, SkipConfirmAction, StackPanesAction, + StartOrReloadPluginAction, SwitchFocusAction, SwitchModeForAllClientsAction, + SwitchSessionAction, SwitchToModeAction, TabNameInputAction, ToggleActiveSyncTabAction, + ToggleFloatingPanesAction, ToggleFocusFullscreenAction, ToggleGroupMarkingAction, + ToggleMouseModeAction, TogglePaneBorderlessAction, TogglePaneEmbedOrFloatingAction, + TogglePaneFramesAction, TogglePaneInGroupAction, TogglePanePinnedAction, + ToggleTabAction, UndoRenamePaneAction, UndoRenameTabAction, WriteAction, + WriteCharsAction, WriteCharsToPaneIdAction, WriteToPaneIdAction, }; use std::collections::HashMap; @@ -1212,6 +1212,15 @@ impl From<crate::input::actions::Action> name: name.into_iter().map(|b| b as u32).collect(), }) }, + crate::input::actions::Action::GoToTabById { id } => { + ActionType::GoToTabById(GoToTabByIdAction { id }) + }, + crate::input::actions::Action::CloseTabById { id } => { + ActionType::CloseTabById(CloseTabByIdAction { id }) + }, + crate::input::actions::Action::RenameTabById { id, name } => { + ActionType::RenameTabById(RenameTabByIdAction { id, name }) + }, crate::input::actions::Action::BreakPane => ActionType::BreakPane(BreakPaneAction {}), crate::input::actions::Action::BreakPaneRight => { ActionType::BreakPaneRight(BreakPaneRightAction {}) @@ -1338,6 +1347,24 @@ impl From<crate::input::actions::Action> crate::input::actions::Action::SaveSession => { ActionType::SaveSession(SaveSessionAction {}) }, + crate::input::actions::Action::ListTabs { + show_state, + show_dimensions, + show_panes, + show_layout, + show_all, + output_json, + } => ActionType::ListTabs(ListTabsAction { + show_state, + show_dimensions, + show_panes, + show_layout, + show_all, + output_json, + }), + crate::input::actions::Action::CurrentTabInfo { output_json } => { + ActionType::CurrentTabInfo(CurrentTabInfoAction { output_json }) + }, }; Self { @@ -1871,6 +1898,22 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> .collect(), }) }, + ActionType::GoToTabById(go_to_tab_by_id_action) => { + Ok(crate::input::actions::Action::GoToTabById { + id: go_to_tab_by_id_action.id, + }) + }, + ActionType::CloseTabById(close_tab_by_id_action) => { + Ok(crate::input::actions::Action::CloseTabById { + id: close_tab_by_id_action.id, + }) + }, + ActionType::RenameTabById(rename_tab_by_id_action) => { + Ok(crate::input::actions::Action::RenameTabById { + id: rename_tab_by_id_action.id, + name: rename_tab_by_id_action.name, + }) + }, ActionType::BreakPane(_) => Ok(crate::input::actions::Action::BreakPane), ActionType::BreakPaneRight(_) => Ok(crate::input::actions::Action::BreakPaneRight), ActionType::BreakPaneLeft(_) => Ok(crate::input::actions::Action::BreakPaneLeft), @@ -1936,6 +1979,19 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> output_json: list_panes_action.output_json, }) }, + ActionType::ListTabs(list_tabs_action) => Ok(crate::input::actions::Action::ListTabs { + show_state: list_tabs_action.show_state, + show_dimensions: list_tabs_action.show_dimensions, + show_panes: list_tabs_action.show_panes, + show_layout: list_tabs_action.show_layout, + show_all: list_tabs_action.show_all, + output_json: list_tabs_action.output_json, + }), + ActionType::CurrentTabInfo(current_tab_info_action) => { + Ok(crate::input::actions::Action::CurrentTabInfo { + output_json: current_tab_info_action.output_json, + }) + }, ActionType::TogglePanePinned(_) => Ok(crate::input::actions::Action::TogglePanePinned), ActionType::StackPanes(stack_panes_action) => { Ok(crate::input::actions::Action::StackPanes { diff --git a/zellij-utils/src/plugin_api/action.proto b/zellij-utils/src/plugin_api/action.proto index 802d0a0e..83181097 100644 --- a/zellij-utils/src/plugin_api/action.proto +++ b/zellij-utils/src/plugin_api/action.proto @@ -232,6 +232,9 @@ message Action { NewInPlacePanePayload new_in_place_pane_payload = 52; OverrideLayoutPayload override_layout_payload = 53; SetPaneBorderlessPayload set_pane_borderless_payload = 54; + uint64 go_to_tab_by_id_payload = 55; + uint64 close_tab_by_id_payload = 56; + TabIdAndName rename_tab_by_id_payload = 57; } } @@ -247,6 +250,11 @@ message IdAndName { uint32 id = 2; } +message TabIdAndName { + uint64 tab_id = 1; + string name = 2; +} + message PaneIdAndShouldFloat { uint32 pane_id = 1; bool should_float = 2; @@ -451,6 +459,9 @@ enum ActionName { NewInPlacePane = 92; OverrideLayout = 93; SetPaneBorderless = 94; + GoToTabById = 95; + CloseTabById = 96; + RenameTabById = 97; } message Position { diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs index 92dc618c..047244d7 100644 --- a/zellij-utils/src/plugin_api/action.rs +++ b/zellij-utils/src/plugin_api/action.rs @@ -1030,8 +1030,12 @@ impl TryFrom<Action> for ProtobufAction { chars: chars_to_write, })), }), - Action::WriteToPaneId { .. } | Action::WriteCharsToPaneId { .. } => { - Err("WriteToPaneId and WriteCharsToPaneId are CLI-only actions, not available in keybindings") + Action::WriteToPaneId { .. } + | Action::WriteCharsToPaneId { .. } + | Action::GoToTabById { .. } + | Action::CloseTabById { .. } + | Action::RenameTabById { .. } => { + Err("WriteToPaneId, WriteCharsToPaneId, GoToTabById, CloseTabById, and RenameTabById are CLI-only actions, not available in keybindings") }, Action::SwitchToMode { input_mode } => { let input_mode: ProtobufInputMode = input_mode.try_into()?; @@ -1782,7 +1786,9 @@ impl TryFrom<Action> for ProtobufAction { | Action::SetPaneBorderless { .. } | Action::SkipConfirm { action: _ } | Action::SwitchSession { .. } - | Action::SaveSession => Err("Unsupported action"), + | Action::SaveSession + | Action::ListTabs { .. } + | Action::CurrentTabInfo { .. } => Err("Unsupported action"), } } } diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto index b450c13f..a2a25f99 100644 --- a/zellij-utils/src/plugin_api/plugin_command.proto +++ b/zellij-utils/src/plugin_api/plugin_command.proto @@ -184,6 +184,11 @@ enum CommandName { GetTabInfo = 189; GetPaneRunningCommand = 190; GetPaneCwd = 191; + SwitchTabToId = 192; + GoToTabWithId = 193; + CloseTabWithId = 194; + RenameTabWithId = 195; + BreakPanesToTabWithId = 196; } message PluginCommand { @@ -317,6 +322,11 @@ message PluginCommand { GetTabInfoPayload get_tab_info_payload = 140; GetPaneRunningCommandPayload get_pane_running_command_payload = 141; GetPaneCwdPayload get_pane_cwd_payload = 142; + SwitchTabToIdPayload switch_tab_to_id_payload = 143; + GoToTabWithIdPayload go_to_tab_with_id_payload = 144; + CloseTabWithIdPayload close_tab_with_id_payload = 145; + RenameTabWithIdPayload rename_tab_with_id_payload = 146; + BreakPanesToTabWithIdPayload break_panes_to_tab_with_id_payload = 147; } } @@ -749,6 +759,36 @@ enum FixedOrPercent { Percent = 1; } +message SwitchTabToIdPayload { + uint64 tab_id = 1; +} + +message GoToTabWithIdPayload { + uint64 tab_id = 1; +} + +message CloseTabWithIdPayload { + uint64 tab_id = 1; +} + +message RenameTabWithIdPayload { + uint64 tab_id = 1; + string new_name = 2; +} + +message BreakPanesToTabWithIdPayload { + repeated PaneId pane_ids = 1; + uint64 tab_id = 2; + bool should_change_focus_to_target_tab = 3; +} + +message BreakPanesToTabWithIdResponse { + oneof result { + uint64 tab_id = 1; + bool none = 2; + } +} + message CreateTokenResponse { optional string token = 1; optional string token_label = 2; diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index 7871d15f..6ade3376 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -3,20 +3,23 @@ pub use super::generated_api::api::{ event::{EventNameList as ProtobufEventNameList, Header}, input_mode::InputMode as ProtobufInputMode, plugin_command::{ - break_panes_to_new_tab_response, break_panes_to_tab_with_index_response, - delete_layout_response, dump_layout_response, dump_session_layout_response, - edit_layout_response, focus_or_create_tab_response, get_focused_pane_info_response, - get_pane_cwd_response, get_pane_pid_response, get_pane_running_command_response, - new_tab_response, parse_layout_response, plugin_command::Payload, rename_layout_response, - save_layout_response, save_session_response, BreakPanesToNewTabPayload, + break_panes_to_new_tab_response, break_panes_to_tab_with_id_response, + break_panes_to_tab_with_index_response, delete_layout_response, dump_layout_response, + dump_session_layout_response, edit_layout_response, focus_or_create_tab_response, + get_focused_pane_info_response, get_pane_cwd_response, get_pane_pid_response, + get_pane_running_command_response, new_tab_response, parse_layout_response, + plugin_command::Payload, rename_layout_response, save_layout_response, + save_session_response, BreakPanesToNewTabPayload, BreakPanesToNewTabResponse as ProtobufBreakPanesToNewTabResponse, + BreakPanesToTabWithIdPayload, + BreakPanesToTabWithIdResponse as ProtobufBreakPanesToTabWithIdResponse, BreakPanesToTabWithIndexPayload, BreakPanesToTabWithIndexResponse as ProtobufBreakPanesToTabWithIndexResponse, ChangeFloatingPanesCoordinatesPayload, ChangeHostFolderPayload, ClearScreenForPaneIdPayload, CliPipeOutputPayload, CloseMultiplePanesPayload, - CloseTabWithIndexPayload, CommandName, ContextItem, CopyToClipboardPayload, - CreateTokenResponse as ProtobufCreateTokenResponse, CreateTokenResponse, - CurrentSessionLastSavedTimePayload, + CloseTabWithIdPayload, CloseTabWithIndexPayload, CommandName, ContextItem, + CopyToClipboardPayload, CreateTokenResponse as ProtobufCreateTokenResponse, + CreateTokenResponse, CurrentSessionLastSavedTimePayload, CurrentSessionLastSavedTimeResponse as ProtobufCurrentSessionLastSavedTimeResponse, CursorPosition, DeleteLayoutPayload, DeleteLayoutResponse as ProtobufDeleteLayoutResponse, DumpLayoutPayload, DumpLayoutResponse as ProtobufDumpLayoutResponse, @@ -39,13 +42,14 @@ pub use super::generated_api::api::{ GetPaneRunningCommandPayload as ProtobufGetPaneRunningCommandPayload, GetPaneRunningCommandResponse as ProtobufGetPaneRunningCommandResponse, GetPaneScrollbackPayload, GetTabInfoPayload, - GetTabInfoResponse as ProtobufGetTabInfoResponse, GroupAndUngroupPanesPayload, - HidePaneWithIdPayload, HighlightAndUnhighlightPanesPayload, HttpVerb as ProtobufHttpVerb, - IdAndNewName, KeyToRebind, KeyToUnbind, KillSessionsPayload, ListTokensResponse, - LoadNewPluginPayload, MessageToPluginPayload, MovePaneWithPaneIdInDirectionPayload, - MovePaneWithPaneIdPayload, MovePayload, NewPluginArgs as ProtobufNewPluginArgs, - NewTabPayload, NewTabResponse as ProtobufNewTabResponse, - NewTabsResponse as ProtobufNewTabsResponse, NewTabsWithLayoutInfoPayload, + GetTabInfoResponse as ProtobufGetTabInfoResponse, GoToTabWithIdPayload, + GroupAndUngroupPanesPayload, HidePaneWithIdPayload, HighlightAndUnhighlightPanesPayload, + HttpVerb as ProtobufHttpVerb, IdAndNewName, KeyToRebind, KeyToUnbind, KillSessionsPayload, + ListTokensResponse, LoadNewPluginPayload, MessageToPluginPayload, + MovePaneWithPaneIdInDirectionPayload, MovePaneWithPaneIdPayload, MovePayload, + NewPluginArgs as ProtobufNewPluginArgs, NewTabPayload, + NewTabResponse as ProtobufNewTabResponse, NewTabsResponse as ProtobufNewTabsResponse, + NewTabsWithLayoutInfoPayload, OpenCommandPaneBackgroundResponse as ProtobufOpenCommandPaneBackgroundResponse, OpenCommandPaneFloatingNearPluginPayload, OpenCommandPaneFloatingNearPluginResponse as ProtobufOpenCommandPaneFloatingNearPluginResponse, @@ -77,9 +81,10 @@ pub use super::generated_api::api::{ ParseLayoutResponse as ProtobufParseLayoutResponse, PluginCommand as ProtobufPluginCommand, PluginMessagePayload, RebindKeysPayload, ReconfigurePayload, ReloadPluginPayload, RenameLayoutPayload, RenameLayoutResponse as ProtobufRenameLayoutResponse, - RenameWebLoginTokenPayload, RenameWebTokenResponse, ReplacePaneWithExistingPanePayload, - RequestPluginPermissionPayload, RerunCommandPanePayload, ResizePaneIdWithDirectionPayload, - ResizePayload, RevokeAllWebTokensResponse, RevokeTokenResponse, RevokeWebLoginTokenPayload, + RenameTabWithIdPayload, RenameWebLoginTokenPayload, RenameWebTokenResponse, + ReplacePaneWithExistingPanePayload, RequestPluginPermissionPayload, + RerunCommandPanePayload, ResizePaneIdWithDirectionPayload, ResizePayload, + RevokeAllWebTokensResponse, RevokeTokenResponse, RevokeWebLoginTokenPayload, RunActionPayload, RunCommandPayload, RunningCommand as ProtobufRunningCommand, SaveLayoutPayload, SaveLayoutResponse as ProtobufSaveLayoutResponse, SaveSessionPayload, SaveSessionResponse as ProtobufSaveSessionResponse, ScrollDownInPaneIdPayload, @@ -87,9 +92,9 @@ pub use super::generated_api::api::{ SetFloatingPanePinnedPayload, SetPaneBorderlessPayload, SetSelfMouseSelectionSupportPayload, SetTimeoutPayload, ShowCursorPayload, ShowPaneWithIdPayload, StackPanesPayload, SubscribePayload, SwitchSessionPayload, - SwitchTabToPayload, TogglePaneBorderlessPayload, TogglePaneEmbedOrEjectForPaneIdPayload, - TogglePaneIdFullscreenPayload, UnsubscribePayload, WebRequestPayload, - WriteCharsToPaneIdPayload, WriteToPaneIdPayload, + SwitchTabToIdPayload, SwitchTabToPayload, TogglePaneBorderlessPayload, + TogglePaneEmbedOrEjectForPaneIdPayload, TogglePaneIdFullscreenPayload, UnsubscribePayload, + WebRequestPayload, WriteCharsToPaneIdPayload, WriteToPaneIdPayload, }, plugin_permission::PermissionType as ProtobufPermissionType, resize::ResizeAction as ProtobufResizeAction, @@ -1679,6 +1684,44 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { )), _ => Err("Mismatched payload for BreakPanesToTabWithIndex"), }, + Some(CommandName::SwitchTabToId) => match protobuf_plugin_command.payload { + Some(Payload::SwitchTabToIdPayload(payload)) => { + Ok(PluginCommand::SwitchTabToId(payload.tab_id)) + }, + _ => Err("Mismatched payload for SwitchTabToId"), + }, + Some(CommandName::GoToTabWithId) => match protobuf_plugin_command.payload { + Some(Payload::GoToTabWithIdPayload(payload)) => { + Ok(PluginCommand::GoToTabWithId(payload.tab_id)) + }, + _ => Err("Mismatched payload for GoToTabWithId"), + }, + Some(CommandName::CloseTabWithId) => match protobuf_plugin_command.payload { + Some(Payload::CloseTabWithIdPayload(payload)) => { + Ok(PluginCommand::CloseTabWithId(payload.tab_id)) + }, + _ => Err("Mismatched payload for CloseTabWithId"), + }, + Some(CommandName::RenameTabWithId) => match protobuf_plugin_command.payload { + Some(Payload::RenameTabWithIdPayload(payload)) => Ok( + PluginCommand::RenameTabWithId(payload.tab_id, payload.new_name), + ), + _ => Err("Mismatched payload for RenameTabWithId"), + }, + Some(CommandName::BreakPanesToTabWithId) => match protobuf_plugin_command.payload { + Some(Payload::BreakPanesToTabWithIdPayload(payload)) => { + Ok(PluginCommand::BreakPanesToTabWithId( + payload + .pane_ids + .into_iter() + .filter_map(|p_id| p_id.try_into().ok()) + .collect(), + payload.tab_id, + payload.should_change_focus_to_target_tab, + )) + }, + _ => Err("Mismatched payload for BreakPanesToTabWithId"), + }, Some(CommandName::ReloadPlugin) => match protobuf_plugin_command.payload { Some(Payload::ReloadPluginPayload(reload_plugin_payload)) => { Ok(PluginCommand::ReloadPlugin(reload_plugin_payload.plugin_id)) @@ -3128,6 +3171,48 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { }, )), }), + PluginCommand::SwitchTabToId(tab_id) => Ok(ProtobufPluginCommand { + name: CommandName::SwitchTabToId as i32, + payload: Some(Payload::SwitchTabToIdPayload(SwitchTabToIdPayload { + tab_id, + })), + }), + PluginCommand::GoToTabWithId(tab_id) => Ok(ProtobufPluginCommand { + name: CommandName::GoToTabWithId as i32, + payload: Some(Payload::GoToTabWithIdPayload(GoToTabWithIdPayload { + tab_id, + })), + }), + PluginCommand::CloseTabWithId(tab_id) => Ok(ProtobufPluginCommand { + name: CommandName::CloseTabWithId as i32, + payload: Some(Payload::CloseTabWithIdPayload(CloseTabWithIdPayload { + tab_id, + })), + }), + PluginCommand::RenameTabWithId(tab_id, new_name) => Ok(ProtobufPluginCommand { + name: CommandName::RenameTabWithId as i32, + payload: Some(Payload::RenameTabWithIdPayload(RenameTabWithIdPayload { + tab_id, + new_name, + })), + }), + PluginCommand::BreakPanesToTabWithId( + pane_ids, + tab_id, + should_change_focus_to_target_tab, + ) => Ok(ProtobufPluginCommand { + name: CommandName::BreakPanesToTabWithId as i32, + payload: Some(Payload::BreakPanesToTabWithIdPayload( + BreakPanesToTabWithIdPayload { + pane_ids: pane_ids + .into_iter() + .filter_map(|p_id| p_id.try_into().ok()) + .collect(), + tab_id, + should_change_focus_to_target_tab, + }, + )), + }), PluginCommand::ReloadPlugin(plugin_id) => Ok(ProtobufPluginCommand { name: CommandName::ReloadPlugin as i32, payload: Some(Payload::ReloadPluginPayload(ReloadPluginPayload { @@ -3601,8 +3686,8 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { // Conversion implementations for tab creation response types use crate::data::{ - BreakPanesToNewTabResponse, BreakPanesToTabWithIndexResponse, FocusOrCreateTabResponse, - NewTabResponse, NewTabsResponse, OpenCommandPaneBackgroundResponse, + BreakPanesToNewTabResponse, BreakPanesToTabWithIdResponse, BreakPanesToTabWithIndexResponse, + FocusOrCreateTabResponse, NewTabResponse, NewTabsResponse, OpenCommandPaneBackgroundResponse, OpenCommandPaneFloatingNearPluginResponse, OpenCommandPaneFloatingResponse, OpenCommandPaneInPlaceOfPluginResponse, OpenCommandPaneInPlaceResponse, OpenCommandPaneNearPluginResponse, OpenCommandPaneResponse, OpenFileFloatingNearPluginResponse, @@ -3725,6 +3810,21 @@ impl From<BreakPanesToTabWithIndexResponse> for ProtobufBreakPanesToTabWithIndex } } +impl From<BreakPanesToTabWithIdResponse> for ProtobufBreakPanesToTabWithIdResponse { + fn from(response: BreakPanesToTabWithIdResponse) -> Self { + match response { + Some(tab_id) => ProtobufBreakPanesToTabWithIdResponse { + result: Some(break_panes_to_tab_with_id_response::Result::TabId( + tab_id as u64, + )), + }, + None => ProtobufBreakPanesToTabWithIdResponse { + result: Some(break_panes_to_tab_with_id_response::Result::None(true)), + }, + } + } +} + // Pane-creating command response conversions impl TryFrom<ProtobufOpenFileResponse> for OpenFileResponse { |
