diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-02-06 14:26:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-06 14:26:14 +0100 |
| commit | 6b20a958f4e8db5614fffb27fe5d32f07ddfe855 (patch) | |
| tree | c8383fb7941b5e0c23cb348a655f2ea0fafd8668 /zellij-utils/src/plugin_api/plugin_command.rs | |
| parent | docs(readme): add sponsor (diff) | |
| download | sl0ppij-6b20a958f4e8db5614fffb27fe5d32f07ddfe855.tar.gz sl0ppij-6b20a958f4e8db5614fffb27fe5d32f07ddfe855.tar.xz sl0ppij-6b20a958f4e8db5614fffb27fe5d32f07ddfe855.zip | |
feat(sessions): welcome screen (#3112)
* prototype - can send layout name for new session from session-manager
* feat(sessions): ui for selecting layout for new session in the session-manager
* fix: send available layouts to plugins
* make tests compile
* fix tests
* improve ui
* fix: respect built-in layouts
* ui for built-in layouts
* some cleanups
* style(fmt): rustfmt
* welcome screen ui
* fix: make sure layout config is not shared between sessions
* allow disconnecting other users from current session and killing other sessions
* fix: respect default layout
* add welcome screen layout
* tests(plugins): new api methods
* fix(session-manager): do not quit welcome screen on esc and break
* fix(plugins): adjust permissions
* style(fmt): rustfmt
* style(fmt): fix warnings
Diffstat (limited to 'zellij-utils/src/plugin_api/plugin_command.rs')
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.rs | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index fa570a26..a5272d42 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -4,10 +4,10 @@ pub use super::generated_api::api::{ input_mode::InputMode as ProtobufInputMode, plugin_command::{ plugin_command::Payload, CliPipeOutputPayload, CommandName, ContextItem, EnvVariable, - ExecCmdPayload, HttpVerb as ProtobufHttpVerb, IdAndNewName, MessageToPluginPayload, - MovePayload, NewPluginArgs as ProtobufNewPluginArgs, OpenCommandPanePayload, - OpenFilePayload, PaneId as ProtobufPaneId, PaneType as ProtobufPaneType, - PluginCommand as ProtobufPluginCommand, PluginMessagePayload, + ExecCmdPayload, HttpVerb as ProtobufHttpVerb, IdAndNewName, KillSessionsPayload, + MessageToPluginPayload, MovePayload, NewPluginArgs as ProtobufNewPluginArgs, + OpenCommandPanePayload, OpenFilePayload, PaneId as ProtobufPaneId, + PaneType as ProtobufPaneType, PluginCommand as ProtobufPluginCommand, PluginMessagePayload, RequestPluginPermissionPayload, ResizePayload, RunCommandPayload, SetTimeoutPayload, SubscribePayload, SwitchSessionPayload, SwitchTabToPayload, UnsubscribePayload, WebRequestPayload, @@ -574,6 +574,7 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { name: payload.name, tab_position: payload.tab_position.map(|p| p as usize), pane_id, + layout: payload.layout.and_then(|l| l.try_into().ok()), })) }, _ => Err("Mismatched payload for SwitchSession"), @@ -727,6 +728,16 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { }), })) }, + _ => Err("Mismatched payload for MessageToPlugin"), + }, + Some(CommandName::DisconnectOtherClients) => match protobuf_plugin_command.payload { + None => Ok(PluginCommand::DisconnectOtherClients), + _ => Err("Mismatched payload for DisconnectOtherClients"), + }, + Some(CommandName::KillSessions) => match protobuf_plugin_command.payload { + Some(Payload::KillSessionsPayload(KillSessionsPayload { session_names })) => { + Ok(PluginCommand::KillSessions(session_names)) + }, _ => Err("Mismatched payload for PipeOutput"), }, None => Err("Unrecognized plugin command"), @@ -1082,6 +1093,7 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { tab_position: switch_to_session.tab_position.map(|t| t as u32), pane_id: switch_to_session.pane_id.map(|p| p.0), pane_id_is_plugin: switch_to_session.pane_id.map(|p| p.1), + layout: switch_to_session.layout.and_then(|l| l.try_into().ok()), })), }), PluginCommand::OpenTerminalInPlace(cwd) => Ok(ProtobufPluginCommand { @@ -1205,6 +1217,16 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { })), }) }, + PluginCommand::DisconnectOtherClients => Ok(ProtobufPluginCommand { + name: CommandName::DisconnectOtherClients as i32, + payload: None, + }), + PluginCommand::KillSessions(session_names) => Ok(ProtobufPluginCommand { + name: CommandName::KillSessions as i32, + payload: Some(Payload::KillSessionsPayload(KillSessionsPayload { + session_names, + })), + }), } } } |
