aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/plugins
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2025-06-03 17:15:32 +0200
committerGitHub <noreply@github.com>2025-06-03 17:15:32 +0200
commita9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d (patch)
tree6d354fdd36cf534d73e0cb81a7cacd3fedc1ebb9 /zellij-server/src/plugins
parentdocs(changelog): theme fixes (diff)
downloadsl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.tar.gz
sl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.tar.xz
sl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.zip
feat(ux): improve multiple select (#4221)
* intercept/clear-intercept key APIs * allow opening a pinned unfocused floating pane * rework plugin * improve some apis * fix tests * tests for pane groups * more exact placement and tests * plugin command permission and cleanup * improve some multiselect ux * improve plugin ui * remove old status indicator * allow moving plugin out of the way * style(fmt): rustfmt * update plugins * remove old keybinding * cleanups * fix: only rename pane if needed * changelog and some cleanups * style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/plugins')
-rw-r--r--zellij-server/src/plugins/mod.rs15
-rw-r--r--zellij-server/src/plugins/plugin_loader.rs1
-rw-r--r--zellij-server/src/plugins/plugin_map.rs4
-rw-r--r--zellij-server/src/plugins/unit/plugin_tests.rs216
-rw-r--r--zellij-server/src/plugins/wasm_bridge.rs11
-rw-r--r--zellij-server/src/plugins/zellij_exports.rs33
6 files changed, 274 insertions, 6 deletions
diff --git a/zellij-server/src/plugins/mod.rs b/zellij-server/src/plugins/mod.rs
index d7cb07d2..ec13df38 100644
--- a/zellij-server/src/plugins/mod.rs
+++ b/zellij-server/src/plugins/mod.rs
@@ -25,8 +25,8 @@ use wasm_bridge::WasmBridge;
use async_std::{channel, future::timeout, task};
use zellij_utils::{
data::{
- ClientInfo, Event, EventType, InputMode, MessageToPlugin, PermissionStatus, PermissionType,
- PipeMessage, PipeSource, PluginCapabilities,
+ ClientInfo, Event, EventType, FloatingPaneCoordinates, InputMode, MessageToPlugin,
+ PermissionStatus, PermissionType, PipeMessage, PipeSource, PluginCapabilities,
},
errors::{prelude::*, ContextType, PluginContext},
input::{
@@ -55,6 +55,8 @@ pub enum PluginInstruction {
Size,
Option<PathBuf>, // cwd
bool, // skip cache
+ Option<bool>, // should focus plugin
+ Option<FloatingPaneCoordinates>,
),
LoadBackgroundPlugin(RunPluginOrAlias, ClientId),
Update(Vec<(Option<PluginId>, Option<ClientId>, Event)>), // Focused plugin / broadcast, client_id, event data
@@ -281,6 +283,8 @@ pub(crate) fn plugin_thread_main(
size,
cwd,
skip_cache,
+ should_focus_plugin,
+ floating_pane_coordinates,
) => {
run_plugin_or_alias.populate_run_plugin_if_needed(&plugin_aliases);
let cwd = run_plugin_or_alias.get_initial_cwd().or(cwd);
@@ -306,6 +310,8 @@ pub(crate) fn plugin_thread_main(
pane_id_to_replace,
cwd,
start_suppressed,
+ floating_pane_coordinates,
+ should_focus_plugin,
Some(client_id),
)));
},
@@ -378,6 +384,8 @@ pub(crate) fn plugin_thread_main(
None,
start_suppressed,
None,
+ None,
+ None,
),
));
},
@@ -1070,7 +1078,8 @@ fn load_background_plugin(
pane_id_to_replace,
cwd,
start_suppressed,
- // None,
+ None,
+ None,
Some(client_id),
)));
},
diff --git a/zellij-server/src/plugins/plugin_loader.rs b/zellij-server/src/plugins/plugin_loader.rs
index 1dbe020e..4d8a4542 100644
--- a/zellij-server/src/plugins/plugin_loader.rs
+++ b/zellij-server/src/plugins/plugin_loader.rs
@@ -868,6 +868,7 @@ impl<'a> PluginLoader<'a> {
default_mode: self.default_mode.clone(),
subscriptions: Arc::new(Mutex::new(HashSet::new())),
keybinds: self.keybinds.clone(),
+ intercepting_key_presses: false,
stdin_pipe,
stdout_pipe,
};
diff --git a/zellij-server/src/plugins/plugin_map.rs b/zellij-server/src/plugins/plugin_map.rs
index 62020f4c..a92c291a 100644
--- a/zellij-server/src/plugins/plugin_map.rs
+++ b/zellij-server/src/plugins/plugin_map.rs
@@ -313,6 +313,7 @@ pub struct PluginEnv {
pub stdin_pipe: Arc<Mutex<VecDeque<u8>>>,
pub stdout_pipe: Arc<Mutex<VecDeque<u8>>>,
pub keybinds: Keybinds,
+ pub intercepting_key_presses: bool,
}
#[derive(Clone)]
@@ -457,4 +458,7 @@ impl RunningPlugin {
pub fn update_default_shell(&mut self, default_shell: Option<TerminalAction>) {
self.store.data_mut().default_shell = default_shell;
}
+ pub fn intercepting_key_presses(&self) -> bool {
+ self.store.data().intercepting_key_presses
+ }
}
diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs
index 60f850cc..276461d9 100644
--- a/zellij-server/src/plugins/unit/plugin_tests.rs
+++ b/zellij-server/src/plugins/unit/plugin_tests.rs
@@ -714,6 +714,8 @@ pub fn load_new_plugin_from_hd() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -794,6 +796,8 @@ pub fn load_new_plugin_with_plugin_alias() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -870,6 +874,8 @@ pub fn plugin_workers() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
// we send a SystemClipboardFailure to trigger the custom handler in the fixture plugin that
@@ -950,6 +956,8 @@ pub fn plugin_workers_persist_state() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
// we send a SystemClipboardFailure to trigger the custom handler in the fixture plugin that
@@ -1040,6 +1048,8 @@ pub fn can_subscribe_to_hd_events() {
size,
None,
false,
+ None,
+ None,
));
// extra long time because we only start the fs watcher on plugin load
std::thread::sleep(std::time::Duration::from_millis(5000));
@@ -1118,6 +1128,8 @@ pub fn switch_to_mode_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1190,6 +1202,8 @@ pub fn switch_to_mode_plugin_command_permission_denied() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1262,6 +1276,8 @@ pub fn new_tabs_with_layout_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1348,6 +1364,8 @@ pub fn new_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1420,6 +1438,8 @@ pub fn go_to_next_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1491,6 +1511,8 @@ pub fn go_to_previous_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1562,6 +1584,8 @@ pub fn resize_focused_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1633,6 +1657,8 @@ pub fn resize_focused_pane_with_direction_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1704,6 +1730,8 @@ pub fn focus_next_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1775,6 +1803,8 @@ pub fn focus_previous_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1846,6 +1876,8 @@ pub fn move_focus_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1917,6 +1949,8 @@ pub fn move_focus_or_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -1988,6 +2022,8 @@ pub fn edit_scrollback_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2059,6 +2095,8 @@ pub fn write_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2130,6 +2168,8 @@ pub fn write_chars_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2201,6 +2241,8 @@ pub fn toggle_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2272,6 +2314,8 @@ pub fn move_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2343,6 +2387,8 @@ pub fn move_pane_with_direction_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2415,6 +2461,8 @@ pub fn clear_screen_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2487,6 +2535,8 @@ pub fn scroll_up_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2558,6 +2608,8 @@ pub fn scroll_down_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2629,6 +2681,8 @@ pub fn scroll_to_top_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2700,6 +2754,8 @@ pub fn scroll_to_bottom_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2771,6 +2827,8 @@ pub fn page_scroll_up_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2842,6 +2900,8 @@ pub fn page_scroll_down_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2913,6 +2973,8 @@ pub fn toggle_focus_fullscreen_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -2984,6 +3046,8 @@ pub fn toggle_pane_frames_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3055,6 +3119,8 @@ pub fn toggle_pane_embed_or_eject_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3126,6 +3192,8 @@ pub fn undo_rename_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3197,6 +3265,8 @@ pub fn close_focus_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3268,6 +3338,8 @@ pub fn toggle_active_tab_sync_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3339,6 +3411,8 @@ pub fn close_focused_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3410,6 +3484,8 @@ pub fn undo_rename_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3481,6 +3557,8 @@ pub fn previous_swap_layout_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3552,6 +3630,8 @@ pub fn next_swap_layout_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3623,6 +3703,8 @@ pub fn go_to_tab_name_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3694,6 +3776,8 @@ pub fn focus_or_create_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3765,6 +3849,8 @@ pub fn go_to_tab() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3836,6 +3922,8 @@ pub fn start_or_reload_plugin() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3914,6 +4002,8 @@ pub fn quit_zellij_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -3992,6 +4082,8 @@ pub fn detach_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4070,6 +4162,8 @@ pub fn open_file_floating_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4152,6 +4246,8 @@ pub fn open_file_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4235,6 +4331,8 @@ pub fn open_file_with_line_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4317,6 +4415,8 @@ pub fn open_file_with_line_floating_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4399,6 +4499,8 @@ pub fn open_terminal_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4477,6 +4579,8 @@ pub fn open_terminal_floating_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4555,6 +4659,8 @@ pub fn open_command_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4633,6 +4739,8 @@ pub fn open_command_pane_floating_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4704,6 +4812,8 @@ pub fn switch_to_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4775,6 +4885,8 @@ pub fn hide_self_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4845,6 +4957,8 @@ pub fn show_self_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4916,6 +5030,8 @@ pub fn close_terminal_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -4987,6 +5103,8 @@ pub fn close_plugin_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5058,6 +5176,8 @@ pub fn focus_terminal_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5129,6 +5249,8 @@ pub fn focus_plugin_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5200,6 +5322,8 @@ pub fn rename_terminal_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5271,6 +5395,8 @@ pub fn rename_plugin_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5342,6 +5468,8 @@ pub fn rename_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5422,6 +5550,8 @@ pub fn send_configuration_to_plugins() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5490,6 +5620,8 @@ pub fn request_plugin_permissions() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5582,6 +5714,8 @@ pub fn granted_permission_request_result() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5673,6 +5807,8 @@ pub fn denied_permission_request_result() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5744,6 +5880,8 @@ pub fn run_command_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5822,6 +5960,8 @@ pub fn run_command_with_env_vars_and_cwd_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5900,6 +6040,8 @@ pub fn web_request_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -5971,6 +6113,8 @@ pub fn unblock_input_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6053,6 +6197,8 @@ pub fn block_input_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
// extra long time because we only start the fs watcher on plugin load
std::thread::sleep(std::time::Duration::from_millis(5000));
@@ -6143,6 +6289,8 @@ pub fn pipe_output_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6226,6 +6374,8 @@ pub fn pipe_message_to_plugin_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::CliPipe {
@@ -6320,6 +6470,8 @@ pub fn switch_session_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6401,6 +6553,8 @@ pub fn switch_session_with_layout_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6482,6 +6636,8 @@ pub fn switch_session_with_layout_and_cwd_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6563,6 +6719,8 @@ pub fn disconnect_other_clients_plugins_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6644,6 +6802,8 @@ pub fn reconfigure_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6729,6 +6889,8 @@ pub fn run_plugin_in_specific_cwd() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -6803,6 +6965,8 @@ pub fn hide_pane_with_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -6874,6 +7038,8 @@ pub fn show_pane_with_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -6952,6 +7118,8 @@ pub fn open_command_pane_background_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7027,6 +7195,8 @@ pub fn rerun_command_pane_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7098,6 +7268,8 @@ pub fn resize_pane_with_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7169,6 +7341,8 @@ pub fn edit_scrollback_for_pane_with_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7240,6 +7414,8 @@ pub fn write_to_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7311,6 +7487,8 @@ pub fn write_chars_to_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7382,6 +7560,8 @@ pub fn move_pane_with_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7453,6 +7633,8 @@ pub fn move_pane_with_pane_id_in_direction_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7524,6 +7706,8 @@ pub fn clear_screen_for_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7595,6 +7779,8 @@ pub fn scroll_up_in_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7666,6 +7852,8 @@ pub fn scroll_down_in_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7737,6 +7925,8 @@ pub fn scroll_to_top_in_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7808,6 +7998,8 @@ pub fn scroll_to_bottom_in_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7879,6 +8071,8 @@ pub fn page_scroll_up_in_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -7950,6 +8144,8 @@ pub fn page_scroll_down_in_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8021,6 +8217,8 @@ pub fn toggle_pane_id_fullscreen_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8092,6 +8290,8 @@ pub fn toggle_pane_embed_or_eject_for_pane_id_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8163,6 +8363,8 @@ pub fn close_tab_with_index_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8234,6 +8436,8 @@ pub fn break_panes_to_new_tab_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8305,6 +8509,8 @@ pub fn break_panes_to_tab_with_index_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8376,6 +8582,8 @@ pub fn reload_plugin_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8447,6 +8655,8 @@ pub fn load_new_plugin_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8525,6 +8735,8 @@ pub fn rebind_keys_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
@@ -8599,6 +8811,8 @@ pub fn list_clients_plugin_command() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
@@ -8670,6 +8884,8 @@ pub fn before_close_plugin_event() {
size,
None,
false,
+ None,
+ None,
));
std::thread::sleep(std::time::Duration::from_millis(5000));
// here we send an unload to plugin id 0 (the first plugin id, presumably this plugin)
diff --git a/zellij-server/src/plugins/wasm_bridge.rs b/zellij-server/src/plugins/wasm_bridge.rs
index d01a24e7..00b30aa1 100644
--- a/zellij-server/src/plugins/wasm_bridge.rs
+++ b/zellij-server/src/plugins/wasm_bridge.rs
@@ -324,6 +324,15 @@ impl WasmBridge {
for (_worker_name, worker_sender) in workers {
drop(worker_sender.send(MessageToWorker::Exit));
}
+ {
+ // if the plugin was intercepting key presses and for some reason did not clear
+ // this state, we make sure to do it ourselves so that the user will not get stuck
+ if running_plugin.lock().unwrap().intercepting_key_presses() {
+ let _ = self
+ .senders
+ .send_to_screen(ScreenInstruction::ClearKeyPressesIntercepts(client_id));
+ }
+ }
let subscriptions = subscriptions.lock().unwrap();
if subscriptions.contains(&EventType::BeforeClose) {
let mut running_plugin = running_plugin.lock().unwrap();
@@ -1436,6 +1445,8 @@ impl WasmBridge {
pane_id_to_replace,
cwd,
start_suppressed,
+ None,
+ None,
Some(client_id),
)));
vec![(plugin_id, Some(client_id))]
diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs
index f8dad922..ffc3fce9 100644
--- a/zellij-server/src/plugins/zellij_exports.rs
+++ b/zellij-server/src/plugins/zellij_exports.rs
@@ -73,9 +73,10 @@ pub fn zellij_exports(linker: &mut Linker<PluginEnv>) {
.unwrap();
}
-fn host_run_plugin_command(caller: Caller<'_, PluginEnv>) {
- let env = caller.data();
- let err_context = || format!("failed to run plugin command {}", env.name());
+fn host_run_plugin_command(mut caller: Caller<'_, PluginEnv>) {
+ let mut env = caller.data_mut();
+ let plugin_command = env.name();
+ let err_context = || format!("failed to run plugin command {}", plugin_command);
wasi_read_bytes(env)
.and_then(|bytes| {
let command: ProtobufPluginCommand = ProtobufPluginCommand::decode(bytes.as_slice())?;
@@ -455,6 +456,10 @@ fn host_run_plugin_command(caller: Caller<'_, PluginEnv>) {
PluginCommand::EmbedMultiplePanes(pane_ids) => {
embed_multiple_panes(env, pane_ids.into_iter().map(|p| p.into()).collect())
},
+ PluginCommand::InterceptKeyPresses => intercept_key_presses(&mut env),
+ PluginCommand::ClearKeyPressesIntercepts => {
+ clear_key_presses_intercepts(&mut env)
+ },
},
(PermissionStatus::Denied, permission) => {
log::error!(
@@ -2163,6 +2168,8 @@ fn load_new_plugin(
size,
cwd,
skip_cache,
+ None,
+ None,
));
},
Err(e) => {
@@ -2231,6 +2238,23 @@ fn embed_multiple_panes(env: &PluginEnv, pane_ids: Vec<PaneId>) {
));
}
+fn intercept_key_presses(env: &mut PluginEnv) {
+ env.intercepting_key_presses = true;
+ let _ = env
+ .senders
+ .send_to_screen(ScreenInstruction::InterceptKeyPresses(
+ env.plugin_id,
+ env.client_id,
+ ));
+}
+
+fn clear_key_presses_intercepts(env: &mut PluginEnv) {
+ env.intercepting_key_presses = false;
+ let _ = env
+ .senders
+ .send_to_screen(ScreenInstruction::ClearKeyPressesIntercepts(env.client_id));
+}
+
// Custom panic handler for plugins.
//
// This is called when a panic occurs in a plugin. Since most panics will likely originate in the
@@ -2409,6 +2433,9 @@ fn check_command_permission(
PermissionType::Reconfigure
},
PluginCommand::ChangeHostFolder(..) => PermissionType::FullHdAccess,
+ PluginCommand::InterceptKeyPresses | PluginCommand::ClearKeyPressesIntercepts => {
+ PermissionType::InterceptInput
+ },
_ => return (PermissionStatus::Granted, None),
};