diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-03-27 20:24:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-27 20:24:18 +0100 |
| commit | 9d2e7fe2c19d2d61223dcc30787ea83a0e447781 (patch) | |
| tree | c077c4fdedb48d18c9e933c76ef8e97850d59bed /zellij-server/src/plugins | |
| parent | docs(changelog): plugin serialization fix (diff) | |
| download | sl0ppij-9d2e7fe2c19d2d61223dcc30787ea83a0e447781.tar.gz sl0ppij-9d2e7fe2c19d2d61223dcc30787ea83a0e447781.tar.xz sl0ppij-9d2e7fe2c19d2d61223dcc30787ea83a0e447781.zip | |
feat(plugins): add api to close current plugin instance (#3228)
Diffstat (limited to 'zellij-server/src/plugins')
| -rw-r--r-- | zellij-server/src/plugins/zellij_exports.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs index 1f65fad5..cc0752ff 100644 --- a/zellij-server/src/plugins/zellij_exports.rs +++ b/zellij-server/src/plugins/zellij_exports.rs @@ -264,6 +264,7 @@ fn host_run_plugin_command(env: FunctionEnvMut<ForeignFunctionEnv>) { }, PluginCommand::WatchFilesystem => watch_filesystem(env), PluginCommand::DumpSessionLayout => dump_session_layout(env), + PluginCommand::CloseSelf => close_self(env), }, (PermissionStatus::Denied, permission) => { log::error!( @@ -813,6 +814,22 @@ fn show_self(env: &ForeignFunctionEnv, should_float_if_hidden: bool) { apply_action!(action, error_msg, env); } +fn close_self(env: &ForeignFunctionEnv) { + env.plugin_env + .senders + .send_to_screen(ScreenInstruction::ClosePane( + PaneId::Plugin(env.plugin_env.plugin_id), + None, + )) + .with_context(|| format!("failed to close self")) + .non_fatal(); + env.plugin_env + .senders + .send_to_plugin(PluginInstruction::Unload(env.plugin_env.plugin_id)) + .with_context(|| format!("failed to close self")) + .non_fatal(); +} + fn switch_to_mode(env: &ForeignFunctionEnv, input_mode: InputMode) { let action = Action::SwitchToMode(input_mode); let error_msg = || { |
