diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-08-16 14:00:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-16 14:00:01 +0200 |
| commit | 056537d3eef06cddc60dc13b715a41766bb1fe9d (patch) | |
| tree | ff7e107e992e4c98ac60ac88da7215cb0beb668a /zellij-utils/src/plugin_api | |
| parent | docs(changelog): CommandPaneReRun plugin event (diff) | |
| download | sl0ppij-056537d3eef06cddc60dc13b715a41766bb1fe9d.tar.gz sl0ppij-056537d3eef06cddc60dc13b715a41766bb1fe9d.tar.xz sl0ppij-056537d3eef06cddc60dc13b715a41766bb1fe9d.zip | |
feat(ux): first run setup-wizard (#3556)
* separate saved/runtime structure, kind of working
* serializing config
* work
* work
* save config through the configuration screen
* work
* startup wizard
* style(code): cleanups
* fix(session): reload config from disk when switching sessions
* style(fmt): rustfmt
* fix(config): propagate cli config options to screen
* style(fmt): rustfmt
Diffstat (limited to 'zellij-utils/src/plugin_api')
| -rw-r--r-- | zellij-utils/src/plugin_api/event.proto | 6 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/event.rs | 16 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.proto | 7 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.rs | 18 |
4 files changed, 40 insertions, 7 deletions
diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto index 610a3ac4..a985806f 100644 --- a/zellij-utils/src/plugin_api/event.proto +++ b/zellij-utils/src/plugin_api/event.proto @@ -48,6 +48,7 @@ enum EventType { EditPaneOpened = 22; EditPaneExited = 23; CommandPaneReRun = 24; + FailedToWriteConfigToDisk = 25; } message EventNameList { @@ -77,9 +78,14 @@ message Event { EditPaneOpenedPayload edit_pane_opened_payload = 19; EditPaneExitedPayload edit_pane_exited_payload = 20; CommandPaneReRunPayload command_pane_rerun_payload = 21; + FailedToWriteConfigToDiskPayload failed_to_write_config_to_disk_payload = 22; } } +message FailedToWriteConfigToDiskPayload { + optional string file_path = 1; +} + message CommandPaneReRunPayload { uint32 terminal_pane_id = 1; repeated ContextItem context = 3; diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index b669a672..faeb53d2 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -312,6 +312,14 @@ impl TryFrom<ProtobufEvent> for Event { }, _ => Err("Malformed payload for the CommandPaneReRun Event"), }, + Some(ProtobufEventType::FailedToWriteConfigToDisk) => match protobuf_event.payload { + Some(ProtobufEventPayload::FailedToWriteConfigToDiskPayload( + failed_to_write_configuration_payload, + )) => Ok(Event::FailedToWriteConfigToDisk( + failed_to_write_configuration_payload.file_path, + )), + _ => Err("Malformed payload for the FailedToWriteConfigToDisk Event"), + }, None => Err("Unknown Protobuf Event"), } } @@ -620,6 +628,12 @@ impl TryFrom<Event> for ProtobufEvent { )), }) }, + Event::FailedToWriteConfigToDisk(file_path) => Ok(ProtobufEvent { + name: ProtobufEventType::FailedToWriteConfigToDisk as i32, + payload: Some(event::Payload::FailedToWriteConfigToDiskPayload( + FailedToWriteConfigToDiskPayload { file_path }, + )), + }), } } } @@ -1129,6 +1143,7 @@ impl TryFrom<ProtobufEventType> for EventType { ProtobufEventType::EditPaneOpened => EventType::EditPaneOpened, ProtobufEventType::EditPaneExited => EventType::EditPaneExited, ProtobufEventType::CommandPaneReRun => EventType::CommandPaneReRun, + ProtobufEventType::FailedToWriteConfigToDisk => EventType::FailedToWriteConfigToDisk, }) } } @@ -1162,6 +1177,7 @@ impl TryFrom<EventType> for ProtobufEventType { EventType::EditPaneOpened => ProtobufEventType::EditPaneOpened, EventType::EditPaneExited => ProtobufEventType::EditPaneExited, EventType::CommandPaneReRun => ProtobufEventType::CommandPaneReRun, + EventType::FailedToWriteConfigToDisk => ProtobufEventType::FailedToWriteConfigToDisk, }) } } diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto index d91cc817..be47f567 100644 --- a/zellij-utils/src/plugin_api/plugin_command.proto +++ b/zellij-utils/src/plugin_api/plugin_command.proto @@ -160,7 +160,7 @@ message PluginCommand { KillSessionsPayload kill_sessions_payload = 60; string scan_host_folder_payload = 61; NewTabsWithLayoutInfoPayload new_tabs_with_layout_info_payload = 62; - string reconfigure_payload = 63; + ReconfigurePayload reconfigure_payload = 63; HidePaneWithIdPayload hide_pane_with_id_payload = 64; ShowPaneWithIdPayload show_pane_with_id_payload = 65; OpenCommandPanePayload open_command_pane_background_payload = 66; @@ -168,6 +168,11 @@ message PluginCommand { } } +message ReconfigurePayload { + string config = 1; + bool write_to_disk = 2; +} + message RerunCommandPanePayload { uint32 terminal_pane_id = 1; } diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index 3df40531..4ffabbe4 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -11,9 +11,9 @@ pub use super::generated_api::api::{ MovePayload, NewPluginArgs as ProtobufNewPluginArgs, NewTabsWithLayoutInfoPayload, OpenCommandPanePayload, OpenFilePayload, PaneId as ProtobufPaneId, PaneType as ProtobufPaneType, PluginCommand as ProtobufPluginCommand, PluginMessagePayload, - RequestPluginPermissionPayload, RerunCommandPanePayload, ResizePayload, RunCommandPayload, - SetTimeoutPayload, ShowPaneWithIdPayload, SubscribePayload, SwitchSessionPayload, - SwitchTabToPayload, UnsubscribePayload, WebRequestPayload, + ReconfigurePayload, RequestPluginPermissionPayload, RerunCommandPanePayload, ResizePayload, + RunCommandPayload, SetTimeoutPayload, ShowPaneWithIdPayload, SubscribePayload, + SwitchSessionPayload, SwitchTabToPayload, UnsubscribePayload, WebRequestPayload, }, plugin_permission::PermissionType as ProtobufPermissionType, resize::ResizeAction as ProtobufResizeAction, @@ -935,7 +935,10 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { }, Some(CommandName::Reconfigure) => match protobuf_plugin_command.payload { Some(Payload::ReconfigurePayload(reconfigure_payload)) => { - Ok(PluginCommand::Reconfigure(reconfigure_payload)) + Ok(PluginCommand::Reconfigure( + reconfigure_payload.config, + reconfigure_payload.write_to_disk, + )) }, _ => Err("Mismatched payload for Reconfigure"), }, @@ -1558,9 +1561,12 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { )), }) }, - PluginCommand::Reconfigure(reconfigure_payload) => Ok(ProtobufPluginCommand { + PluginCommand::Reconfigure(config, write_to_disk) => Ok(ProtobufPluginCommand { name: CommandName::Reconfigure as i32, - payload: Some(Payload::ReconfigurePayload(reconfigure_payload)), + payload: Some(Payload::ReconfigurePayload(ReconfigurePayload { + config, + write_to_disk, + })), }), PluginCommand::HidePaneWithId(pane_id_to_hide) => Ok(ProtobufPluginCommand { name: CommandName::HidePaneWithId as i32, |
