diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-03-27 19:19:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 19:19:34 +0200 |
commit | 341f9eb8c8771a59b2e4d238ba49ba88c3720d6d (patch) | |
tree | 51205536dd0789efb770dbe0095af7210a60eed3 /zellij-utils/src | |
parent | 7b609b053f3aaf466258e12be53d57614c8884c7 (diff) |
feat(plugins): async plugin loading (#2327)
* work
* refactor(plugins): break down start plugin async function
* work
* loading messages
* nice ui
* floating panes and error handling
* cleanups and conflicting plugin/direction
* find exact pane when relayouting
* fix plugin pane titles
* kill loading tasks on exit
* refactor: move stuff around
* style(fmt): rustfmt
* various fixes and refactors
Diffstat (limited to 'zellij-utils/src')
-rw-r--r-- | zellij-utils/src/cli.rs | 3 | ||||
-rw-r--r-- | zellij-utils/src/errors.rs | 8 | ||||
-rw-r--r-- | zellij-utils/src/input/actions.rs | 29 |
3 files changed, 38 insertions, 2 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index 3947dfad3..f232438b9 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -254,6 +254,9 @@ pub enum CliAction { #[clap(last(true))] command: Vec<String>, + #[clap(short, long, conflicts_with("command"), conflicts_with("direction"))] + plugin: Option<String>, + /// Change the working directory of the new pane #[clap(long, value_parser)] cwd: Option<PathBuf>, diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs index f1522c1de..8a0f63317 100644 --- a/zellij-utils/src/errors.rs +++ b/zellij-utils/src/errors.rs @@ -324,6 +324,11 @@ pub enum ScreenContext { PreviousSwapLayout, NextSwapLayout, QueryTabNames, + NewTiledPluginPane, + NewFloatingPluginPane, + AddPlugin, + UpdatePluginLoadingStage, + ProgressPluginLoadingOffset, } /// Stack call representations corresponding to the different types of [`PtyInstruction`]s. @@ -354,6 +359,7 @@ pub enum PluginContext { AddClient, RemoveClient, NewTab, + ApplyCachedEvents, } /// Stack call representations corresponding to the different types of [`ClientInstruction`]s. @@ -399,6 +405,8 @@ pub enum PtyWriteContext { #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum BackgroundJobContext { DisplayPaneError, + AnimatePluginLoading, + StopPluginLoadingAnimation, Exit, } diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index b2ec8d828..8e614d6de 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -2,7 +2,8 @@ use super::command::RunCommandAction; use super::layout::{ - FloatingPaneLayout, Layout, SwapFloatingLayout, SwapTiledLayout, TiledPaneLayout, + FloatingPaneLayout, Layout, RunPluginLocation, SwapFloatingLayout, SwapTiledLayout, + TiledPaneLayout, }; use crate::cli::CliAction; use crate::data::InputMode; @@ -225,6 +226,9 @@ pub enum Action { NextSwapLayout, /// Query all tab names QueryTabNames, + /// Open a new tiled (embedded, non-floating) plugin pane + NewTiledPluginPane(RunPluginLocation, Option<String>), // String is an optional name + NewFloatingPluginPane(RunPluginLocation, Option<String>), // String is an optional name } impl Action { @@ -270,13 +274,34 @@ impl Action { CliAction::NewPane { direction, command, + plugin, cwd, floating, name, close_on_exit, start_suspended, } => { - if !command.is_empty() { + if let Some(plugin) = plugin { + if floating { + let plugin = RunPluginLocation::parse(&plugin).map_err(|e| { + format!("Failed to parse plugin loction {plugin}: {}", e) + })?; + Ok(vec![Action::NewFloatingPluginPane(plugin, name)]) + } else { + let plugin = RunPluginLocation::parse(&plugin).map_err(|e| { + format!("Failed to parse plugin location {plugin}: {}", e) + })?; + // it is intentional that a new tiled plugin pane cannot include a + // direction + // this is because the cli client opening a tiled plugin pane is a + // different client than the one opening the pane, and this can potentially + // create very confusing races if the client changes focus while the plugin + // is being loaded + // this is not the case with terminal panes for historical reasons of + // backwards compatibility to a time before we had auto layouts + Ok(vec![Action::NewTiledPluginPane(plugin, name)]) + } + } else if !command.is_empty() { let mut command = command.clone(); let (command, args) = (PathBuf::from(command.remove(0)), command); let current_dir = get_current_dir(); |