diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-09-16 21:02:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-16 21:02:04 +0200 |
| commit | d78f3586dd3de75b0ae6a71500b6f15a1ef8d71d (patch) | |
| tree | 6e12313db4515a03f7653c099d1239e34ae4eb86 /zellij-utils/src/plugin_api/plugin_command.rs | |
| parent | docs(readme): update sponsors (diff) | |
| download | sl0ppij-d78f3586dd3de75b0ae6a71500b6f15a1ef8d71d.tar.gz sl0ppij-d78f3586dd3de75b0ae6a71500b6f15a1ef8d71d.tar.xz sl0ppij-d78f3586dd3de75b0ae6a71500b6f15a1ef8d71d.zip | |
feat(plugins): APIs to break multiple panes into a new tab or an existing tab (#3610)
* feat(plugins): break multiple panes to a new tab
* fix(layouts): properly ignore run instructions when breaking panes
* feat(plugins): break multiple panes to existing tab
* feat(apis): allow these methods to also specify whether they want focus changed to the tab
* various fixes
* allow specifying name for the new tab when breaking out panes
* 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 | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index 155907d3..15c56d03 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -3,9 +3,10 @@ pub use super::generated_api::api::{ event::{EventNameList as ProtobufEventNameList, Header}, input_mode::InputMode as ProtobufInputMode, plugin_command::{ - plugin_command::Payload, ClearScreenForPaneIdPayload, CliPipeOutputPayload, - CloseTabWithIndexPayload, CommandName, ContextItem, EditScrollbackForPaneWithIdPayload, - EnvVariable, ExecCmdPayload, FixedOrPercent as ProtobufFixedOrPercent, + plugin_command::Payload, BreakPanesToNewTabPayload, BreakPanesToTabWithIndexPayload, + ClearScreenForPaneIdPayload, CliPipeOutputPayload, CloseTabWithIndexPayload, CommandName, + ContextItem, EditScrollbackForPaneWithIdPayload, EnvVariable, ExecCmdPayload, + FixedOrPercent as ProtobufFixedOrPercent, FixedOrPercentValue as ProtobufFixedOrPercentValue, FloatingPaneCoordinates as ProtobufFloatingPaneCoordinates, HidePaneWithIdPayload, HttpVerb as ProtobufHttpVerb, IdAndNewName, KillSessionsPayload, MessageToPluginPayload, @@ -1174,6 +1175,34 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { ), _ => Err("Mismatched payload for CloseTabWithIndex"), }, + Some(CommandName::BreakPanesToNewTab) => match protobuf_plugin_command.payload { + Some(Payload::BreakPanesToNewTabPayload(break_panes_to_new_tab_payload)) => { + Ok(PluginCommand::BreakPanesToNewTab( + break_panes_to_new_tab_payload + .pane_ids + .into_iter() + .filter_map(|p_id| p_id.try_into().ok()) + .collect(), + break_panes_to_new_tab_payload.new_tab_name, + break_panes_to_new_tab_payload.should_change_focus_to_new_tab, + )) + }, + _ => Err("Mismatched payload for BreakPanesToNewTab"), + }, + Some(CommandName::BreakPanesToTabWithIndex) => match protobuf_plugin_command.payload { + Some(Payload::BreakPanesToTabWithIndexPayload( + break_panes_to_tab_with_index_payload, + )) => Ok(PluginCommand::BreakPanesToTabWithIndex( + break_panes_to_tab_with_index_payload + .pane_ids + .into_iter() + .filter_map(|p_id| p_id.try_into().ok()) + .collect(), + break_panes_to_tab_with_index_payload.tab_index as usize, + break_panes_to_tab_with_index_payload.should_change_focus_to_target_tab, + )), + _ => Err("Mismatched payload for BreakPanesToTabWithIndex"), + }, None => Err("Unrecognized plugin command"), } } @@ -1922,6 +1951,40 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { }, )), }), + PluginCommand::BreakPanesToNewTab( + pane_ids, + new_tab_name, + should_change_focus_to_new_tab, + ) => Ok(ProtobufPluginCommand { + name: CommandName::BreakPanesToNewTab as i32, + payload: Some(Payload::BreakPanesToNewTabPayload( + BreakPanesToNewTabPayload { + pane_ids: pane_ids + .into_iter() + .filter_map(|p_id| p_id.try_into().ok()) + .collect(), + should_change_focus_to_new_tab, + new_tab_name, + }, + )), + }), + PluginCommand::BreakPanesToTabWithIndex( + pane_ids, + tab_index, + should_change_focus_to_target_tab, + ) => Ok(ProtobufPluginCommand { + name: CommandName::BreakPanesToTabWithIndex as i32, + payload: Some(Payload::BreakPanesToTabWithIndexPayload( + BreakPanesToTabWithIndexPayload { + pane_ids: pane_ids + .into_iter() + .filter_map(|p_id| p_id.try_into().ok()) + .collect(), + tab_index: tab_index as u32, + should_change_focus_to_target_tab, + }, + )), + }), } } } |
