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-server/src/panes | |
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-server/src/panes')
-rw-r--r-- | zellij-server/src/panes/plugin_pane.rs | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs index c6896f90d..28828907e 100644 --- a/zellij-server/src/panes/plugin_pane.rs +++ b/zellij-server/src/panes/plugin_pane.rs @@ -6,7 +6,10 @@ use crate::panes::{grid::Grid, sixel::SixelImageStore, LinkHandler, PaneId}; use crate::plugins::PluginInstruction; use crate::pty::VteBytes; use crate::tab::Pane; -use crate::ui::pane_boundaries_frame::{FrameParams, PaneFrame}; +use crate::ui::{ + loading_indication::LoadingIndication, + pane_boundaries_frame::{FrameParams, PaneFrame}, +}; use crate::ClientId; use std::cell::RefCell; use std::rc::Rc; @@ -67,6 +70,7 @@ pub(crate) struct PluginPane { borderless: bool, pane_frame_color_override: Option<(PaletteColor, Option<String>)>, invoked_with: Option<Run>, + loading_indication: LoadingIndication, } impl PluginPane { @@ -81,10 +85,13 @@ impl PluginPane { terminal_emulator_color_codes: Rc<RefCell<HashMap<usize, String>>>, link_handler: Rc<RefCell<LinkHandler>>, character_cell_size: Rc<RefCell<Option<SizeInPixels>>>, + currently_connected_clients: Vec<ClientId>, style: Style, invoked_with: Option<Run>, ) -> Self { - Self { + let loading_indication = LoadingIndication::new(title.clone()).with_colors(style.colors); + let initial_loading_message = loading_indication.to_string(); + let mut plugin = PluginPane { pid, should_render: HashMap::new(), selectable: true, @@ -108,7 +115,12 @@ impl PluginPane { style, pane_frame_color_override: None, invoked_with, + loading_indication, + }; + for client_id in currently_connected_clients { + plugin.handle_plugin_bytes(client_id, initial_loading_message.as_bytes().to_vec()); } + plugin } } @@ -513,6 +525,24 @@ impl Pane for PluginPane { fn set_title(&mut self, title: String) { self.pane_title = title; } + fn update_loading_indication(&mut self, loading_indication: LoadingIndication) { + if self.loading_indication.ended { + return; + } + self.loading_indication.merge(loading_indication); + self.handle_plugin_bytes_for_all_clients( + self.loading_indication.to_string().as_bytes().to_vec(), + ); + } + fn progress_animation_offset(&mut self) { + if self.loading_indication.ended { + return; + } + self.loading_indication.progress_animation_offset(); + self.handle_plugin_bytes_for_all_clients( + self.loading_indication.to_string().as_bytes().to_vec(), + ); + } } impl PluginPane { @@ -527,4 +557,10 @@ impl PluginPane { fn set_client_should_render(&mut self, client_id: ClientId, should_render: bool) { self.should_render.insert(client_id, should_render); } + fn handle_plugin_bytes_for_all_clients(&mut self, bytes: VteBytes) { + let client_ids: Vec<ClientId> = self.grids.keys().copied().collect(); + for client_id in client_ids { + self.handle_plugin_bytes(client_id, bytes.clone()); + } + } } |