diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-07-22 18:30:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-22 18:30:18 +0200 |
| commit | ffbdb095ec5402455ac7f1cc8ef2f1bb8ebc8df2 (patch) | |
| tree | 99467c7156aa1b9c2fa6d0b65464e1b0c948c913 /zellij-utils/src | |
| parent | docs(changelog): current process refresh fix (diff) | |
| download | sl0ppij-ffbdb095ec5402455ac7f1cc8ef2f1bb8ebc8df2.tar.gz sl0ppij-ffbdb095ec5402455ac7f1cc8ef2f1bb8ebc8df2.tar.xz sl0ppij-ffbdb095ec5402455ac7f1cc8ef2f1bb8ebc8df2.zip | |
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
Diffstat (limited to 'zellij-utils/src')
37 files changed, 309 insertions, 64 deletions
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index 0ebb6f1b..cb27a706 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -910,9 +910,12 @@ pub enum Event { Vec<u8>, BTreeMap<String, String>, ), // status, - // headers, - // body, - // context + // headers, + // body, + // context + CommandPaneOpened(u32, Context), // u32 - terminal_pane_id + CommandPaneExited(u32, Option<i32>, Context), // u32 - terminal_pane_id, Option<i32> - + // exit_code } #[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)] #[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))] #[strum_discriminants(name(CommandType))] @@ -1684,8 +1706,8 @@ pub enum PluginCommand { OpenFileFloating(FileToOpen, Option<FloatingPaneCoordinates>), OpenTerminal(FileToOpen), // only used for the path as cwd OpenTerminalFloating(FileToOpen, Option<FloatingPaneCoordinates>), // only used for the path as cwd - OpenCommandPane(CommandToRun), - OpenCommandPaneFloating(CommandToRun, Option<FloatingPaneCoordinates>), + OpenCommandPane(CommandToRun, Context), + OpenCommandPaneFloating(CommandToRun, Option<FloatingPaneCoordinates>, Context), SwitchTabTo(u32), // tab index SetTimeout(f64), // seconds ExecCmd(Vec<String>), @@ -1747,7 +1769,7 @@ pub enum PluginCommand { DeleteAllDeadSessions, // String -> session name OpenTerminalInPlace(FileToOpen), // only used for the path as cwd OpenFileInPlace(FileToOpen), - OpenCommandPaneInPlace(CommandToRun), + OpenCommandPaneInPlace(CommandToRun, Context), RunCommand( Vec<String>, // command BTreeMap<String, String>, // env_variables @@ -1774,4 +1796,6 @@ pub enum PluginCommand { CloseSelf, NewTabsWithLayoutInfo(LayoutInfo), Reconfigure(String), // String -> stringified configuration + HidePaneWithId(PaneId), + ShowPaneWithId(PaneId, bool), // bool -> should_float_if_hidden } diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index 32a8a828..50bcf2af 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -432,6 +432,7 @@ impl Action { direction, hold_on_close, hold_on_start, + ..Default::default() }; if floating { Ok(vec![Action::NewFloatingPane( diff --git a/zellij-utils/src/input/command.rs b/zellij-utils/src/input/command.rs index c05aa644..2b860f66 100644 --- a/zellij-utils/src/input/command.rs +++ b/zellij-utils/src/input/command.rs @@ -1,5 +1,5 @@ //! Trigger a command -use crate::data::Direction; +use crate::data::{Direction, OriginatingPlugin}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -35,6 +35,8 @@ pub struct RunCommand { pub hold_on_close: bool, #[serde(default)] pub hold_on_start: bool, + #[serde(default)] + pub originating_plugin: Option<OriginatingPlugin>, } impl std::fmt::Display for RunCommand { @@ -68,6 +70,8 @@ pub struct RunCommandAction { pub hold_on_close: bool, #[serde(default)] pub hold_on_start: bool, + #[serde(default)] + pub originating_plugin: Option<OriginatingPlugin>, } impl From<RunCommandAction> for RunCommand { @@ -78,6 +82,7 @@ impl From<RunCommandAction> for RunCommand { cwd: action.cwd, hold_on_close: action.hold_on_close, hold_on_start: action.hold_on_start, + originating_plugin: action.originating_plugin, } } } @@ -91,6 +96,7 @@ impl From<RunCommand> for RunCommandAction { direction: None, hold_on_close: run_command.hold_on_close, hold_on_start: run_command.hold_on_start, + originating_plugin: run_command.originating_plugin, } } } diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap index 0d8a3635..32af5be5 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_added_to_args_in_template.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1352 +assertion_line: 1410 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -25,6 +25,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), @@ -54,6 +55,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap index 65db8169..83c3040b 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__args_override_args_in_template.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1317 +assertion_line: 1375 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -28,6 +28,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), @@ -57,6 +58,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap index f9208fc3..7ad4d582 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1369 +assertion_line: 1427 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -25,6 +25,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), @@ -51,6 +52,7 @@ Layout { cwd: None, hold_on_close: false, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap index adc88ee8..17c1b957 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1335 +assertion_line: 1393 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -25,6 +25,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), @@ -51,6 +52,7 @@ Layout { cwd: None, hold_on_close: false, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_added_to_cwd_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_added_to_cwd_in_template.snap index 721b37d5..fd2c4367 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_added_to_cwd_in_template.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_added_to_cwd_in_template.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1404 +assertion_line: 1462 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -25,6 +25,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), @@ -53,6 +54,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_override_cwd_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_override_cwd_in_template.snap index bad9bf62..065c224e 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_override_cwd_in_template.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__cwd_override_cwd_in_template.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1387 +assertion_line: 1445 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), @@ -55,6 +56,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__env_var_expansion.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__env_var_expansion.snap index 25cfceb5..96b3368e 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__env_var_expansion.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__env_var_expansion.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 2141 +assertion_line: 2230 expression: "format!(\"{layout:#?}\")" --- Layout { @@ -107,6 +107,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), @@ -183,6 +184,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd.snap index 8bf48d27..506f125a 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1789 +assertion_line: 1847 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -46,6 +46,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_pane_templates.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_pane_templates.snap index a8938ed8..d3ca7b10 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_pane_templates.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_pane_templates.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1810 +assertion_line: 1868 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -50,6 +50,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_tab_templates.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_tab_templates.snap index 3abbaaee..f378d730 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_tab_templates.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_and_tab_cwd_prepended_to_panes_with_and_without_cwd_in_tab_templates.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1829 +assertion_line: 1887 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -46,6 +46,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_given_to_panes_without_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_given_to_panes_without_cwd.snap index adb41072..45cceeae 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_given_to_panes_without_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_given_to_panes_without_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1674 +assertion_line: 1732 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -47,6 +47,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor.snap index 3ae5eee2..5fa90d82 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1707 +assertion_line: 1765 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -47,6 +47,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor_overrides_global_cwd_in_layout_file.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor_overrides_global_cwd_in_layout_file.snap index dcd2d932..5cb9b89f 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor_overrides_global_cwd_in_layout_file.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_passed_from_layout_constructor_overrides_global_cwd_in_layout_file.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1728 +assertion_line: 1786 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -47,6 +47,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_prepended_to_panes_with_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_prepended_to_panes_with_cwd.snap index d292e95f..9b090525 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_prepended_to_panes_with_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_prepended_to_panes_with_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1687 +assertion_line: 1745 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -47,6 +47,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_with_tab_cwd_given_to_panes_without_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_with_tab_cwd_given_to_panes_without_cwd.snap index 2abeb3d1..56daf176 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_with_tab_cwd_given_to_panes_without_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__global_cwd_with_tab_cwd_given_to_panes_without_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1744 +assertion_line: 1802 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -46,6 +46,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap index 1c3e5a38..ed00fc5e 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 481 +assertion_line: 511 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -25,6 +25,7 @@ Layout { cwd: None, hold_on_close: false, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_start_suspended.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_start_suspended.snap index 11986040..711a3107 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_start_suspended.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_start_suspended.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 494 +assertion_line: 524 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -25,6 +25,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: true, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_tab_and_pane_templates.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_tab_and_pane_templates.snap index 30bd1b85..7bcdec0e 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_tab_and_pane_templates.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_tab_and_pane_templates.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 834 +assertion_line: 892 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -48,6 +48,7 @@ Layout { cwd: None, hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_is_overriden_by_its_consumers_bare_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_is_overriden_by_its_consumers_bare_cwd.snap index e8cbac56..fa2cac82 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_is_overriden_by_its_consumers_bare_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_is_overriden_by_its_consumers_bare_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1558 +assertion_line: 1616 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_overriden_by_its_consumers_command_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_overriden_by_its_consumers_command_cwd.snap index e03609cf..b70dca22 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_overriden_by_its_consumers_command_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_overriden_by_its_consumers_command_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1504 +assertion_line: 1562 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_remains_when_its_consumer_command_does_not_have_a_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_remains_when_its_consumer_command_does_not_have_a_cwd.snap index c7214bb2..03a02e4a 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_remains_when_its_consumer_command_does_not_have_a_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_with_cwd_remains_when_its_consumer_command_does_not_have_a_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1521 +assertion_line: 1579 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_is_overriden_by_its_consumers_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_is_overriden_by_its_consumers_cwd.snap index e3308e18..3f803880 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_is_overriden_by_its_consumers_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_is_overriden_by_its_consumers_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1539 +assertion_line: 1597 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_receives_its_consumers_bare_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_receives_its_consumers_bare_cwd.snap index 748f5f91..1bb20e26 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_receives_its_consumers_bare_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_command_without_cwd_receives_its_consumers_bare_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1576 +assertion_line: 1634 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_with_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_with_cwd.snap index 4923ab97..98b99d53 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_with_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_with_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1628 +assertion_line: 1686 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_without_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_without_cwd.snap index 5067ae79..131d89fd 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_without_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__pane_template_with_bare_propagated_to_its_consumer_command_without_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1610 +assertion_line: 1668 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -27,6 +27,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_given_to_panes_without_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_given_to_panes_without_cwd.snap index 49019f51..1f4a0dd7 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_given_to_panes_without_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_given_to_panes_without_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1759 +assertion_line: 1817 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -46,6 +46,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_prepended_to_panes_with_cwd.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_prepended_to_panes_with_cwd.snap index ffc6958e..0d4a6f4a 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_prepended_to_panes_with_cwd.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__tab_cwd_prepended_to_panes_with_cwd.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/input/./unit/layout_test.rs -assertion_line: 1774 +assertion_line: 1832 expression: "format!(\"{:#?}\", layout)" --- Layout { @@ -46,6 +46,7 @@ Layout { ), hold_on_close: true, hold_on_start: false, + originating_plugin: None, }, ), ), diff --git a/zellij-utils/src/kdl/kdl_layout_parser.rs b/zellij-utils/src/kdl/kdl_layout_parser.rs index b2952501..f19cc9a2 100644 --- a/zellij-utils/src/kdl/kdl_layout_parser.rs +++ b/zellij-utils/src/kdl/kdl_layout_parser.rs @@ -455,6 +455,7 @@ impl<'a> KdlLayoutParser<'a> { cwd, hold_on_close, hold_on_start, + ..Default::default() }))), (None, Some(edit), Some(cwd)) => { Ok(Some(Run::EditFile(cwd.join(edit), None, Some(cwd)))) diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index 95b534fd..b22c8112 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -946,6 +946,7 @@ impl TryFrom<(&KdlNode, &Options)> for Action { direction, hold_on_close, hold_on_start, + ..Default::default() }; let x = command_metadata .and_then(|c_m| kdl_child_string_value_for_entry(c_m, "x")) diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs index d148541e..b206dba0 100644 --- a/zellij-utils/src/plugin_api/action.rs +++ b/zellij-utils/src/plugin_api/action.rs @@ -1385,6 +1385,7 @@ impl TryFrom<ProtobufRunCommandAction> for RunCommandAction { direction, hold_on_close, hold_on_start, + ..Default::default() }) } } diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto index c48030aa..ac1bdd29 100644 --- a/zellij-utils/src/plugin_api/event.proto +++ b/zellij-utils/src/plugin_api/event.proto @@ -42,6 +42,8 @@ enum EventType { SessionUpdate = 16; RunCommandResult = 17; WebRequestResult = 18; + CommandPaneOpened = 19; + CommandPaneExited = 20; } message EventNameList { @@ -65,9 +67,22 @@ message Event { SessionUpdatePayload session_update_payload = 13; RunCommandResultPayload run_command_result_payload = 14; 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 { repeated SessionManifest session_manifests = 1; repeated ResurrectableSession resurrectable_sessions = 2; diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index 7996801c..c10c6ec0 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -235,6 +235,33 @@ impl TryFrom<ProtobufEvent> for 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"), } } @@ -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::RunCommandResult => EventType::RunCommandResult, 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::RunCommandResult => ProtobufEventType::RunCommandResult, EventType::WebRequestResult => ProtobufEventType::WebRequestResult, + EventType::CommandPaneOpened => ProtobufEventType::CommandPaneOpened, + EventType::CommandPaneExited => ProtobufEventType::CommandPaneExited, }) } } diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto index 5442909e..3e3567dd 100644 --- a/zellij-utils/src/plugin_api/plugin_command.proto +++ b/zellij-utils/src/plugin_api/plugin_command.proto @@ -99,6 +99,8 @@ enum CommandName { CloseSelf = 85; NewTabsWithLayoutInfo = 86; Reconfigure = 87; + HidePaneWithId = 88; + ShowPaneWithId = 89; } message PluginCommand { @@ -157,9 +159,20 @@ message PluginCommand { string scan_host_folder_payload = 61; NewTabsWithLayoutInfoPayload new_tabs_with_layout_info_payload = 62; 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 { event.LayoutInfo layout_info = 1; } @@ -230,6 +243,7 @@ message OpenFilePayload { message OpenCommandPanePayload { command.Command command_to_run = 1; optional FloatingPaneCoordinates floating_pane_coordinates = 2; + repeated ContextItem context = 3; } message SwitchTabToPayload { diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index a6514b1b..e72001e2 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -6,14 +6,14 @@ pub use super::generated_api::api::{ plugin_command::Payload, CliPipeOutputPayload, CommandName, ContextItem, EnvVariable, ExecCmdPayload, FixedOrPercent as ProtobufFixedOrPercent, FixedOrPercentValue as ProtobufFixedOrPercentValue, - FloatingPaneCoordinates as ProtobufFloatingPaneCoordinates, HttpVerb as ProtobufHttpVerb, - IdAndNewName, KillSessionsPayload, MessageToPluginPayload, MovePayload, - NewPluginArgs as ProtobufNewPluginArgs, NewTabsWithLayoutInfoPayload, + FloatingPaneCoordinates as ProtobufFloatingPaneCoordinates, HidePaneWithIdPayload, + HttpVerb as ProtobufHttpVerb, IdAndNewName, KillSessionsPayload, MessageToPluginPayload, + MovePayload, NewPluginArgs as ProtobufNewPluginArgs, NewTabsWithLayoutInfoPayload, OpenCommandPanePayload, OpenFilePayload, PaneId as ProtobufPaneId, PaneType as ProtobufPaneType, PluginCommand as ProtobufPluginCommand, PluginMessagePayload, RequestPluginPermissionPayload, ResizePayload, RunCommandPayload, SetTimeoutPayload, - SubscribePayload, SwitchSessionPayload, SwitchTabToPayload, UnsubscribePayload, - WebRequestPayload, + ShowPaneWithIdPayload, SubscribePayload, SwitchSessionPayload, SwitchTabToPayload, + UnsubscribePayload, WebRequestPayload, }, plugin_permission::PermissionType as ProtobufPermissionType, resize::ResizeAction as ProtobufResizeAction, @@ -278,7 +278,15 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { Some(Payload::OpenCommandPanePayload(command_to_run_payload)) => { match command_to_run_payload.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"), } @@ -291,10 +299,18 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { .floating_pane_coordinates .map(|f| f.into()); match command_to_run_payload.command_to_run { - Some(command_to_run) => Ok(PluginCommand::OpenCommandPaneFloating( - command_to_run.try_into()?, - floating_pane_coordinates, - )), + Some(command_to_run) => { + let context: BTreeMap<String, String> = command_to_run_payload + .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"), } }, @@ -719,9 +735,17 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { 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()?, - )), + Some(command_to_run) => { + 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"), } }, @@ -894,6 +918,30 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { }, _ => 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"), } } @@ -965,20 +1013,36 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { })), }) }, - PluginCommand::OpenCommandPane(command_to_run) => Ok(ProtobufPluginCommand { - name: CommandName::OpenCommandPane as i32, - payload: Some(Payload::OpenCommandPanePayload(OpenCommandPanePayload { - command_to_run: Some(command_to_run.try_into()?), - floating_pane_coordinates: None, - })), - }), - PluginCommand::OpenCommandPaneFloating(command_to_run, floating_pane_coordinates) => { + PluginCommand::OpenCommandPane(command_to_run, context) => { + let context: Vec<_> = context + .into_iter() + .map(|(name, value)| ContextItem { name, value }) + .collect(); + Ok(ProtobufPluginCommand { + name: CommandName::OpenCommandPane as i32, + 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 { name: CommandName::OpenCommandPaneFloating as i32, payload: Some(Payload::OpenCommandPaneFloatingPayload( OpenCommandPanePayload { command_to_run: Some(command_to_run.try_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, })), }), - 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()?), - floating_pane_coordinates: None, - }, - )), - }), + PluginCommand::OpenCommandPaneInPlace(command_to_run, context) => { + let context: Vec<_> = context + .into_iter() + .map(|(name, value)| ContextItem { name, value }) + .collect(); + 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) => { let env_variables: Vec<_> = env_variables .into_iter() @@ -1430,6 +1501,21 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { name: CommandName::Reconfigure as i32, 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, + })), + }) + }, } } } |
