diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-02-10 10:42:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-10 10:42:46 +0100 |
| commit | 860e8e323a0d9b94280e1e25d0c626ff5bc03687 (patch) | |
| tree | 53b7bdccd075f93e93a7d93d8bb79878061aa000 /zellij-utils/src/data.rs | |
| parent | chore: Fix the issue template to match existing labels (#4637) (diff) | |
| download | sl0ppij-860e8e323a0d9b94280e1e25d0c626ff5bc03687.tar.gz sl0ppij-860e8e323a0d9b94280e1e25d0c626ff5bc03687.tar.xz sl0ppij-860e8e323a0d9b94280e1e25d0c626ff5bc03687.zip | |
Improve plugin API ergonomics and add CLI goodies (#4690)
* return created tab_id from relevant plugin API methods
* add to cli
* return Option<PaneId> in plugin API methods that create panes
* return created pane_id in cli for relevant actions
* allow plugins to query for pane_info based on pane_id
* allow plugins to query for TabInfo by its id
* allow plugins to query pane command/cwd synchronously
* zellij action list-panes
* style and formatting
* fix e2e tests
* add pr
Diffstat (limited to 'zellij-utils/src/data.rs')
| -rw-r--r-- | zellij-utils/src/data.rs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index fa4383df..c6e95f9e 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -2255,6 +2255,22 @@ pub struct PaneInfo { /// the index is kept track of in order to preserve the pane group order pub index_in_pane_group: BTreeMap<ClientId, usize>, } + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct PaneListEntry { + #[serde(flatten)] + pub pane_info: PaneInfo, + pub tab_id: usize, + pub tab_position: usize, + pub tab_name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub pane_command: Option<String>, + #[serde(skip_serializing_if = "Option::is_none")] + pub pane_cwd: Option<String>, +} + +pub type ListPanesResponse = Vec<PaneListEntry>; + #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] pub struct ClientInfo { pub client_id: ClientId, @@ -2462,6 +2478,18 @@ pub enum GetPanePidResponse { Err(String), } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub enum GetPaneRunningCommandResponse { + Ok(Vec<String>), + Err(String), +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub enum GetPaneCwdResponse { + Ok(PathBuf), + Err(String), +} + #[derive(Debug, Clone, PartialEq)] pub enum GetFocusedPaneInfoResponse { Ok { tab_index: usize, pane_id: PaneId }, @@ -2690,6 +2718,15 @@ impl FromStr for PaneId { } } +impl std::fmt::Display for PaneId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PaneId::Terminal(id) => write!(f, "terminal_{}", id), + PaneId::Plugin(id) => write!(f, "plugin_{}", id), + } + } +} + impl MessageToPlugin { pub fn new(message_name: impl Into<String>) -> Self { MessageToPlugin { @@ -3291,6 +3328,12 @@ pub enum PluginCommand { GetPanePid { pane_id: PaneId, }, + GetPaneRunningCommand { + pane_id: PaneId, + }, + GetPaneCwd { + pane_id: PaneId, + }, MovePaneWithPaneId(PaneId), MovePaneWithPaneIdInDirection(PaneId, Direction), ClearScreenForPaneId(PaneId), @@ -3392,4 +3435,36 @@ pub enum PluginCommand { GetFocusedPaneInfo, SaveSession, CurrentSessionLastSavedTime, + GetPaneInfo(PaneId), + GetTabInfo(usize), // tab_id } + +// Response types for plugin API methods that create tabs +pub type NewTabResponse = Option<usize>; +pub type NewTabsResponse = Vec<usize>; +pub type FocusOrCreateTabResponse = Option<usize>; +pub type BreakPanesToNewTabResponse = Option<usize>; +pub type BreakPanesToTabWithIndexResponse = Option<usize>; + +// Response types for plugin API methods that create panes +pub type OpenFileResponse = Option<PaneId>; +pub type OpenFileFloatingResponse = Option<PaneId>; +pub type OpenFileInPlaceResponse = Option<PaneId>; +pub type OpenFileNearPluginResponse = Option<PaneId>; +pub type OpenFileFloatingNearPluginResponse = Option<PaneId>; +pub type OpenFileInPlaceOfPluginResponse = Option<PaneId>; + +pub type OpenTerminalResponse = Option<PaneId>; +pub type OpenTerminalFloatingResponse = Option<PaneId>; +pub type OpenTerminalInPlaceResponse = Option<PaneId>; +pub type OpenTerminalNearPluginResponse = Option<PaneId>; +pub type OpenTerminalFloatingNearPluginResponse = Option<PaneId>; +pub type OpenTerminalInPlaceOfPluginResponse = Option<PaneId>; + +pub type OpenCommandPaneResponse = Option<PaneId>; +pub type OpenCommandPaneFloatingResponse = Option<PaneId>; +pub type OpenCommandPaneInPlaceResponse = Option<PaneId>; +pub type OpenCommandPaneNearPluginResponse = Option<PaneId>; +pub type OpenCommandPaneFloatingNearPluginResponse = Option<PaneId>; +pub type OpenCommandPaneInPlaceOfPluginResponse = Option<PaneId>; +pub type OpenCommandPaneBackgroundResponse = Option<PaneId>; |
