feat(plugins): some APIs for controlling and receiving information about other panes (#3515)
* add context to opening command panes, and events for their start/finish * show/hide other panes plugin apis * get tests to pass * style(fmt): rustfmt * update plugin test snapshots
This commit is contained in:
parent
5f64bf03fd
commit
ffbdb095ec
51 changed files with 555 additions and 121 deletions
|
|
@ -207,11 +207,14 @@ impl ZellijPlugin for State {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
BareKey::Char('m') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
|
BareKey::Char('m') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
|
||||||
open_command_pane(CommandToRun {
|
open_command_pane(
|
||||||
path: std::path::PathBuf::from("/path/to/my/file.rs"),
|
CommandToRun {
|
||||||
args: vec!["arg1".to_owned(), "arg2".to_owned()],
|
path: std::path::PathBuf::from("/path/to/my/file.rs"),
|
||||||
..Default::default()
|
args: vec!["arg1".to_owned(), "arg2".to_owned()],
|
||||||
});
|
..Default::default()
|
||||||
|
},
|
||||||
|
BTreeMap::new(),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
BareKey::Char('n') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
|
BareKey::Char('n') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
|
||||||
open_command_pane_floating(
|
open_command_pane_floating(
|
||||||
|
|
@ -221,6 +224,7 @@ impl ZellijPlugin for State {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
|
BTreeMap::new(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
BareKey::Char('o') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
|
BareKey::Char('o') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
|
||||||
|
|
|
||||||
|
|
@ -337,6 +337,7 @@ fn spawn_terminal(
|
||||||
cwd,
|
cwd,
|
||||||
hold_on_close: false,
|
hold_on_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
..Default::default()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TerminalAction::RunCommand(command) => command,
|
TerminalAction::RunCommand(command) => command,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
||||||
assertion_line: 4400
|
assertion_line: 4557
|
||||||
expression: "format!(\"{:#?}\", new_tab_event)"
|
expression: "format!(\"{:#?}\", new_tab_event)"
|
||||||
---
|
---
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -16,6 +16,13 @@ Some(
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: Some(
|
||||||
|
OriginatingPlugin {
|
||||||
|
plugin_id: 0,
|
||||||
|
client_id: 1,
|
||||||
|
context: {},
|
||||||
|
},
|
||||||
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
||||||
assertion_line: 4323
|
assertion_line: 4479
|
||||||
expression: "format!(\"{:#?}\", new_tab_event)"
|
expression: "format!(\"{:#?}\", new_tab_event)"
|
||||||
---
|
---
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -16,6 +16,13 @@ Some(
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: Some(
|
||||||
|
OriginatingPlugin {
|
||||||
|
plugin_id: 0,
|
||||||
|
client_id: 1,
|
||||||
|
context: {},
|
||||||
|
},
|
||||||
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
||||||
assertion_line: 4390
|
assertion_line: 4401
|
||||||
expression: "format!(\"{:#?}\", new_tab_event)"
|
expression: "format!(\"{:#?}\", new_tab_event)"
|
||||||
---
|
---
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -15,6 +15,7 @@ Some(
|
||||||
),
|
),
|
||||||
hold_on_close: false,
|
hold_on_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
||||||
assertion_line: 4312
|
assertion_line: 4323
|
||||||
expression: "format!(\"{:#?}\", new_tab_event)"
|
expression: "format!(\"{:#?}\", new_tab_event)"
|
||||||
---
|
---
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -15,6 +15,7 @@ Some(
|
||||||
),
|
),
|
||||||
hold_on_close: false,
|
hold_on_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1314,6 +1314,8 @@ fn check_event_permission(
|
||||||
| Event::SessionUpdate(..)
|
| Event::SessionUpdate(..)
|
||||||
| Event::CopyToClipboard(..)
|
| Event::CopyToClipboard(..)
|
||||||
| Event::SystemClipboardFailure
|
| Event::SystemClipboardFailure
|
||||||
|
| Event::CommandPaneOpened(..)
|
||||||
|
| Event::CommandPaneExited(..)
|
||||||
| Event::InputReceived => PermissionType::ReadApplicationState,
|
| Event::InputReceived => PermissionType::ReadApplicationState,
|
||||||
_ => return (PermissionStatus::Granted, None),
|
_ => return (PermissionStatus::Granted, None),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use std::{
|
||||||
use wasmtime::{Caller, Linker};
|
use wasmtime::{Caller, Linker};
|
||||||
use zellij_utils::data::{
|
use zellij_utils::data::{
|
||||||
CommandType, ConnectToSession, FloatingPaneCoordinates, HttpVerb, LayoutInfo, MessageToPlugin,
|
CommandType, ConnectToSession, FloatingPaneCoordinates, HttpVerb, LayoutInfo, MessageToPlugin,
|
||||||
PermissionStatus, PermissionType, PluginPermission,
|
OriginatingPlugin, PermissionStatus, PermissionType, PluginPermission,
|
||||||
};
|
};
|
||||||
use zellij_utils::input::permission::PermissionCache;
|
use zellij_utils::input::permission::PermissionCache;
|
||||||
use zellij_utils::{
|
use zellij_utils::{
|
||||||
|
|
@ -99,13 +99,19 @@ fn host_run_plugin_command(caller: Caller<'_, PluginEnv>) {
|
||||||
PluginCommand::OpenTerminalFloating(cwd, floating_pane_coordinates) => {
|
PluginCommand::OpenTerminalFloating(cwd, floating_pane_coordinates) => {
|
||||||
open_terminal_floating(env, cwd.path.try_into()?, floating_pane_coordinates)
|
open_terminal_floating(env, cwd.path.try_into()?, floating_pane_coordinates)
|
||||||
},
|
},
|
||||||
PluginCommand::OpenCommandPane(command_to_run) => {
|
PluginCommand::OpenCommandPane(command_to_run, context) => {
|
||||||
open_command_pane(env, command_to_run)
|
open_command_pane(env, command_to_run, context)
|
||||||
},
|
},
|
||||||
PluginCommand::OpenCommandPaneFloating(
|
PluginCommand::OpenCommandPaneFloating(
|
||||||
command_to_run,
|
command_to_run,
|
||||||
floating_pane_coordinates,
|
floating_pane_coordinates,
|
||||||
) => open_command_pane_floating(env, command_to_run, floating_pane_coordinates),
|
context,
|
||||||
|
) => open_command_pane_floating(
|
||||||
|
env,
|
||||||
|
command_to_run,
|
||||||
|
floating_pane_coordinates,
|
||||||
|
context,
|
||||||
|
),
|
||||||
PluginCommand::SwitchTabTo(tab_index) => switch_tab_to(env, tab_index),
|
PluginCommand::SwitchTabTo(tab_index) => switch_tab_to(env, tab_index),
|
||||||
PluginCommand::SetTimeout(seconds) => set_timeout(env, seconds),
|
PluginCommand::SetTimeout(seconds) => set_timeout(env, seconds),
|
||||||
PluginCommand::ExecCmd(command_line) => exec_cmd(env, command_line),
|
PluginCommand::ExecCmd(command_line) => exec_cmd(env, command_line),
|
||||||
|
|
@ -221,8 +227,8 @@ fn host_run_plugin_command(caller: Caller<'_, PluginEnv>) {
|
||||||
PluginCommand::OpenTerminalInPlace(cwd) => {
|
PluginCommand::OpenTerminalInPlace(cwd) => {
|
||||||
open_terminal_in_place(env, cwd.path.try_into()?)
|
open_terminal_in_place(env, cwd.path.try_into()?)
|
||||||
},
|
},
|
||||||
PluginCommand::OpenCommandPaneInPlace(command_to_run) => {
|
PluginCommand::OpenCommandPaneInPlace(command_to_run, context) => {
|
||||||
open_command_pane_in_place(env, command_to_run)
|
open_command_pane_in_place(env, command_to_run, context)
|
||||||
},
|
},
|
||||||
PluginCommand::RenameSession(new_session_name) => {
|
PluginCommand::RenameSession(new_session_name) => {
|
||||||
rename_session(env, new_session_name)
|
rename_session(env, new_session_name)
|
||||||
|
|
@ -246,6 +252,12 @@ fn host_run_plugin_command(caller: Caller<'_, PluginEnv>) {
|
||||||
PluginCommand::DumpSessionLayout => dump_session_layout(env),
|
PluginCommand::DumpSessionLayout => dump_session_layout(env),
|
||||||
PluginCommand::CloseSelf => close_self(env),
|
PluginCommand::CloseSelf => close_self(env),
|
||||||
PluginCommand::Reconfigure(new_config) => reconfigure(env, new_config)?,
|
PluginCommand::Reconfigure(new_config) => reconfigure(env, new_config)?,
|
||||||
|
PluginCommand::HidePaneWithId(pane_id) => {
|
||||||
|
hide_pane_with_id(env, pane_id.into())?
|
||||||
|
},
|
||||||
|
PluginCommand::ShowPaneWithId(pane_id, should_float_if_hidden) => {
|
||||||
|
show_pane_with_id(env, pane_id.into(), should_float_if_hidden)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
(PermissionStatus::Denied, permission) => {
|
(PermissionStatus::Denied, permission) => {
|
||||||
log::error!(
|
log::error!(
|
||||||
|
|
@ -530,31 +542,10 @@ fn open_terminal_in_place(env: &PluginEnv, cwd: PathBuf) {
|
||||||
apply_action!(action, error_msg, env);
|
apply_action!(action, error_msg, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_command_pane(env: &PluginEnv, command_to_run: CommandToRun) {
|
fn open_command_pane(
|
||||||
let error_msg = || format!("failed to open command in plugin {}", env.name());
|
|
||||||
let command = command_to_run.path;
|
|
||||||
let cwd = command_to_run.cwd.map(|cwd| env.plugin_cwd.join(cwd));
|
|
||||||
let args = command_to_run.args;
|
|
||||||
let direction = None;
|
|
||||||
let hold_on_close = true;
|
|
||||||
let hold_on_start = false;
|
|
||||||
let name = None;
|
|
||||||
let run_command_action = RunCommandAction {
|
|
||||||
command,
|
|
||||||
args,
|
|
||||||
cwd,
|
|
||||||
direction,
|
|
||||||
hold_on_close,
|
|
||||||
hold_on_start,
|
|
||||||
};
|
|
||||||
let action = Action::NewTiledPane(direction, Some(run_command_action), name);
|
|
||||||
apply_action!(action, error_msg, env);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn open_command_pane_floating(
|
|
||||||
env: &PluginEnv,
|
env: &PluginEnv,
|
||||||
command_to_run: CommandToRun,
|
command_to_run: CommandToRun,
|
||||||
floating_pane_coordinates: Option<FloatingPaneCoordinates>,
|
context: BTreeMap<String, String>,
|
||||||
) {
|
) {
|
||||||
let error_msg = || format!("failed to open command in plugin {}", env.name());
|
let error_msg = || format!("failed to open command in plugin {}", env.name());
|
||||||
let command = command_to_run.path;
|
let command = command_to_run.path;
|
||||||
|
|
@ -571,12 +562,22 @@ fn open_command_pane_floating(
|
||||||
direction,
|
direction,
|
||||||
hold_on_close,
|
hold_on_close,
|
||||||
hold_on_start,
|
hold_on_start,
|
||||||
|
originating_plugin: Some(OriginatingPlugin::new(
|
||||||
|
env.plugin_id,
|
||||||
|
env.client_id,
|
||||||
|
context,
|
||||||
|
)),
|
||||||
};
|
};
|
||||||
let action = Action::NewFloatingPane(Some(run_command_action), name, floating_pane_coordinates);
|
let action = Action::NewTiledPane(direction, Some(run_command_action), name);
|
||||||
apply_action!(action, error_msg, env);
|
apply_action!(action, error_msg, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_command_pane_in_place(env: &PluginEnv, command_to_run: CommandToRun) {
|
fn open_command_pane_floating(
|
||||||
|
env: &PluginEnv,
|
||||||
|
command_to_run: CommandToRun,
|
||||||
|
floating_pane_coordinates: Option<FloatingPaneCoordinates>,
|
||||||
|
context: BTreeMap<String, String>,
|
||||||
|
) {
|
||||||
let error_msg = || format!("failed to open command in plugin {}", env.name());
|
let error_msg = || format!("failed to open command in plugin {}", env.name());
|
||||||
let command = command_to_run.path;
|
let command = command_to_run.path;
|
||||||
let cwd = command_to_run.cwd.map(|cwd| env.plugin_cwd.join(cwd));
|
let cwd = command_to_run.cwd.map(|cwd| env.plugin_cwd.join(cwd));
|
||||||
|
|
@ -592,6 +593,41 @@ fn open_command_pane_in_place(env: &PluginEnv, command_to_run: CommandToRun) {
|
||||||
direction,
|
direction,
|
||||||
hold_on_close,
|
hold_on_close,
|
||||||
hold_on_start,
|
hold_on_start,
|
||||||
|
originating_plugin: Some(OriginatingPlugin::new(
|
||||||
|
env.plugin_id,
|
||||||
|
env.client_id,
|
||||||
|
context,
|
||||||
|
)),
|
||||||
|
};
|
||||||
|
let action = Action::NewFloatingPane(Some(run_command_action), name, floating_pane_coordinates);
|
||||||
|
apply_action!(action, error_msg, env);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn open_command_pane_in_place(
|
||||||
|
env: &PluginEnv,
|
||||||
|
command_to_run: CommandToRun,
|
||||||
|
context: BTreeMap<String, String>,
|
||||||
|
) {
|
||||||
|
let error_msg = || format!("failed to open command in plugin {}", env.name());
|
||||||
|
let command = command_to_run.path;
|
||||||
|
let cwd = command_to_run.cwd.map(|cwd| env.plugin_cwd.join(cwd));
|
||||||
|
let args = command_to_run.args;
|
||||||
|
let direction = None;
|
||||||
|
let hold_on_close = true;
|
||||||
|
let hold_on_start = false;
|
||||||
|
let name = None;
|
||||||
|
let run_command_action = RunCommandAction {
|
||||||
|
command,
|
||||||
|
args,
|
||||||
|
cwd,
|
||||||
|
direction,
|
||||||
|
hold_on_close,
|
||||||
|
hold_on_start,
|
||||||
|
originating_plugin: Some(OriginatingPlugin::new(
|
||||||
|
env.plugin_id,
|
||||||
|
env.client_id,
|
||||||
|
context,
|
||||||
|
)),
|
||||||
};
|
};
|
||||||
let action = Action::NewInPlacePane(Some(run_command_action), name);
|
let action = Action::NewInPlacePane(Some(run_command_action), name);
|
||||||
apply_action!(action, error_msg, env);
|
apply_action!(action, error_msg, env);
|
||||||
|
|
@ -762,12 +798,28 @@ fn hide_self(env: &PluginEnv) -> Result<()> {
|
||||||
.with_context(|| format!("failed to hide self"))
|
.with_context(|| format!("failed to hide self"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_pane_with_id(env: &PluginEnv, pane_id: PaneId) -> Result<()> {
|
||||||
|
env.senders
|
||||||
|
.send_to_screen(ScreenInstruction::SuppressPane(pane_id, env.client_id))
|
||||||
|
.with_context(|| format!("failed to hide self"))
|
||||||
|
}
|
||||||
|
|
||||||
fn show_self(env: &PluginEnv, should_float_if_hidden: bool) {
|
fn show_self(env: &PluginEnv, should_float_if_hidden: bool) {
|
||||||
let action = Action::FocusPluginPaneWithId(env.plugin_id, should_float_if_hidden);
|
let action = Action::FocusPluginPaneWithId(env.plugin_id, should_float_if_hidden);
|
||||||
let error_msg = || format!("Failed to show self for plugin");
|
let error_msg = || format!("Failed to show self for plugin");
|
||||||
apply_action!(action, error_msg, env);
|
apply_action!(action, error_msg, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn show_pane_with_id(env: &PluginEnv, pane_id: PaneId, should_float_if_hidden: bool) {
|
||||||
|
let _ = env
|
||||||
|
.senders
|
||||||
|
.send_to_screen(ScreenInstruction::FocusPaneWithId(
|
||||||
|
pane_id,
|
||||||
|
should_float_if_hidden,
|
||||||
|
env.client_id,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
fn close_self(env: &PluginEnv) {
|
fn close_self(env: &PluginEnv) {
|
||||||
env.senders
|
env.senders
|
||||||
.send_to_screen(ScreenInstruction::ClosePane(
|
.send_to_screen(ScreenInstruction::ClosePane(
|
||||||
|
|
@ -1448,6 +1500,8 @@ fn check_command_permission(
|
||||||
| PluginCommand::RenameSession(..)
|
| PluginCommand::RenameSession(..)
|
||||||
| PluginCommand::RenameTab(..)
|
| PluginCommand::RenameTab(..)
|
||||||
| PluginCommand::DisconnectOtherClients
|
| PluginCommand::DisconnectOtherClients
|
||||||
|
| PluginCommand::ShowPaneWithId(..)
|
||||||
|
| PluginCommand::HidePaneWithId(..)
|
||||||
| PluginCommand::KillSessions(..) => PermissionType::ChangeApplicationState,
|
| PluginCommand::KillSessions(..) => PermissionType::ChangeApplicationState,
|
||||||
PluginCommand::UnblockCliPipeInput(..)
|
PluginCommand::UnblockCliPipeInput(..)
|
||||||
| PluginCommand::BlockCliPipeInput(..)
|
| PluginCommand::BlockCliPipeInput(..)
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,12 @@ use crate::{
|
||||||
ClientId, ServerInstruction,
|
ClientId, ServerInstruction,
|
||||||
};
|
};
|
||||||
use async_std::task::{self, JoinHandle};
|
use async_std::task::{self, JoinHandle};
|
||||||
|
use std::sync::Arc;
|
||||||
use std::{collections::HashMap, os::unix::io::RawFd, path::PathBuf};
|
use std::{collections::HashMap, os::unix::io::RawFd, path::PathBuf};
|
||||||
use zellij_utils::nix::unistd::Pid;
|
use zellij_utils::nix::unistd::Pid;
|
||||||
use zellij_utils::{
|
use zellij_utils::{
|
||||||
async_std,
|
async_std,
|
||||||
data::FloatingPaneCoordinates,
|
data::{Event, FloatingPaneCoordinates},
|
||||||
errors::prelude::*,
|
errors::prelude::*,
|
||||||
errors::{ContextType, PtyContext},
|
errors::{ContextType, PtyContext},
|
||||||
input::{
|
input::{
|
||||||
|
|
@ -173,6 +174,24 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// if this command originated in a plugin, we send the plugin back an event
|
||||||
|
// to let it know the command started and which pane_id it has
|
||||||
|
if let Some(originating_plugin) =
|
||||||
|
run_command.and_then(|r| r.originating_plugin)
|
||||||
|
{
|
||||||
|
let update_event =
|
||||||
|
Event::CommandPaneOpened(pid, originating_plugin.context.clone());
|
||||||
|
pty.bus
|
||||||
|
.senders
|
||||||
|
.send_to_plugin(PluginInstruction::Update(vec![(
|
||||||
|
Some(originating_plugin.plugin_id),
|
||||||
|
Some(originating_plugin.client_id),
|
||||||
|
update_event,
|
||||||
|
)]))
|
||||||
|
.with_context(err_context)?;
|
||||||
|
}
|
||||||
|
|
||||||
pty.bus
|
pty.bus
|
||||||
.senders
|
.senders
|
||||||
.send_to_screen(ScreenInstruction::NewPane(
|
.send_to_screen(ScreenInstruction::NewPane(
|
||||||
|
|
@ -764,6 +783,7 @@ impl Pty {
|
||||||
cwd, // note: this might also be filled by the calling function, eg. spawn_terminal
|
cwd, // note: this might also be filled by the calling function, eg. spawn_terminal
|
||||||
hold_on_close: false,
|
hold_on_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -827,11 +847,13 @@ impl Pty {
|
||||||
terminal_action
|
terminal_action
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let (hold_on_start, hold_on_close) = match &terminal_action {
|
let (hold_on_start, hold_on_close, originating_plugin) = match &terminal_action {
|
||||||
TerminalAction::RunCommand(run_command) => {
|
TerminalAction::RunCommand(run_command) => (
|
||||||
(run_command.hold_on_start, run_command.hold_on_close)
|
run_command.hold_on_start,
|
||||||
},
|
run_command.hold_on_close,
|
||||||
_ => (false, false),
|
run_command.originating_plugin.clone(),
|
||||||
|
),
|
||||||
|
_ => (false, false, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
if hold_on_start {
|
if hold_on_start {
|
||||||
|
|
@ -847,9 +869,27 @@ impl Pty {
|
||||||
return Ok((terminal_id, starts_held));
|
return Ok((terminal_id, starts_held));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let originating_plugin = Arc::new(originating_plugin.clone());
|
||||||
let quit_cb = Box::new({
|
let quit_cb = Box::new({
|
||||||
let senders = self.bus.senders.clone();
|
let senders = self.bus.senders.clone();
|
||||||
move |pane_id, exit_status, command| {
|
move |pane_id, exit_status, command| {
|
||||||
|
// if this command originated in a plugin, we send the plugin an event letting it
|
||||||
|
// know the command exited and some other useful information
|
||||||
|
if let PaneId::Terminal(pane_id) = pane_id {
|
||||||
|
if let Some(originating_plugin) = originating_plugin.as_ref() {
|
||||||
|
let update_event = Event::CommandPaneExited(
|
||||||
|
pane_id,
|
||||||
|
exit_status,
|
||||||
|
originating_plugin.context.clone(),
|
||||||
|
);
|
||||||
|
let _ = senders.send_to_plugin(PluginInstruction::Update(vec![(
|
||||||
|
Some(originating_plugin.plugin_id),
|
||||||
|
Some(originating_plugin.client_id),
|
||||||
|
update_event,
|
||||||
|
)]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if hold_on_close {
|
if hold_on_close {
|
||||||
let _ = senders.send_to_screen(ScreenInstruction::HoldPane(
|
let _ = senders.send_to_screen(ScreenInstruction::HoldPane(
|
||||||
pane_id,
|
pane_id,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 1915
|
assertion_line: 2306
|
||||||
expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())"
|
expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())"
|
||||||
---
|
---
|
||||||
[SpawnTerminalVertically(Some(RunCommand(RunCommand { command: "htop", args: [], cwd: Some("/some/folder"), hold_on_close: true, hold_on_start: false })), None, 10), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit]
|
[SpawnTerminalVertically(Some(RunCommand(RunCommand { command: "htop", args: [], cwd: Some("/some/folder"), hold_on_close: true, hold_on_start: false, originating_plugin: None })), None, 10), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 2040
|
assertion_line: 2349
|
||||||
expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())"
|
expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())"
|
||||||
---
|
---
|
||||||
[SpawnTerminal(Some(RunCommand(RunCommand { command: "htop", args: [], cwd: Some("/some/folder"), hold_on_close: true, hold_on_start: false })), Some(true), None, Some(FloatingPaneCoordinates { x: Some(Fixed(10)), y: None, width: Some(Percent(20)), height: None }), ClientId(10)), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit]
|
[SpawnTerminal(Some(RunCommand(RunCommand { command: "htop", args: [], cwd: Some("/some/folder"), hold_on_close: true, hold_on_start: false, originating_plugin: None })), Some(true), None, Some(FloatingPaneCoordinates { x: Some(Fixed(10)), y: None, width: Some(Percent(20)), height: None }), ClientId(10)), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit]
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,8 @@ pub fn open_terminal_in_place<P: AsRef<Path>>(path: P) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open a new command pane with the specified command and args (this sort of pane allows the user to control the command, re-run it and see its exit status through the Zellij UI).
|
/// Open a new command pane with the specified command and args (this sort of pane allows the user to control the command, re-run it and see its exit status through the Zellij UI).
|
||||||
pub fn open_command_pane(command_to_run: CommandToRun) {
|
pub fn open_command_pane(command_to_run: CommandToRun, context: BTreeMap<String, String>) {
|
||||||
let plugin_command = PluginCommand::OpenCommandPane(command_to_run);
|
let plugin_command = PluginCommand::OpenCommandPane(command_to_run, context);
|
||||||
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
||||||
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
||||||
unsafe { host_run_plugin_command() };
|
unsafe { host_run_plugin_command() };
|
||||||
|
|
@ -142,16 +142,18 @@ pub fn open_command_pane(command_to_run: CommandToRun) {
|
||||||
pub fn open_command_pane_floating(
|
pub fn open_command_pane_floating(
|
||||||
command_to_run: CommandToRun,
|
command_to_run: CommandToRun,
|
||||||
coordinates: Option<FloatingPaneCoordinates>,
|
coordinates: Option<FloatingPaneCoordinates>,
|
||||||
|
context: BTreeMap<String, String>,
|
||||||
) {
|
) {
|
||||||
let plugin_command = PluginCommand::OpenCommandPaneFloating(command_to_run, coordinates);
|
let plugin_command =
|
||||||
|
PluginCommand::OpenCommandPaneFloating(command_to_run, coordinates, context);
|
||||||
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
||||||
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
||||||
unsafe { host_run_plugin_command() };
|
unsafe { host_run_plugin_command() };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open a new in place command pane with the specified command and args (this sort of pane allows the user to control the command, re-run it and see its exit status through the Zellij UI).
|
/// Open a new in place command pane with the specified command and args (this sort of pane allows the user to control the command, re-run it and see its exit status through the Zellij UI).
|
||||||
pub fn open_command_pane_in_place(command_to_run: CommandToRun) {
|
pub fn open_command_pane_in_place(command_to_run: CommandToRun, context: BTreeMap<String, String>) {
|
||||||
let plugin_command = PluginCommand::OpenCommandPaneInPlace(command_to_run);
|
let plugin_command = PluginCommand::OpenCommandPaneInPlace(command_to_run, context);
|
||||||
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
||||||
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
||||||
unsafe { host_run_plugin_command() };
|
unsafe { host_run_plugin_command() };
|
||||||
|
|
@ -241,6 +243,14 @@ pub fn hide_self() {
|
||||||
unsafe { host_run_plugin_command() };
|
unsafe { host_run_plugin_command() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Hide the pane (suppress it) with the specified [PaneId] from the UI
|
||||||
|
pub fn hide_pane_with_id(pane_id: PaneId) {
|
||||||
|
let plugin_command = PluginCommand::HidePaneWithId(pane_id);
|
||||||
|
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
||||||
|
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
||||||
|
unsafe { host_run_plugin_command() };
|
||||||
|
}
|
||||||
|
|
||||||
/// Show the plugin pane (unsuppress it if it is suppressed), focus it and switch to its tab
|
/// Show the plugin pane (unsuppress it if it is suppressed), focus it and switch to its tab
|
||||||
pub fn show_self(should_float_if_hidden: bool) {
|
pub fn show_self(should_float_if_hidden: bool) {
|
||||||
let plugin_command = PluginCommand::ShowSelf(should_float_if_hidden);
|
let plugin_command = PluginCommand::ShowSelf(should_float_if_hidden);
|
||||||
|
|
@ -249,6 +259,14 @@ pub fn show_self(should_float_if_hidden: bool) {
|
||||||
unsafe { host_run_plugin_command() };
|
unsafe { host_run_plugin_command() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Show the pane (unsuppress it if it is suppressed) with the specified [PaneId], focus it and switch to its tab
|
||||||
|
pub fn show_pane_with_id(pane_id: PaneId, should_float_if_hidden: bool) {
|
||||||
|
let plugin_command = PluginCommand::ShowPaneWithId(pane_id, should_float_if_hidden);
|
||||||
|
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
|
||||||
|
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
|
||||||
|
unsafe { host_run_plugin_command() };
|
||||||
|
}
|
||||||
|
|
||||||
/// Close this plugin pane
|
/// Close this plugin pane
|
||||||
pub fn close_self() {
|
pub fn close_self() {
|
||||||
let plugin_command = PluginCommand::CloseSelf;
|
let plugin_command = PluginCommand::CloseSelf;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ pub struct Event {
|
||||||
pub name: i32,
|
pub name: i32,
|
||||||
#[prost(
|
#[prost(
|
||||||
oneof = "event::Payload",
|
oneof = "event::Payload",
|
||||||
tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"
|
tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17"
|
||||||
)]
|
)]
|
||||||
pub payload: ::core::option::Option<event::Payload>,
|
pub payload: ::core::option::Option<event::Payload>,
|
||||||
}
|
}
|
||||||
|
|
@ -48,10 +48,32 @@ pub mod event {
|
||||||
RunCommandResultPayload(super::RunCommandResultPayload),
|
RunCommandResultPayload(super::RunCommandResultPayload),
|
||||||
#[prost(message, tag = "15")]
|
#[prost(message, tag = "15")]
|
||||||
WebRequestResultPayload(super::WebRequestResultPayload),
|
WebRequestResultPayload(super::WebRequestResultPayload),
|
||||||
|
#[prost(message, tag = "16")]
|
||||||
|
CommandPaneOpenedPayload(super::CommandPaneOpenedPayload),
|
||||||
|
#[prost(message, tag = "17")]
|
||||||
|
CommandPaneExitedPayload(super::CommandPaneExitedPayload),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
|
pub struct CommandPaneOpenedPayload {
|
||||||
|
#[prost(uint32, tag = "1")]
|
||||||
|
pub terminal_pane_id: u32,
|
||||||
|
#[prost(message, repeated, tag = "2")]
|
||||||
|
pub context: ::prost::alloc::vec::Vec<ContextItem>,
|
||||||
|
}
|
||||||
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
|
pub struct CommandPaneExitedPayload {
|
||||||
|
#[prost(uint32, tag = "1")]
|
||||||
|
pub terminal_pane_id: u32,
|
||||||
|
#[prost(int32, optional, tag = "2")]
|
||||||
|
pub exit_code: ::core::option::Option<i32>,
|
||||||
|
#[prost(message, repeated, tag = "3")]
|
||||||
|
pub context: ::prost::alloc::vec::Vec<ContextItem>,
|
||||||
|
}
|
||||||
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct SessionUpdatePayload {
|
pub struct SessionUpdatePayload {
|
||||||
#[prost(message, repeated, tag = "1")]
|
#[prost(message, repeated, tag = "1")]
|
||||||
pub session_manifests: ::prost::alloc::vec::Vec<SessionManifest>,
|
pub session_manifests: ::prost::alloc::vec::Vec<SessionManifest>,
|
||||||
|
|
@ -349,6 +371,8 @@ pub enum EventType {
|
||||||
SessionUpdate = 16,
|
SessionUpdate = 16,
|
||||||
RunCommandResult = 17,
|
RunCommandResult = 17,
|
||||||
WebRequestResult = 18,
|
WebRequestResult = 18,
|
||||||
|
CommandPaneOpened = 19,
|
||||||
|
CommandPaneExited = 20,
|
||||||
}
|
}
|
||||||
impl EventType {
|
impl EventType {
|
||||||
/// String value of the enum field names used in the ProtoBuf definition.
|
/// String value of the enum field names used in the ProtoBuf definition.
|
||||||
|
|
@ -376,6 +400,8 @@ impl EventType {
|
||||||
EventType::SessionUpdate => "SessionUpdate",
|
EventType::SessionUpdate => "SessionUpdate",
|
||||||
EventType::RunCommandResult => "RunCommandResult",
|
EventType::RunCommandResult => "RunCommandResult",
|
||||||
EventType::WebRequestResult => "WebRequestResult",
|
EventType::WebRequestResult => "WebRequestResult",
|
||||||
|
EventType::CommandPaneOpened => "CommandPaneOpened",
|
||||||
|
EventType::CommandPaneExited => "CommandPaneExited",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||||
|
|
@ -400,6 +426,8 @@ impl EventType {
|
||||||
"SessionUpdate" => Some(Self::SessionUpdate),
|
"SessionUpdate" => Some(Self::SessionUpdate),
|
||||||
"RunCommandResult" => Some(Self::RunCommandResult),
|
"RunCommandResult" => Some(Self::RunCommandResult),
|
||||||
"WebRequestResult" => Some(Self::WebRequestResult),
|
"WebRequestResult" => Some(Self::WebRequestResult),
|
||||||
|
"CommandPaneOpened" => Some(Self::CommandPaneOpened),
|
||||||
|
"CommandPaneExited" => Some(Self::CommandPaneExited),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ pub struct PluginCommand {
|
||||||
pub name: i32,
|
pub name: i32,
|
||||||
#[prost(
|
#[prost(
|
||||||
oneof = "plugin_command::Payload",
|
oneof = "plugin_command::Payload",
|
||||||
tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 60, 61, 62, 63"
|
tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 60, 61, 62, 63, 64, 65"
|
||||||
)]
|
)]
|
||||||
pub payload: ::core::option::Option<plugin_command::Payload>,
|
pub payload: ::core::option::Option<plugin_command::Payload>,
|
||||||
}
|
}
|
||||||
|
|
@ -120,10 +120,28 @@ pub mod plugin_command {
|
||||||
NewTabsWithLayoutInfoPayload(super::NewTabsWithLayoutInfoPayload),
|
NewTabsWithLayoutInfoPayload(super::NewTabsWithLayoutInfoPayload),
|
||||||
#[prost(string, tag = "63")]
|
#[prost(string, tag = "63")]
|
||||||
ReconfigurePayload(::prost::alloc::string::String),
|
ReconfigurePayload(::prost::alloc::string::String),
|
||||||
|
#[prost(message, tag = "64")]
|
||||||
|
HidePaneWithIdPayload(super::HidePaneWithIdPayload),
|
||||||
|
#[prost(message, tag = "65")]
|
||||||
|
ShowPaneWithIdPayload(super::ShowPaneWithIdPayload),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
|
pub struct HidePaneWithIdPayload {
|
||||||
|
#[prost(message, optional, tag = "1")]
|
||||||
|
pub pane_id: ::core::option::Option<PaneId>,
|
||||||
|
}
|
||||||
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
|
pub struct ShowPaneWithIdPayload {
|
||||||
|
#[prost(message, optional, tag = "1")]
|
||||||
|
pub pane_id: ::core::option::Option<PaneId>,
|
||||||
|
#[prost(bool, tag = "2")]
|
||||||
|
pub should_float_if_hidden: bool,
|
||||||
|
}
|
||||||
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct NewTabsWithLayoutInfoPayload {
|
pub struct NewTabsWithLayoutInfoPayload {
|
||||||
#[prost(message, optional, tag = "1")]
|
#[prost(message, optional, tag = "1")]
|
||||||
pub layout_info: ::core::option::Option<super::event::LayoutInfo>,
|
pub layout_info: ::core::option::Option<super::event::LayoutInfo>,
|
||||||
|
|
@ -235,6 +253,8 @@ pub struct OpenCommandPanePayload {
|
||||||
pub command_to_run: ::core::option::Option<super::command::Command>,
|
pub command_to_run: ::core::option::Option<super::command::Command>,
|
||||||
#[prost(message, optional, tag = "2")]
|
#[prost(message, optional, tag = "2")]
|
||||||
pub floating_pane_coordinates: ::core::option::Option<FloatingPaneCoordinates>,
|
pub floating_pane_coordinates: ::core::option::Option<FloatingPaneCoordinates>,
|
||||||
|
#[prost(message, repeated, tag = "3")]
|
||||||
|
pub context: ::prost::alloc::vec::Vec<ContextItem>,
|
||||||
}
|
}
|
||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
|
|
@ -434,6 +454,8 @@ pub enum CommandName {
|
||||||
CloseSelf = 85,
|
CloseSelf = 85,
|
||||||
NewTabsWithLayoutInfo = 86,
|
NewTabsWithLayoutInfo = 86,
|
||||||
Reconfigure = 87,
|
Reconfigure = 87,
|
||||||
|
HidePaneWithId = 88,
|
||||||
|
ShowPaneWithId = 89,
|
||||||
}
|
}
|
||||||
impl CommandName {
|
impl CommandName {
|
||||||
/// String value of the enum field names used in the ProtoBuf definition.
|
/// String value of the enum field names used in the ProtoBuf definition.
|
||||||
|
|
@ -530,6 +552,8 @@ impl CommandName {
|
||||||
CommandName::CloseSelf => "CloseSelf",
|
CommandName::CloseSelf => "CloseSelf",
|
||||||
CommandName::NewTabsWithLayoutInfo => "NewTabsWithLayoutInfo",
|
CommandName::NewTabsWithLayoutInfo => "NewTabsWithLayoutInfo",
|
||||||
CommandName::Reconfigure => "Reconfigure",
|
CommandName::Reconfigure => "Reconfigure",
|
||||||
|
CommandName::HidePaneWithId => "HidePaneWithId",
|
||||||
|
CommandName::ShowPaneWithId => "ShowPaneWithId",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||||
|
|
@ -623,6 +647,8 @@ impl CommandName {
|
||||||
"CloseSelf" => Some(Self::CloseSelf),
|
"CloseSelf" => Some(Self::CloseSelf),
|
||||||
"NewTabsWithLayoutInfo" => Some(Self::NewTabsWithLayoutInfo),
|
"NewTabsWithLayoutInfo" => Some(Self::NewTabsWithLayoutInfo),
|
||||||
"Reconfigure" => Some(Self::Reconfigure),
|
"Reconfigure" => Some(Self::Reconfigure),
|
||||||
|
"HidePaneWithId" => Some(Self::HidePaneWithId),
|
||||||
|
"ShowPaneWithId" => Some(Self::ShowPaneWithId),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -910,9 +910,12 @@ pub enum Event {
|
||||||
Vec<u8>,
|
Vec<u8>,
|
||||||
BTreeMap<String, String>,
|
BTreeMap<String, String>,
|
||||||
), // status,
|
), // status,
|
||||||
// headers,
|
// headers,
|
||||||
// body,
|
// body,
|
||||||
// context
|
// context
|
||||||
|
CommandPaneOpened(u32, Context), // u32 - terminal_pane_id
|
||||||
|
CommandPaneExited(u32, Option<i32>, Context), // u32 - terminal_pane_id, Option<i32> -
|
||||||
|
// exit_code
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
@ -1671,6 +1674,25 @@ impl FloatingPaneCoordinates {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
pub struct OriginatingPlugin {
|
||||||
|
pub plugin_id: u32,
|
||||||
|
pub client_id: ClientId,
|
||||||
|
pub context: Context,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OriginatingPlugin {
|
||||||
|
pub fn new(plugin_id: u32, client_id: ClientId, context: Context) -> Self {
|
||||||
|
OriginatingPlugin {
|
||||||
|
plugin_id,
|
||||||
|
client_id,
|
||||||
|
context,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Context = BTreeMap<String, String>;
|
||||||
|
|
||||||
#[derive(Debug, Clone, EnumDiscriminants, ToString)]
|
#[derive(Debug, Clone, EnumDiscriminants, ToString)]
|
||||||
#[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))]
|
#[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))]
|
||||||
#[strum_discriminants(name(CommandType))]
|
#[strum_discriminants(name(CommandType))]
|
||||||
|
|
@ -1684,8 +1706,8 @@ pub enum PluginCommand {
|
||||||
OpenFileFloating(FileToOpen, Option<FloatingPaneCoordinates>),
|
OpenFileFloating(FileToOpen, Option<FloatingPaneCoordinates>),
|
||||||
OpenTerminal(FileToOpen), // only used for the path as cwd
|
OpenTerminal(FileToOpen), // only used for the path as cwd
|
||||||
OpenTerminalFloating(FileToOpen, Option<FloatingPaneCoordinates>), // only used for the path as cwd
|
OpenTerminalFloating(FileToOpen, Option<FloatingPaneCoordinates>), // only used for the path as cwd
|
||||||
OpenCommandPane(CommandToRun),
|
OpenCommandPane(CommandToRun, Context),
|
||||||
OpenCommandPaneFloating(CommandToRun, Option<FloatingPaneCoordinates>),
|
OpenCommandPaneFloating(CommandToRun, Option<FloatingPaneCoordinates>, Context),
|
||||||
SwitchTabTo(u32), // tab index
|
SwitchTabTo(u32), // tab index
|
||||||
SetTimeout(f64), // seconds
|
SetTimeout(f64), // seconds
|
||||||
ExecCmd(Vec<String>),
|
ExecCmd(Vec<String>),
|
||||||
|
|
@ -1747,7 +1769,7 @@ pub enum PluginCommand {
|
||||||
DeleteAllDeadSessions, // String -> session name
|
DeleteAllDeadSessions, // String -> session name
|
||||||
OpenTerminalInPlace(FileToOpen), // only used for the path as cwd
|
OpenTerminalInPlace(FileToOpen), // only used for the path as cwd
|
||||||
OpenFileInPlace(FileToOpen),
|
OpenFileInPlace(FileToOpen),
|
||||||
OpenCommandPaneInPlace(CommandToRun),
|
OpenCommandPaneInPlace(CommandToRun, Context),
|
||||||
RunCommand(
|
RunCommand(
|
||||||
Vec<String>, // command
|
Vec<String>, // command
|
||||||
BTreeMap<String, String>, // env_variables
|
BTreeMap<String, String>, // env_variables
|
||||||
|
|
@ -1774,4 +1796,6 @@ pub enum PluginCommand {
|
||||||
CloseSelf,
|
CloseSelf,
|
||||||
NewTabsWithLayoutInfo(LayoutInfo),
|
NewTabsWithLayoutInfo(LayoutInfo),
|
||||||
Reconfigure(String), // String -> stringified configuration
|
Reconfigure(String), // String -> stringified configuration
|
||||||
|
HidePaneWithId(PaneId),
|
||||||
|
ShowPaneWithId(PaneId, bool), // bool -> should_float_if_hidden
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,7 @@ impl Action {
|
||||||
direction,
|
direction,
|
||||||
hold_on_close,
|
hold_on_close,
|
||||||
hold_on_start,
|
hold_on_start,
|
||||||
|
..Default::default()
|
||||||
};
|
};
|
||||||
if floating {
|
if floating {
|
||||||
Ok(vec![Action::NewFloatingPane(
|
Ok(vec![Action::NewFloatingPane(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//! Trigger a command
|
//! Trigger a command
|
||||||
use crate::data::Direction;
|
use crate::data::{Direction, OriginatingPlugin};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
|
@ -35,6 +35,8 @@ pub struct RunCommand {
|
||||||
pub hold_on_close: bool,
|
pub hold_on_close: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub hold_on_start: bool,
|
pub hold_on_start: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub originating_plugin: Option<OriginatingPlugin>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for RunCommand {
|
impl std::fmt::Display for RunCommand {
|
||||||
|
|
@ -68,6 +70,8 @@ pub struct RunCommandAction {
|
||||||
pub hold_on_close: bool,
|
pub hold_on_close: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub hold_on_start: bool,
|
pub hold_on_start: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub originating_plugin: Option<OriginatingPlugin>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RunCommandAction> for RunCommand {
|
impl From<RunCommandAction> for RunCommand {
|
||||||
|
|
@ -78,6 +82,7 @@ impl From<RunCommandAction> for RunCommand {
|
||||||
cwd: action.cwd,
|
cwd: action.cwd,
|
||||||
hold_on_close: action.hold_on_close,
|
hold_on_close: action.hold_on_close,
|
||||||
hold_on_start: action.hold_on_start,
|
hold_on_start: action.hold_on_start,
|
||||||
|
originating_plugin: action.originating_plugin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +96,7 @@ impl From<RunCommand> for RunCommandAction {
|
||||||
direction: None,
|
direction: None,
|
||||||
hold_on_close: run_command.hold_on_close,
|
hold_on_close: run_command.hold_on_close,
|
||||||
hold_on_start: run_command.hold_on_start,
|
hold_on_start: run_command.hold_on_start,
|
||||||
|
originating_plugin: run_command.originating_plugin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1352
|
assertion_line: 1410
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -25,6 +25,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -54,6 +55,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1317
|
assertion_line: 1375
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -28,6 +28,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -57,6 +58,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1369
|
assertion_line: 1427
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -25,6 +25,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -51,6 +52,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: false,
|
hold_on_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1335
|
assertion_line: 1393
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -25,6 +25,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -51,6 +52,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: false,
|
hold_on_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1404
|
assertion_line: 1462
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -25,6 +25,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -53,6 +54,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1387
|
assertion_line: 1445
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -55,6 +56,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 2141
|
assertion_line: 2230
|
||||||
expression: "format!(\"{layout:#?}\")"
|
expression: "format!(\"{layout:#?}\")"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -107,6 +107,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -183,6 +184,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1789
|
assertion_line: 1847
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -46,6 +46,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1810
|
assertion_line: 1868
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -50,6 +50,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1829
|
assertion_line: 1887
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -46,6 +46,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1674
|
assertion_line: 1732
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -47,6 +47,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1707
|
assertion_line: 1765
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -47,6 +47,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1728
|
assertion_line: 1786
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -47,6 +47,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1687
|
assertion_line: 1745
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -47,6 +47,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1744
|
assertion_line: 1802
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -46,6 +46,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 481
|
assertion_line: 511
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -25,6 +25,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: false,
|
hold_on_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 494
|
assertion_line: 524
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -25,6 +25,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: true,
|
hold_on_start: true,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 834
|
assertion_line: 892
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -48,6 +48,7 @@ Layout {
|
||||||
cwd: None,
|
cwd: None,
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1558
|
assertion_line: 1616
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1504
|
assertion_line: 1562
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1521
|
assertion_line: 1579
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1539
|
assertion_line: 1597
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1576
|
assertion_line: 1634
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1628
|
assertion_line: 1686
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1610
|
assertion_line: 1668
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -27,6 +27,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1759
|
assertion_line: 1817
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -46,6 +46,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-utils/src/input/./unit/layout_test.rs
|
source: zellij-utils/src/input/./unit/layout_test.rs
|
||||||
assertion_line: 1774
|
assertion_line: 1832
|
||||||
expression: "format!(\"{:#?}\", layout)"
|
expression: "format!(\"{:#?}\", layout)"
|
||||||
---
|
---
|
||||||
Layout {
|
Layout {
|
||||||
|
|
@ -46,6 +46,7 @@ Layout {
|
||||||
),
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
|
originating_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -455,6 +455,7 @@ impl<'a> KdlLayoutParser<'a> {
|
||||||
cwd,
|
cwd,
|
||||||
hold_on_close,
|
hold_on_close,
|
||||||
hold_on_start,
|
hold_on_start,
|
||||||
|
..Default::default()
|
||||||
}))),
|
}))),
|
||||||
(None, Some(edit), Some(cwd)) => {
|
(None, Some(edit), Some(cwd)) => {
|
||||||
Ok(Some(Run::EditFile(cwd.join(edit), None, Some(cwd))))
|
Ok(Some(Run::EditFile(cwd.join(edit), None, Some(cwd))))
|
||||||
|
|
|
||||||
|
|
@ -946,6 +946,7 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
|
||||||
direction,
|
direction,
|
||||||
hold_on_close,
|
hold_on_close,
|
||||||
hold_on_start,
|
hold_on_start,
|
||||||
|
..Default::default()
|
||||||
};
|
};
|
||||||
let x = command_metadata
|
let x = command_metadata
|
||||||
.and_then(|c_m| kdl_child_string_value_for_entry(c_m, "x"))
|
.and_then(|c_m| kdl_child_string_value_for_entry(c_m, "x"))
|
||||||
|
|
|
||||||
|
|
@ -1385,6 +1385,7 @@ impl TryFrom<ProtobufRunCommandAction> for RunCommandAction {
|
||||||
direction,
|
direction,
|
||||||
hold_on_close,
|
hold_on_close,
|
||||||
hold_on_start,
|
hold_on_start,
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ enum EventType {
|
||||||
SessionUpdate = 16;
|
SessionUpdate = 16;
|
||||||
RunCommandResult = 17;
|
RunCommandResult = 17;
|
||||||
WebRequestResult = 18;
|
WebRequestResult = 18;
|
||||||
|
CommandPaneOpened = 19;
|
||||||
|
CommandPaneExited = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
message EventNameList {
|
message EventNameList {
|
||||||
|
|
@ -65,9 +67,22 @@ message Event {
|
||||||
SessionUpdatePayload session_update_payload = 13;
|
SessionUpdatePayload session_update_payload = 13;
|
||||||
RunCommandResultPayload run_command_result_payload = 14;
|
RunCommandResultPayload run_command_result_payload = 14;
|
||||||
WebRequestResultPayload web_request_result_payload = 15;
|
WebRequestResultPayload web_request_result_payload = 15;
|
||||||
|
CommandPaneOpenedPayload command_pane_opened_payload = 16;
|
||||||
|
CommandPaneExitedPayload command_pane_exited_payload = 17;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message CommandPaneOpenedPayload {
|
||||||
|
uint32 terminal_pane_id = 1;
|
||||||
|
repeated ContextItem context = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CommandPaneExitedPayload {
|
||||||
|
uint32 terminal_pane_id = 1;
|
||||||
|
optional int32 exit_code = 2;
|
||||||
|
repeated ContextItem context = 3;
|
||||||
|
}
|
||||||
|
|
||||||
message SessionUpdatePayload {
|
message SessionUpdatePayload {
|
||||||
repeated SessionManifest session_manifests = 1;
|
repeated SessionManifest session_manifests = 1;
|
||||||
repeated ResurrectableSession resurrectable_sessions = 2;
|
repeated ResurrectableSession resurrectable_sessions = 2;
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,33 @@ impl TryFrom<ProtobufEvent> for Event {
|
||||||
},
|
},
|
||||||
_ => Err("Malformed payload for the WebRequestResult Event"),
|
_ => Err("Malformed payload for the WebRequestResult Event"),
|
||||||
},
|
},
|
||||||
|
Some(ProtobufEventType::CommandPaneOpened) => match protobuf_event.payload {
|
||||||
|
Some(ProtobufEventPayload::CommandPaneOpenedPayload(
|
||||||
|
command_pane_opened_payload,
|
||||||
|
)) => Ok(Event::CommandPaneOpened(
|
||||||
|
command_pane_opened_payload.terminal_pane_id,
|
||||||
|
command_pane_opened_payload
|
||||||
|
.context
|
||||||
|
.into_iter()
|
||||||
|
.map(|c_i| (c_i.name, c_i.value))
|
||||||
|
.collect(),
|
||||||
|
)),
|
||||||
|
_ => Err("Malformed payload for the CommandPaneOpened Event"),
|
||||||
|
},
|
||||||
|
Some(ProtobufEventType::CommandPaneExited) => match protobuf_event.payload {
|
||||||
|
Some(ProtobufEventPayload::CommandPaneExitedPayload(
|
||||||
|
command_pane_exited_payload,
|
||||||
|
)) => Ok(Event::CommandPaneExited(
|
||||||
|
command_pane_exited_payload.terminal_pane_id,
|
||||||
|
command_pane_exited_payload.exit_code,
|
||||||
|
command_pane_exited_payload
|
||||||
|
.context
|
||||||
|
.into_iter()
|
||||||
|
.map(|c_i| (c_i.name, c_i.value))
|
||||||
|
.collect(),
|
||||||
|
)),
|
||||||
|
_ => Err("Malformed payload for the CommandPaneExited Event"),
|
||||||
|
},
|
||||||
None => Err("Unknown Protobuf Event"),
|
None => Err("Unknown Protobuf Event"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -460,6 +487,37 @@ impl TryFrom<Event> for ProtobufEvent {
|
||||||
)),
|
)),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Event::CommandPaneOpened(terminal_pane_id, context) => {
|
||||||
|
let command_pane_opened_payload = CommandPaneOpenedPayload {
|
||||||
|
terminal_pane_id,
|
||||||
|
context: context
|
||||||
|
.into_iter()
|
||||||
|
.map(|(name, value)| ContextItem { name, value })
|
||||||
|
.collect(),
|
||||||
|
};
|
||||||
|
Ok(ProtobufEvent {
|
||||||
|
name: ProtobufEventType::CommandPaneOpened as i32,
|
||||||
|
payload: Some(event::Payload::CommandPaneOpenedPayload(
|
||||||
|
command_pane_opened_payload,
|
||||||
|
)),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
Event::CommandPaneExited(terminal_pane_id, exit_code, context) => {
|
||||||
|
let command_pane_exited_payload = CommandPaneExitedPayload {
|
||||||
|
terminal_pane_id,
|
||||||
|
exit_code,
|
||||||
|
context: context
|
||||||
|
.into_iter()
|
||||||
|
.map(|(name, value)| ContextItem { name, value })
|
||||||
|
.collect(),
|
||||||
|
};
|
||||||
|
Ok(ProtobufEvent {
|
||||||
|
name: ProtobufEventType::CommandPaneExited as i32,
|
||||||
|
payload: Some(event::Payload::CommandPaneExitedPayload(
|
||||||
|
command_pane_exited_payload,
|
||||||
|
)),
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -963,6 +1021,8 @@ impl TryFrom<ProtobufEventType> for EventType {
|
||||||
ProtobufEventType::SessionUpdate => EventType::SessionUpdate,
|
ProtobufEventType::SessionUpdate => EventType::SessionUpdate,
|
||||||
ProtobufEventType::RunCommandResult => EventType::RunCommandResult,
|
ProtobufEventType::RunCommandResult => EventType::RunCommandResult,
|
||||||
ProtobufEventType::WebRequestResult => EventType::WebRequestResult,
|
ProtobufEventType::WebRequestResult => EventType::WebRequestResult,
|
||||||
|
ProtobufEventType::CommandPaneOpened => EventType::CommandPaneOpened,
|
||||||
|
ProtobufEventType::CommandPaneExited => EventType::CommandPaneExited,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -990,6 +1050,8 @@ impl TryFrom<EventType> for ProtobufEventType {
|
||||||
EventType::SessionUpdate => ProtobufEventType::SessionUpdate,
|
EventType::SessionUpdate => ProtobufEventType::SessionUpdate,
|
||||||
EventType::RunCommandResult => ProtobufEventType::RunCommandResult,
|
EventType::RunCommandResult => ProtobufEventType::RunCommandResult,
|
||||||
EventType::WebRequestResult => ProtobufEventType::WebRequestResult,
|
EventType::WebRequestResult => ProtobufEventType::WebRequestResult,
|
||||||
|
EventType::CommandPaneOpened => ProtobufEventType::CommandPaneOpened,
|
||||||
|
EventType::CommandPaneExited => ProtobufEventType::CommandPaneExited,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,8 @@ enum CommandName {
|
||||||
CloseSelf = 85;
|
CloseSelf = 85;
|
||||||
NewTabsWithLayoutInfo = 86;
|
NewTabsWithLayoutInfo = 86;
|
||||||
Reconfigure = 87;
|
Reconfigure = 87;
|
||||||
|
HidePaneWithId = 88;
|
||||||
|
ShowPaneWithId = 89;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PluginCommand {
|
message PluginCommand {
|
||||||
|
|
@ -157,9 +159,20 @@ message PluginCommand {
|
||||||
string scan_host_folder_payload = 61;
|
string scan_host_folder_payload = 61;
|
||||||
NewTabsWithLayoutInfoPayload new_tabs_with_layout_info_payload = 62;
|
NewTabsWithLayoutInfoPayload new_tabs_with_layout_info_payload = 62;
|
||||||
string reconfigure_payload = 63;
|
string reconfigure_payload = 63;
|
||||||
|
HidePaneWithIdPayload hide_pane_with_id_payload = 64;
|
||||||
|
ShowPaneWithIdPayload show_pane_with_id_payload = 65;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message HidePaneWithIdPayload {
|
||||||
|
PaneId pane_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ShowPaneWithIdPayload {
|
||||||
|
PaneId pane_id = 1;
|
||||||
|
bool should_float_if_hidden = 2;
|
||||||
|
}
|
||||||
|
|
||||||
message NewTabsWithLayoutInfoPayload {
|
message NewTabsWithLayoutInfoPayload {
|
||||||
event.LayoutInfo layout_info = 1;
|
event.LayoutInfo layout_info = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -230,6 +243,7 @@ message OpenFilePayload {
|
||||||
message OpenCommandPanePayload {
|
message OpenCommandPanePayload {
|
||||||
command.Command command_to_run = 1;
|
command.Command command_to_run = 1;
|
||||||
optional FloatingPaneCoordinates floating_pane_coordinates = 2;
|
optional FloatingPaneCoordinates floating_pane_coordinates = 2;
|
||||||
|
repeated ContextItem context = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SwitchTabToPayload {
|
message SwitchTabToPayload {
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ pub use super::generated_api::api::{
|
||||||
plugin_command::Payload, CliPipeOutputPayload, CommandName, ContextItem, EnvVariable,
|
plugin_command::Payload, CliPipeOutputPayload, CommandName, ContextItem, EnvVariable,
|
||||||
ExecCmdPayload, FixedOrPercent as ProtobufFixedOrPercent,
|
ExecCmdPayload, FixedOrPercent as ProtobufFixedOrPercent,
|
||||||
FixedOrPercentValue as ProtobufFixedOrPercentValue,
|
FixedOrPercentValue as ProtobufFixedOrPercentValue,
|
||||||
FloatingPaneCoordinates as ProtobufFloatingPaneCoordinates, HttpVerb as ProtobufHttpVerb,
|
FloatingPaneCoordinates as ProtobufFloatingPaneCoordinates, HidePaneWithIdPayload,
|
||||||
IdAndNewName, KillSessionsPayload, MessageToPluginPayload, MovePayload,
|
HttpVerb as ProtobufHttpVerb, IdAndNewName, KillSessionsPayload, MessageToPluginPayload,
|
||||||
NewPluginArgs as ProtobufNewPluginArgs, NewTabsWithLayoutInfoPayload,
|
MovePayload, NewPluginArgs as ProtobufNewPluginArgs, NewTabsWithLayoutInfoPayload,
|
||||||
OpenCommandPanePayload, OpenFilePayload, PaneId as ProtobufPaneId,
|
OpenCommandPanePayload, OpenFilePayload, PaneId as ProtobufPaneId,
|
||||||
PaneType as ProtobufPaneType, PluginCommand as ProtobufPluginCommand, PluginMessagePayload,
|
PaneType as ProtobufPaneType, PluginCommand as ProtobufPluginCommand, PluginMessagePayload,
|
||||||
RequestPluginPermissionPayload, ResizePayload, RunCommandPayload, SetTimeoutPayload,
|
RequestPluginPermissionPayload, ResizePayload, RunCommandPayload, SetTimeoutPayload,
|
||||||
SubscribePayload, SwitchSessionPayload, SwitchTabToPayload, UnsubscribePayload,
|
ShowPaneWithIdPayload, SubscribePayload, SwitchSessionPayload, SwitchTabToPayload,
|
||||||
WebRequestPayload,
|
UnsubscribePayload, WebRequestPayload,
|
||||||
},
|
},
|
||||||
plugin_permission::PermissionType as ProtobufPermissionType,
|
plugin_permission::PermissionType as ProtobufPermissionType,
|
||||||
resize::ResizeAction as ProtobufResizeAction,
|
resize::ResizeAction as ProtobufResizeAction,
|
||||||
|
|
@ -278,7 +278,15 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
|
||||||
Some(Payload::OpenCommandPanePayload(command_to_run_payload)) => {
|
Some(Payload::OpenCommandPanePayload(command_to_run_payload)) => {
|
||||||
match command_to_run_payload.command_to_run {
|
match command_to_run_payload.command_to_run {
|
||||||
Some(command_to_run) => {
|
Some(command_to_run) => {
|
||||||
Ok(PluginCommand::OpenCommandPane(command_to_run.try_into()?))
|
let context: BTreeMap<String, String> = command_to_run_payload
|
||||||
|
.context
|
||||||
|
.into_iter()
|
||||||
|
.map(|e| (e.name, e.value))
|
||||||
|
.collect();
|
||||||
|
Ok(PluginCommand::OpenCommandPane(
|
||||||
|
command_to_run.try_into()?,
|
||||||
|
context,
|
||||||
|
))
|
||||||
},
|
},
|
||||||
None => Err("Malformed open open command pane payload"),
|
None => Err("Malformed open open command pane payload"),
|
||||||
}
|
}
|
||||||
|
|
@ -291,10 +299,18 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
|
||||||
.floating_pane_coordinates
|
.floating_pane_coordinates
|
||||||
.map(|f| f.into());
|
.map(|f| f.into());
|
||||||
match command_to_run_payload.command_to_run {
|
match command_to_run_payload.command_to_run {
|
||||||
Some(command_to_run) => Ok(PluginCommand::OpenCommandPaneFloating(
|
Some(command_to_run) => {
|
||||||
command_to_run.try_into()?,
|
let context: BTreeMap<String, String> = command_to_run_payload
|
||||||
floating_pane_coordinates,
|
.context
|
||||||
)),
|
.into_iter()
|
||||||
|
.map(|e| (e.name, e.value))
|
||||||
|
.collect();
|
||||||
|
Ok(PluginCommand::OpenCommandPaneFloating(
|
||||||
|
command_to_run.try_into()?,
|
||||||
|
floating_pane_coordinates,
|
||||||
|
context,
|
||||||
|
))
|
||||||
|
},
|
||||||
None => Err("Malformed open command pane floating payload"),
|
None => Err("Malformed open command pane floating payload"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -719,9 +735,17 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
|
||||||
Some(CommandName::OpenCommandInPlace) => match protobuf_plugin_command.payload {
|
Some(CommandName::OpenCommandInPlace) => match protobuf_plugin_command.payload {
|
||||||
Some(Payload::OpenCommandPaneInPlacePayload(command_to_run_payload)) => {
|
Some(Payload::OpenCommandPaneInPlacePayload(command_to_run_payload)) => {
|
||||||
match command_to_run_payload.command_to_run {
|
match command_to_run_payload.command_to_run {
|
||||||
Some(command_to_run) => Ok(PluginCommand::OpenCommandPaneInPlace(
|
Some(command_to_run) => {
|
||||||
command_to_run.try_into()?,
|
let context: BTreeMap<String, String> = command_to_run_payload
|
||||||
)),
|
.context
|
||||||
|
.into_iter()
|
||||||
|
.map(|e| (e.name, e.value))
|
||||||
|
.collect();
|
||||||
|
Ok(PluginCommand::OpenCommandPaneInPlace(
|
||||||
|
command_to_run.try_into()?,
|
||||||
|
context,
|
||||||
|
))
|
||||||
|
},
|
||||||
None => Err("Malformed open command pane in-place payload"),
|
None => Err("Malformed open command pane in-place payload"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -894,6 +918,30 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
|
||||||
},
|
},
|
||||||
_ => Err("Mismatched payload for Reconfigure"),
|
_ => Err("Mismatched payload for Reconfigure"),
|
||||||
},
|
},
|
||||||
|
Some(CommandName::HidePaneWithId) => match protobuf_plugin_command.payload {
|
||||||
|
Some(Payload::HidePaneWithIdPayload(hide_pane_with_id_payload)) => {
|
||||||
|
let pane_id = hide_pane_with_id_payload
|
||||||
|
.pane_id
|
||||||
|
.and_then(|p_id| PaneId::try_from(p_id).ok())
|
||||||
|
.ok_or("Failed to parse HidePaneWithId command")?;
|
||||||
|
Ok(PluginCommand::HidePaneWithId(pane_id))
|
||||||
|
},
|
||||||
|
_ => Err("Mismatched payload for HidePaneWithId"),
|
||||||
|
},
|
||||||
|
Some(CommandName::ShowPaneWithId) => match protobuf_plugin_command.payload {
|
||||||
|
Some(Payload::ShowPaneWithIdPayload(show_pane_with_id_payload)) => {
|
||||||
|
let pane_id = show_pane_with_id_payload
|
||||||
|
.pane_id
|
||||||
|
.and_then(|p_id| PaneId::try_from(p_id).ok())
|
||||||
|
.ok_or("Failed to parse ShowPaneWithId command")?;
|
||||||
|
let should_float_if_hidden = show_pane_with_id_payload.should_float_if_hidden;
|
||||||
|
Ok(PluginCommand::ShowPaneWithId(
|
||||||
|
pane_id,
|
||||||
|
should_float_if_hidden,
|
||||||
|
))
|
||||||
|
},
|
||||||
|
_ => Err("Mismatched payload for ShowPaneWithId"),
|
||||||
|
},
|
||||||
None => Err("Unrecognized plugin command"),
|
None => Err("Unrecognized plugin command"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -965,20 +1013,36 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
|
||||||
})),
|
})),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
PluginCommand::OpenCommandPane(command_to_run) => Ok(ProtobufPluginCommand {
|
PluginCommand::OpenCommandPane(command_to_run, context) => {
|
||||||
name: CommandName::OpenCommandPane as i32,
|
let context: Vec<_> = context
|
||||||
payload: Some(Payload::OpenCommandPanePayload(OpenCommandPanePayload {
|
.into_iter()
|
||||||
command_to_run: Some(command_to_run.try_into()?),
|
.map(|(name, value)| ContextItem { name, value })
|
||||||
floating_pane_coordinates: None,
|
.collect();
|
||||||
})),
|
Ok(ProtobufPluginCommand {
|
||||||
}),
|
name: CommandName::OpenCommandPane as i32,
|
||||||
PluginCommand::OpenCommandPaneFloating(command_to_run, floating_pane_coordinates) => {
|
payload: Some(Payload::OpenCommandPanePayload(OpenCommandPanePayload {
|
||||||
|
command_to_run: Some(command_to_run.try_into()?),
|
||||||
|
floating_pane_coordinates: None,
|
||||||
|
context,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
PluginCommand::OpenCommandPaneFloating(
|
||||||
|
command_to_run,
|
||||||
|
floating_pane_coordinates,
|
||||||
|
context,
|
||||||
|
) => {
|
||||||
|
let context: Vec<_> = context
|
||||||
|
.into_iter()
|
||||||
|
.map(|(name, value)| ContextItem { name, value })
|
||||||
|
.collect();
|
||||||
Ok(ProtobufPluginCommand {
|
Ok(ProtobufPluginCommand {
|
||||||
name: CommandName::OpenCommandPaneFloating as i32,
|
name: CommandName::OpenCommandPaneFloating as i32,
|
||||||
payload: Some(Payload::OpenCommandPaneFloatingPayload(
|
payload: Some(Payload::OpenCommandPaneFloatingPayload(
|
||||||
OpenCommandPanePayload {
|
OpenCommandPanePayload {
|
||||||
command_to_run: Some(command_to_run.try_into()?),
|
command_to_run: Some(command_to_run.try_into()?),
|
||||||
floating_pane_coordinates: floating_pane_coordinates.map(|f| f.into()),
|
floating_pane_coordinates: floating_pane_coordinates.map(|f| f.into()),
|
||||||
|
context,
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
})
|
})
|
||||||
|
|
@ -1277,15 +1341,22 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
|
||||||
floating_pane_coordinates: None,
|
floating_pane_coordinates: None,
|
||||||
})),
|
})),
|
||||||
}),
|
}),
|
||||||
PluginCommand::OpenCommandPaneInPlace(command_to_run) => Ok(ProtobufPluginCommand {
|
PluginCommand::OpenCommandPaneInPlace(command_to_run, context) => {
|
||||||
name: CommandName::OpenCommandInPlace as i32,
|
let context: Vec<_> = context
|
||||||
payload: Some(Payload::OpenCommandPaneInPlacePayload(
|
.into_iter()
|
||||||
OpenCommandPanePayload {
|
.map(|(name, value)| ContextItem { name, value })
|
||||||
command_to_run: Some(command_to_run.try_into()?),
|
.collect();
|
||||||
floating_pane_coordinates: None,
|
Ok(ProtobufPluginCommand {
|
||||||
},
|
name: CommandName::OpenCommandInPlace as i32,
|
||||||
)),
|
payload: Some(Payload::OpenCommandPaneInPlacePayload(
|
||||||
}),
|
OpenCommandPanePayload {
|
||||||
|
command_to_run: Some(command_to_run.try_into()?),
|
||||||
|
floating_pane_coordinates: None,
|
||||||
|
context,
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
})
|
||||||
|
},
|
||||||
PluginCommand::RunCommand(command_line, env_variables, cwd, context) => {
|
PluginCommand::RunCommand(command_line, env_variables, cwd, context) => {
|
||||||
let env_variables: Vec<_> = env_variables
|
let env_variables: Vec<_> = env_variables
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
@ -1430,6 +1501,21 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
|
||||||
name: CommandName::Reconfigure as i32,
|
name: CommandName::Reconfigure as i32,
|
||||||
payload: Some(Payload::ReconfigurePayload(reconfigure_payload)),
|
payload: Some(Payload::ReconfigurePayload(reconfigure_payload)),
|
||||||
}),
|
}),
|
||||||
|
PluginCommand::HidePaneWithId(pane_id_to_hide) => Ok(ProtobufPluginCommand {
|
||||||
|
name: CommandName::HidePaneWithId as i32,
|
||||||
|
payload: Some(Payload::HidePaneWithIdPayload(HidePaneWithIdPayload {
|
||||||
|
pane_id: ProtobufPaneId::try_from(pane_id_to_hide).ok(),
|
||||||
|
})),
|
||||||
|
}),
|
||||||
|
PluginCommand::ShowPaneWithId(pane_id_to_show, should_float_if_hidden) => {
|
||||||
|
Ok(ProtobufPluginCommand {
|
||||||
|
name: CommandName::ShowPaneWithId as i32,
|
||||||
|
payload: Some(Payload::ShowPaneWithIdPayload(ShowPaneWithIdPayload {
|
||||||
|
pane_id: ProtobufPaneId::try_from(pane_id_to_show).ok(),
|
||||||
|
should_float_if_hidden,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue