diff options
Diffstat (limited to 'zellij-utils/src/plugin_api')
-rw-r--r-- | zellij-utils/src/plugin_api/action.proto | 1 | ||||
-rw-r--r-- | zellij-utils/src/plugin_api/action.rs | 23 | ||||
-rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.proto | 6 | ||||
-rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.rs | 55 |
4 files changed, 82 insertions, 3 deletions
diff --git a/zellij-utils/src/plugin_api/action.proto b/zellij-utils/src/plugin_api/action.proto index 7e40bde24..1545b9bf4 100644 --- a/zellij-utils/src/plugin_api/action.proto +++ b/zellij-utils/src/plugin_api/action.proto @@ -85,6 +85,7 @@ message LaunchOrFocusPluginPayload { bool should_float = 2; optional PluginConfiguration plugin_configuration = 3; bool move_to_focused_tab = 4; + bool should_open_in_place = 5; } message GoToTabNamePayload { diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs index 0d70af692..bba6e821c 100644 --- a/zellij-utils/src/plugin_api/action.rs +++ b/zellij-utils/src/plugin_api/action.rs @@ -232,12 +232,14 @@ impl TryFrom<ProtobufAction> for Action { .and_then(|d| ProtobufResizeDirection::from_i32(d)) .and_then(|d| d.try_into().ok()); let should_float = payload.should_float; + let should_be_in_place = false; Ok(Action::EditFile( file_to_edit, line_number, cwd, direction, should_float, + should_be_in_place, )) }, _ => Err("Wrong payload for Action::NewPane"), @@ -400,10 +402,12 @@ impl TryFrom<ProtobufAction> for Action { }; let should_float = payload.should_float; let move_to_focused_tab = payload.move_to_focused_tab; + let should_open_in_place = payload.should_open_in_place; Ok(Action::LaunchOrFocusPlugin( run_plugin, should_float, move_to_focused_tab, + should_open_in_place, )) }, _ => Err("Wrong payload for Action::LaunchOrFocusPlugin"), @@ -814,7 +818,14 @@ impl TryFrom<Action> for ProtobufAction { })), }) }, - Action::EditFile(path_to_file, line_number, cwd, direction, should_float) => { + Action::EditFile( + path_to_file, + line_number, + cwd, + direction, + should_float, + _should_be_in_place, + ) => { let file_to_edit = path_to_file.display().to_string(); let cwd = cwd.map(|cwd| cwd.display().to_string()); let direction: Option<i32> = direction @@ -959,7 +970,12 @@ impl TryFrom<Action> for ProtobufAction { optional_payload: Some(OptionalPayload::MiddleClickPayload(position)), }) }, - Action::LaunchOrFocusPlugin(run_plugin, should_float, move_to_focused_tab) => { + Action::LaunchOrFocusPlugin( + run_plugin, + should_float, + move_to_focused_tab, + should_open_in_place, + ) => { let url: Url = Url::from(&run_plugin.location); Ok(ProtobufAction { name: ProtobufActionName::LaunchOrFocusPlugin as i32, @@ -968,6 +984,7 @@ impl TryFrom<Action> for ProtobufAction { plugin_url: url.into(), should_float, move_to_focused_tab, + should_open_in_place, plugin_configuration: Some(run_plugin.configuration.try_into()?), }, )), @@ -1149,6 +1166,8 @@ impl TryFrom<Action> for ProtobufAction { }), Action::NoOp | Action::Confirm + | Action::NewInPlacePane(..) + | Action::NewInPlacePluginPane(..) | Action::Deny | Action::Copy | Action::SkipConfirm(..) => Err("Unsupported action"), diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto index fed8ec54d..17b153810 100644 --- a/zellij-utils/src/plugin_api/plugin_command.proto +++ b/zellij-utils/src/plugin_api/plugin_command.proto @@ -79,6 +79,9 @@ enum CommandName { ReportCrash = 65; RequestPluginPermissions = 66; SwitchSession = 67; + OpenTerminalInPlace = 68; + OpenCommandInPlace = 69; + OpenFileInPlace = 70; } message PluginCommand { @@ -122,6 +125,9 @@ message PluginCommand { string report_crash_payload = 37; RequestPluginPermissionPayload request_plugin_permission_payload = 38; SwitchSessionPayload switch_session_payload = 39; + OpenFilePayload open_file_in_place_payload = 40; + OpenFilePayload open_terminal_in_place_payload = 41; + OpenCommandPanePayload open_command_pane_in_place_payload = 42; } } diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index 25773ba3a..3d34f10fc 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -82,7 +82,7 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { None => Err("Malformed open file payload"), } }, - _ => Err("Mismatched payload for OpenFile"), + _ => Err("Mismatched payload for OpenFileFloating"), }, Some(CommandName::OpenTerminal) => match protobuf_plugin_command.payload { Some(Payload::OpenTerminalPayload(file_to_open_payload)) => { @@ -520,6 +520,39 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { }, _ => Err("Mismatched payload for SwitchSession"), }, + Some(CommandName::OpenTerminalInPlace) => match protobuf_plugin_command.payload { + Some(Payload::OpenTerminalInPlacePayload(file_to_open_payload)) => { + match file_to_open_payload.file_to_open { + Some(file_to_open) => { + Ok(PluginCommand::OpenTerminalInPlace(file_to_open.try_into()?)) + }, + None => Err("Malformed open terminal in-place payload"), + } + }, + _ => Err("Mismatched payload for OpenTerminalInPlace"), + }, + Some(CommandName::OpenFileInPlace) => match protobuf_plugin_command.payload { + Some(Payload::OpenFileInPlacePayload(file_to_open_payload)) => { + match file_to_open_payload.file_to_open { + Some(file_to_open) => { + Ok(PluginCommand::OpenFileInPlace(file_to_open.try_into()?)) + }, + None => Err("Malformed open file in place payload"), + } + }, + _ => Err("Mismatched payload for OpenFileInPlace"), + }, + Some(CommandName::OpenCommandInPlace) => match protobuf_plugin_command.payload { + Some(Payload::OpenCommandPaneInPlacePayload(command_to_run_payload)) => { + match command_to_run_payload.command_to_run { + Some(command_to_run) => Ok(PluginCommand::OpenCommandPaneInPlace( + command_to_run.try_into()?, + )), + None => Err("Malformed open command pane in-place payload"), + } + }, + _ => Err("Mismatched payload for OpenCommandPaneInPlace"), + }, None => Err("Unrecognized plugin command"), } } @@ -875,6 +908,26 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { pane_id_is_plugin: switch_to_session.pane_id.map(|p| p.1), })), }), + PluginCommand::OpenTerminalInPlace(cwd) => Ok(ProtobufPluginCommand { + name: CommandName::OpenTerminalInPlace as i32, + payload: Some(Payload::OpenTerminalInPlacePayload(OpenFilePayload { + file_to_open: Some(cwd.try_into()?), + })), + }), + PluginCommand::OpenFileInPlace(file_to_open) => Ok(ProtobufPluginCommand { + name: CommandName::OpenFileInPlace as i32, + payload: Some(Payload::OpenFileInPlacePayload(OpenFilePayload { + file_to_open: Some(file_to_open.try_into()?), + })), + }), + PluginCommand::OpenCommandPaneInPlace(command_to_run) => Ok(ProtobufPluginCommand { + name: CommandName::OpenCommandInPlace as i32, + payload: Some(Payload::OpenCommandPaneInPlacePayload( + OpenCommandPanePayload { + command_to_run: Some(command_to_run.try_into()?), + }, + )), + }), } } } |