diff options
| author | Aram Drevekenin <aram@poor.dev> | 2025-01-30 17:04:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 17:04:36 +0100 |
| commit | c4cb9d3d8138346f3257fdcdd6a8f9967b88a402 (patch) | |
| tree | afafe8f7184e2c29bbfa1fe2f81d86c9d23a9fdc /zellij-utils/src/plugin_api/plugin_command.rs | |
| parent | docs(changelog): stacked resize (diff) | |
| download | sl0ppij-c4cb9d3d8138346f3257fdcdd6a8f9967b88a402.tar.gz sl0ppij-c4cb9d3d8138346f3257fdcdd6a8f9967b88a402.tar.xz sl0ppij-c4cb9d3d8138346f3257fdcdd6a8f9967b88a402.zip | |
feat(plugins): API to change floating pane coordinates (#3958)
* basic functionality through the cli
* added to plugin api
* add display area and viewport size to TabInfo
* fix tests and add new one
* some cleanups
* refactor: extract pane_id parsing logic
* style(fmt): rustfmt
Diffstat (limited to 'zellij-utils/src/plugin_api/plugin_command.rs')
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.rs | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index 2621502a..5eb634c2 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -4,9 +4,10 @@ pub use super::generated_api::api::{ input_mode::InputMode as ProtobufInputMode, plugin_command::{ plugin_command::Payload, BreakPanesToNewTabPayload, BreakPanesToTabWithIndexPayload, - ChangeHostFolderPayload, ClearScreenForPaneIdPayload, CliPipeOutputPayload, - CloseTabWithIndexPayload, CommandName, ContextItem, EditScrollbackForPaneWithIdPayload, - EnvVariable, ExecCmdPayload, FixedOrPercent as ProtobufFixedOrPercent, + ChangeFloatingPanesCoordinatesPayload, ChangeHostFolderPayload, + ClearScreenForPaneIdPayload, CliPipeOutputPayload, CloseTabWithIndexPayload, CommandName, + ContextItem, EditScrollbackForPaneWithIdPayload, EnvVariable, ExecCmdPayload, + FixedOrPercent as ProtobufFixedOrPercent, FixedOrPercentValue as ProtobufFixedOrPercentValue, FloatingPaneCoordinates as ProtobufFloatingPaneCoordinates, HidePaneWithIdPayload, HttpVerb as ProtobufHttpVerb, IdAndNewName, KeyToRebind, KeyToUnbind, KillSessionsPayload, @@ -14,8 +15,9 @@ pub use super::generated_api::api::{ MovePaneWithPaneIdPayload, MovePayload, NewPluginArgs as ProtobufNewPluginArgs, NewTabsWithLayoutInfoPayload, OpenCommandPanePayload, OpenFilePayload, PageScrollDownInPaneIdPayload, PageScrollUpInPaneIdPayload, PaneId as ProtobufPaneId, - PaneType as ProtobufPaneType, PluginCommand as ProtobufPluginCommand, PluginMessagePayload, - RebindKeysPayload, ReconfigurePayload, ReloadPluginPayload, RequestPluginPermissionPayload, + PaneIdAndFloatingPaneCoordinates, PaneType as ProtobufPaneType, + PluginCommand as ProtobufPluginCommand, PluginMessagePayload, RebindKeysPayload, + ReconfigurePayload, ReloadPluginPayload, RequestPluginPermissionPayload, RerunCommandPanePayload, ResizePaneIdWithDirectionPayload, ResizePayload, RunCommandPayload, ScrollDownInPaneIdPayload, ScrollToBottomInPaneIdPayload, ScrollToTopInPaneIdPayload, ScrollUpInPaneIdPayload, SetFloatingPanePinnedPayload, @@ -1339,7 +1341,26 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { .collect(), )) }, - _ => Err("Mismatched payload for SetFloatingPanePinned"), + _ => Err("Mismatched payload for StackPanes"), + }, + Some(CommandName::ChangeFloatingPanesCoordinates) => { + match protobuf_plugin_command.payload { + Some(Payload::ChangeFloatingPanesCoordinatesPayload( + change_floating_panes_coordinates_payload, + )) => Ok(PluginCommand::ChangeFloatingPanesCoordinates( + change_floating_panes_coordinates_payload + .pane_ids_and_floating_panes_coordinates + .into_iter() + .filter_map(|p_id_a_fp| { + let pane_id: PaneId = p_id_a_fp.pane_id?.try_into().ok()?; + let floating_pane_coordinates: FloatingPaneCoordinates = + p_id_a_fp.floating_pane_coordinates?.try_into().ok()?; + Some((pane_id, floating_pane_coordinates)) + }) + .collect(), + )), + _ => Err("Mismatched payload for ChangeFloatingPanesCoordinates"), + } }, None => Err("Unrecognized plugin command"), } @@ -2194,6 +2215,27 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { .collect(), })), }), + PluginCommand::ChangeFloatingPanesCoordinates( + pane_ids_and_floating_panes_coordinates, + ) => Ok(ProtobufPluginCommand { + name: CommandName::ChangeFloatingPanesCoordinates as i32, + payload: Some(Payload::ChangeFloatingPanesCoordinatesPayload( + ChangeFloatingPanesCoordinatesPayload { + pane_ids_and_floating_panes_coordinates: + pane_ids_and_floating_panes_coordinates + .into_iter() + .filter_map(|(p_id, floating_pane_coordinates)| { + Some(PaneIdAndFloatingPaneCoordinates { + pane_id: Some(p_id.try_into().ok()?), + floating_pane_coordinates: Some( + floating_pane_coordinates.try_into().ok()?, + ), + }) + }) + .collect(), + }, + )), + }), } } } |
