aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/plugin_api/plugin_command.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2025-06-26 13:51:17 +0200
committerGitHub <noreply@github.com>2025-06-26 13:51:17 +0200
commit11015c8fe4db1a8ffe77e0c569f0e026c53d9776 (patch)
tree82c8513128e4be58cf6ac991b9872c9b44be5b46 /zellij-utils/src/plugin_api/plugin_command.rs
parentdocs(changelog): terminal performance (diff)
downloadsl0ppij-11015c8fe4db1a8ffe77e0c569f0e026c53d9776.tar.gz
sl0ppij-11015c8fe4db1a8ffe77e0c569f0e026c53d9776.tar.xz
sl0ppij-11015c8fe4db1a8ffe77e0c569f0e026c53d9776.zip
feat(plugin-api): allow replacing pane with existing pane (#4246)
* work * make the api work * some cleanups * close pane * style(fmt): rustfmt
Diffstat (limited to 'zellij-utils/src/plugin_api/plugin_command.rs')
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.rs45
1 files changed, 36 insertions, 9 deletions
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs
index 7fb583b7..296a8a74 100644
--- a/zellij-utils/src/plugin_api/plugin_command.rs
+++ b/zellij-utils/src/plugin_api/plugin_command.rs
@@ -26,15 +26,15 @@ pub use super::generated_api::api::{
PaneIdAndFloatingPaneCoordinates, PaneType as ProtobufPaneType,
PluginCommand as ProtobufPluginCommand, PluginMessagePayload, RebindKeysPayload,
ReconfigurePayload, ReloadPluginPayload, RenameWebLoginTokenPayload,
- RenameWebTokenResponse, RequestPluginPermissionPayload, RerunCommandPanePayload,
- ResizePaneIdWithDirectionPayload, ResizePayload, RevokeAllWebTokensResponse,
- RevokeTokenResponse, RevokeWebLoginTokenPayload, RunCommandPayload,
- ScrollDownInPaneIdPayload, ScrollToBottomInPaneIdPayload, ScrollToTopInPaneIdPayload,
- ScrollUpInPaneIdPayload, SetFloatingPanePinnedPayload, SetSelfMouseSelectionSupportPayload,
- SetTimeoutPayload, ShowPaneWithIdPayload, StackPanesPayload, SubscribePayload,
- SwitchSessionPayload, SwitchTabToPayload, TogglePaneEmbedOrEjectForPaneIdPayload,
- TogglePaneIdFullscreenPayload, UnsubscribePayload, WebRequestPayload,
- WriteCharsToPaneIdPayload, WriteToPaneIdPayload,
+ RenameWebTokenResponse, ReplacePaneWithExistingPanePayload, RequestPluginPermissionPayload,
+ RerunCommandPanePayload, ResizePaneIdWithDirectionPayload, ResizePayload,
+ RevokeAllWebTokensResponse, RevokeTokenResponse, RevokeWebLoginTokenPayload,
+ RunCommandPayload, ScrollDownInPaneIdPayload, ScrollToBottomInPaneIdPayload,
+ ScrollToTopInPaneIdPayload, ScrollUpInPaneIdPayload, SetFloatingPanePinnedPayload,
+ SetSelfMouseSelectionSupportPayload, SetTimeoutPayload, ShowPaneWithIdPayload,
+ StackPanesPayload, SubscribePayload, SwitchSessionPayload, SwitchTabToPayload,
+ TogglePaneEmbedOrEjectForPaneIdPayload, TogglePaneIdFullscreenPayload, UnsubscribePayload,
+ WebRequestPayload, WriteCharsToPaneIdPayload, WriteToPaneIdPayload,
},
plugin_permission::PermissionType as ProtobufPermissionType,
resize::ResizeAction as ProtobufResizeAction,
@@ -1711,6 +1711,22 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
Some(_) => Err("ClearKeyPressesIntercepts should have no payload, found a payload"),
None => Ok(PluginCommand::ClearKeyPressesIntercepts),
},
+ Some(CommandName::ReplacePaneWithExistingPane) => match protobuf_plugin_command.payload
+ {
+ Some(Payload::ReplacePaneWithExistingPanePayload(
+ replace_pane_with_other_pane_payload,
+ )) => Ok(PluginCommand::ReplacePaneWithExistingPane(
+ replace_pane_with_other_pane_payload
+ .pane_id_to_replace
+ .and_then(|p_id| PaneId::try_from(p_id).ok())
+ .ok_or("Failed to parse ReplacePaneWithExistingPanePayload")?,
+ replace_pane_with_other_pane_payload
+ .existing_pane_id
+ .and_then(|p_id| PaneId::try_from(p_id).ok())
+ .ok_or("Failed to parse ReplacePaneWithExistingPanePayload")?,
+ )),
+ _ => Err("Mismatched payload for ReplacePaneWithExistingPane"),
+ },
None => Err("Unrecognized plugin command"),
}
}
@@ -2848,6 +2864,17 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
name: CommandName::ClearKeyPressesIntercepts as i32,
payload: None,
}),
+ PluginCommand::ReplacePaneWithExistingPane(pane_id_to_replace, existing_pane_id) => {
+ Ok(ProtobufPluginCommand {
+ name: CommandName::ReplacePaneWithExistingPane as i32,
+ payload: Some(Payload::ReplacePaneWithExistingPanePayload(
+ ReplacePaneWithExistingPanePayload {
+ pane_id_to_replace: ProtobufPaneId::try_from(pane_id_to_replace).ok(),
+ existing_pane_id: ProtobufPaneId::try_from(existing_pane_id).ok(),
+ },
+ )),
+ })
+ },
}
}
}