summaryrefslogtreecommitdiffstats
path: root/zellij-utils
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-06-07 12:43:35 +0200
committerGitHub <noreply@github.com>2023-06-07 12:43:35 +0200
commitc11d75f9157873fc99fe0d40933de8ec5fbb4f6b (patch)
treefc55dc7f9132395585613dd9cce94c98c8c76600 /zellij-utils
parentb8f095330a57c905f23563ca7c2bfae3171abf57 (diff)
feat(wasm-plugin-system): major overhaul and some goodies (#2510)
* strider resiliency * worker channel prototype * finalized ui * show hide plugin * fs events to plugins * tests for events and new screen instructions * various refactoringz * report plugin errors instead of crashing zellij * fix plugin loading with workers * refactor: move watch filesystem * some fixes and refactoring * refactor(panes): combine pane insertion logic * refactor(screen): launch or focus * refactor(pty): consolidate default shell fetching * refactor: various cleanups * initial refactoring * more initial refactoring * refactor(strider): search * style(fmt): rustfmt * style(pty): cleanup * style(clippy): ok clippy * style(fmt): rustfmt
Diffstat (limited to 'zellij-utils')
-rw-r--r--zellij-utils/Cargo.toml2
-rwxr-xr-xzellij-utils/assets/plugins/compact-bar.wasmbin791665 -> 796418 bytes
-rwxr-xr-xzellij-utils/assets/plugins/fixture-plugin-for-tests.wasmbin732287 -> 725203 bytes
-rwxr-xr-xzellij-utils/assets/plugins/status-bar.wasmbin920797 -> 924326 bytes
-rwxr-xr-xzellij-utils/assets/plugins/strider.wasmbin916361 -> 968345 bytes
-rwxr-xr-xzellij-utils/assets/plugins/tab-bar.wasmbin762202 -> 766944 bytes
-rw-r--r--zellij-utils/src/cli.rs5
-rw-r--r--zellij-utils/src/data.rs5
-rw-r--r--zellij-utils/src/errors.rs2
-rw-r--r--zellij-utils/src/input/actions.rs12
-rw-r--r--zellij-utils/src/input/command.rs13
-rw-r--r--zellij-utils/src/kdl/mod.rs23
-rw-r--r--zellij-utils/src/lib.rs4
13 files changed, 63 insertions, 3 deletions
diff --git a/zellij-utils/Cargo.toml b/zellij-utils/Cargo.toml
index f12d8c78e..2469715f6 100644
--- a/zellij-utils/Cargo.toml
+++ b/zellij-utils/Cargo.toml
@@ -40,6 +40,8 @@ tempfile = "3.2.0"
kdl = { version = "4.5.0", features = ["span"] }
shellexpand = "3.0.0"
uuid = { version = "0.8.2", features = ["serde", "v4"] }
+notify = "6.0.0"
+async-channel = "1.8.0"
#[cfg(not(target_family = "wasm"))]
[target.'cfg(not(target_family = "wasm"))'.dependencies]
diff --git a/zellij-utils/assets/plugins/compact-bar.wasm b/zellij-utils/assets/plugins/compact-bar.wasm
index 3145fe1da..e033de69a 100755
--- a/zellij-utils/assets/plugins/compact-bar.wasm
+++ b/zellij-utils/assets/plugins/compact-bar.wasm
Binary files differ
diff --git a/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm b/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm
index a5421d720..cf68f60a0 100755
--- a/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm
+++ b/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm
Binary files differ
diff --git a/zellij-utils/assets/plugins/status-bar.wasm b/zellij-utils/assets/plugins/status-bar.wasm
index 8f7ed7826..317c839b0 100755
--- a/zellij-utils/assets/plugins/status-bar.wasm
+++ b/zellij-utils/assets/plugins/status-bar.wasm
Binary files differ
diff --git a/zellij-utils/assets/plugins/strider.wasm b/zellij-utils/assets/plugins/strider.wasm
index 929f5e8c7..51fcf72d7 100755
--- a/zellij-utils/assets/plugins/strider.wasm
+++ b/zellij-utils/assets/plugins/strider.wasm
Binary files differ
diff --git a/zellij-utils/assets/plugins/tab-bar.wasm b/zellij-utils/assets/plugins/tab-bar.wasm
index a8742f676..f58671b9b 100755
--- a/zellij-utils/assets/plugins/tab-bar.wasm
+++ b/zellij-utils/assets/plugins/tab-bar.wasm
Binary files differ
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs
index 14bcfae7a..b222af004 100644
--- a/zellij-utils/src/cli.rs
+++ b/zellij-utils/src/cli.rs
@@ -377,4 +377,9 @@ pub enum CliAction {
StartOrReloadPlugin {
url: Url,
},
+ LaunchOrFocusPlugin {
+ #[clap(short, long, value_parser)]
+ floating: bool,
+ url: Url,
+ },
}
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs
index 285532cc3..d470c2489 100644
--- a/zellij-utils/src/data.rs
+++ b/zellij-utils/src/data.rs
@@ -3,6 +3,7 @@ use crate::input::config::ConversionError;
use clap::ArgEnum;
use serde::{Deserialize, Serialize};
use std::fmt;
+use std::path::PathBuf;
use std::str::FromStr;
use strum_macros::{EnumDiscriminants, EnumIter, EnumString, ToString};
@@ -473,6 +474,10 @@ pub enum Event {
String, // message
String, // payload
),
+ FileSystemCreate(Vec<PathBuf>),
+ FileSystemRead(Vec<PathBuf>),
+ FileSystemUpdate(Vec<PathBuf>),
+ FileSystemDelete(Vec<PathBuf>),
}
/// Describes the different input modes, which change the way that keystrokes will be interpreted.
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index 74395e57a..239cf5ab8 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -333,6 +333,8 @@ pub enum ScreenContext {
ProgressPluginLoadingOffset,
StartPluginLoadingIndication,
RequestStateUpdateForPlugins,
+ LaunchOrFocusPlugin,
+ SuppressPane,
}
/// Stack call representations corresponding to the different types of [`PtyInstruction`]s.
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index c288b8d2b..36d59dde6 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -2,7 +2,7 @@
use super::command::RunCommandAction;
use super::layout::{
- FloatingPaneLayout, Layout, RunPluginLocation, SwapFloatingLayout, SwapTiledLayout,
+ FloatingPaneLayout, Layout, RunPlugin, RunPluginLocation, SwapFloatingLayout, SwapTiledLayout,
TiledPaneLayout,
};
use crate::cli::CliAction;
@@ -205,6 +205,7 @@ pub enum Action {
LeftClick(Position),
RightClick(Position),
MiddleClick(Position),
+ LaunchOrFocusPlugin(RunPlugin, bool), // bool => should float
LeftMouseRelease(Position),
RightMouseRelease(Position),
MiddleMouseRelease(Position),
@@ -474,6 +475,15 @@ impl Action {
CliAction::NextSwapLayout => Ok(vec![Action::NextSwapLayout]),
CliAction::QueryTabNames => Ok(vec![Action::QueryTabNames]),
CliAction::StartOrReloadPlugin { url } => Ok(vec![Action::StartOrReloadPlugin(url)]),
+ CliAction::LaunchOrFocusPlugin { url, floating } => {
+ let run_plugin_location = RunPluginLocation::parse(url.as_str())
+ .map_err(|e| format!("Failed to parse plugin location: {}", e))?;
+ let run_plugin = RunPlugin {
+ location: run_plugin_location,
+ _allow_exec_host_cmd: false,
+ };
+ Ok(vec![Action::LaunchOrFocusPlugin(run_plugin, floating)])
+ },
}
}
}
diff --git a/zellij-utils/src/input/command.rs b/zellij-utils/src/input/command.rs
index 3d2a87ab3..3212d26ec 100644
--- a/zellij-utils/src/input/command.rs
+++ b/zellij-utils/src/input/command.rs
@@ -68,3 +68,16 @@ impl From<RunCommandAction> for RunCommand {
}
}
}
+
+impl RunCommand {
+ pub fn new(command: PathBuf) -> Self {
+ RunCommand {
+ command,
+ ..Default::default()
+ }
+ }
+ pub fn with_cwd(mut self, cwd: PathBuf) -> Self {
+ self.cwd = Some(cwd);
+ self
+ }
+}
diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs
index dceaaf36c..58dda9c86 100644
--- a/zellij-utils/src/kdl/mod.rs
+++ b/zellij-utils/src/kdl/mod.rs
@@ -876,6 +876,29 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
};
Ok(Action::Run(run_command_action))
},
+ "LaunchOrFocusPlugin" => {
+ let arguments = action_arguments.iter().copied();
+ let mut args = kdl_arguments_that_are_strings(arguments)?;
+ if args.is_empty() {
+ return Err(ConfigError::new_kdl_error(
+ "No plugin found to launch in LaunchOrFocusPlugin".into(),
+ kdl_action.span().offset(),
+ kdl_action.span().len(),
+ ));
+ }
+ let plugin_path = args.remove(0);
+
+ let command_metadata = action_children.iter().next();
+ let should_float = command_metadata
+ .and_then(|c_m| kdl_child_bool_value_for_entry(c_m, "floating"))
+ .unwrap_or(false);
+ let location = RunPluginLocation::parse(&plugin_path)?;
+ let run_plugin = RunPlugin {
+ location,
+ _allow_exec_host_cmd: false,
+ };
+ Ok(Action::LaunchOrFocusPlugin(run_plugin, should_float))
+ },
"PreviousSwapLayout" => Ok(Action::PreviousSwapLayout),
"NextSwapLayout" => Ok(Action::NextSwapLayout),
_ => Err(ConfigError::new_kdl_error(
diff --git a/zellij-utils/src/lib.rs b/zellij-utils/src/lib.rs
index 2ee248060..87637de55 100644
--- a/zellij-utils/src/lib.rs
+++ b/zellij-utils/src/lib.rs
@@ -20,6 +20,6 @@ pub mod logging; // Requires log4rs
#[cfg(not(target_family = "wasm"))]
pub use ::{
- anyhow, async_std, clap, interprocess, lazy_static, libc, miette, nix, regex, serde,
- signal_hook, tempfile, termwiz, vte,
+ anyhow, async_channel, async_std, clap, interprocess, lazy_static, libc, miette, nix, notify,
+ regex, serde, signal_hook, tempfile, termwiz, vte,
};