summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-02-26 15:30:15 +0100
committerGitHub <noreply@github.com>2024-02-26 15:30:15 +0100
commit21273ac95a2fed6b07d8550fe2d4f65993be7037 (patch)
treef5a7aa488ece8f21c17350bb3ec14ceaf15f60a7
parent27bffbf1533b4b2d3c10b1305557c75ddd121374 (diff)
feat(plugins): introduce plugin aliases (#3157)
* working prototype with passing tests * new tests and passing plugin tests as well * style(code): cleanups * cleanup strider from unused search feature * prototype of removing old plugin block from the config * aliases working from config file and all tests passing * fixups and cleanups * use aliases in layouts * update test snapshot * style(fmt): rustfmt
-rw-r--r--default-plugins/strider/src/main.rs138
-rw-r--r--default-plugins/strider/src/search/controls_line.rs353
-rw-r--r--default-plugins/strider/src/search/mod.rs317
-rw-r--r--default-plugins/strider/src/search/search_results.rs308
-rw-r--r--default-plugins/strider/src/search/search_state.rs264
-rw-r--r--default-plugins/strider/src/search/selection_controls_area.rs61
-rw-r--r--default-plugins/strider/src/search/ui.rs120
-rw-r--r--default-plugins/strider/src/state.rs22
-rw-r--r--zellij-client/src/lib.rs2
-rw-r--r--zellij-server/src/lib.rs13
-rw-r--r--zellij-server/src/panes/floating_panes/mod.rs7
-rw-r--r--zellij-server/src/panes/tiled_panes/mod.rs7
-rw-r--r--zellij-server/src/plugins/mod.rs214
-rw-r--r--zellij-server/src/plugins/unit/plugin_tests.rs415
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__load_new_plugin_with_plugin_alias.snap12
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__start_or_reload_plugin.snap22
-rw-r--r--zellij-server/src/plugins/wasm_bridge.rs283
-rw-r--r--zellij-server/src/plugins/zellij_exports.rs14
-rw-r--r--zellij-server/src/pty.rs14
-rw-r--r--zellij-server/src/route.rs4
-rw-r--r--zellij-server/src/screen.rs92
-rw-r--r--zellij-server/src/session_layout_metadata.rs5
-rw-r--r--zellij-server/src/tab/layout_applier.rs18
-rw-r--r--zellij-server/src/tab/mod.rs17
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__base_floating_layout_is_included_in_swap_layouts.snap4
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__floating_layout_with_plugins_and_commands_swaped_properly.snap4
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_floating_layouts_including_command_panes_absent_from_existing_layout.snap4
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_floating_layouts_not_including_command_panes_present_in_existing_layout.snap6
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_floating_layouts_not_including_plugin_panes_present_in_existing_layout.snap6
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_layouts_not_including_plugin_panes_present_in_existing_layout.snap6
-rw-r--r--zellij-server/src/tab/unit/tab_integration_tests.rs106
-rw-r--r--zellij-server/src/unit/screen_tests.rs194
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-2.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-3.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-4.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-6.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab-7.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_floating_plugin_pane_to_a_new_tab.snap6
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab-3.snap4
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab-4.snap4
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__screen_can_break_plugin_pane_to_a_new_tab.snap4
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_launch_or_focus_plugin_action.snap22
-rw-r--r--zellij-utils/assets/config/default.kdl14
-rw-r--r--zellij-utils/assets/layouts/compact.kdl2
-rw-r--r--zellij-utils/assets/layouts/compact.swap.kdl2
-rw-r--r--zellij-utils/assets/layouts/default.kdl4
-rw-r--r--zellij-utils/assets/layouts/default.swap.kdl4
-rw-r--r--zellij-utils/assets/layouts/disable-status-bar.kdl2
-rw-r--r--zellij-utils/assets/layouts/strider.kdl6
-rw-r--r--zellij-utils/assets/layouts/strider.swap.kdl6
-rw-r--r--zellij-utils/assets/layouts/welcome.kdl4
-rw-r--r--zellij-utils/src/cli.rs2
-rw-r--r--zellij-utils/src/input/actions.rs82
-rw-r--r--zellij-utils/src/input/config.rs86
-rw-r--r--zellij-utils/src/input/layout.rs196
-rw-r--r--zellij-utils/src/input/plugins.rs113
-rw-r--r--zellij-utils/src/input/unit/layout_test.rs47
-rw-r--r--zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_load_swap_layouts_from_a_different_file.snap134
-rw-r--r--zellij-utils/src/ipc.rs4
-rw-r--r--zellij-utils/src/kdl/kdl_layout_parser.rs31
-rw-r--r--zellij-utils/src/kdl/mod.rs99
-rw-r--r--zellij-utils/src/plugin_api/action.rs104
-rw-r--r--zellij-utils/src/session_serialization.rs31
-rw-r--r--zellij-utils/src/setup.rs14
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments-2.snap322
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap190
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap190
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap168
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap24
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap190
-rw-r--r--zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap190
71 files changed, 2119 insertions, 3264 deletions
diff --git a/default-plugins/strider/src/main.rs b/default-plugins/strider/src/main.rs
index 598bf61d4..2e06240af 100644
--- a/default-plugins/strider/src/main.rs
+++ b/default-plugins/strider/src/main.rs
@@ -1,49 +1,22 @@
-mod search;
mod state;
use colored::*;
-use search::{FileContentsWorker, FileNameWorker, MessageToSearch, ResultsOfSearch};
-use serde::{Deserialize, Serialize};
-use serde_json;
use state::{refresh_directory, FsEntry, State};
use std::collections::BTreeMap;
use std::{cmp::min, time::Instant};
use zellij_tile::prelude::*;
register_plugin!(State);
-register_worker!(FileNameWorker, file_name_search_worker, FILE_NAME_WORKER);
-register_worker!(
- FileContentsWorker,
- file_contents_search_worker,
- FILE_CONTENTS_WORKER
-);
impl ZellijPlugin for State {
fn load(&mut self, _configuration: BTreeMap<String, String>) {
refresh_directory(self);
- self.search_state.loading = true;
subscribe(&[
EventType::Key,
EventType::Mouse,
EventType::CustomMessage,
EventType::Timer,
- EventType::FileSystemCreate,
- EventType::FileSystemUpdate,
- EventType::FileSystemDelete,
- EventType::PermissionRequestResult,
]);
- post_message_to(PluginMessage {
- worker_name: Some("file_name_search".into()),
- name: serde_json::to_string(&MessageToSearch::ScanFolder).unwrap(),
- payload: "".into(),
- });
- post_message_to(PluginMessage {
- worker_name: Some("file_contents_search".into()),
- name: serde_json::to_string(&MessageToSearch::ScanFolder).unwrap(),
- payload: "".into(),
- });
- self.search_state.loading = true;
- set_timeout(0.5); // for displaying loading animation
}
fn update(&mut self, event: Event) -> bool {
@@ -55,58 +28,8 @@ impl ZellijPlugin for State {
};
self.ev_history.push_back((event.clone(), Instant::now()));
match event {
- Event::PermissionRequestResult(_) => {
- should_render = true;
- },
- Event::Timer(_elapsed) => {
- if self.search_state.loading {
- set_timeout(0.5);
- self.search_state.progress_animation();
- should_render = true;
- }
- },
- Event::CustomMessage(message, payload) => match serde_json::from_str(&message) {
- Ok(MessageToPlugin::UpdateFileNameSearchResults) => {
- if let Ok(results_of_search) = serde_json::from_str::<ResultsOfSearch>(&payload)
- {
- self.search_state
- .update_file_name_search_results(results_of_search);
- should_render = true;
- }
- },
- Ok(MessageToPlugin::UpdateFileContentsSearchResults) => {
- if let Ok(results_of_search) = serde_json::from_str::<ResultsOfSearch>(&payload)
- {
- self.search_state
- .update_file_contents_search_results(results_of_search);
- should_render = true;
- }
- },
- Ok(MessageToPlugin::DoneScanningFolder) => {
- self.search_state.loading = false;
- should_render = true;
- },
- Err(e) => eprintln!("Failed to deserialize custom message: {:?}", e),
- },
Event::Key(key) => match key {
- Key::Esc if self.typing_search_term() => {
- if self.search_state.search_term.is_empty() {
- self.stop_typing_search_term();
- } else {
- self.search_state.handle_key(key);
- }
- should_render = true;
- },
- _ if self.typing_search_term() => {
- self.search_state.handle_key(key);
- should_render = true;
- },
- Key::Char('/') => {
- self.start_typing_search_term();
- should_render = true;
- },
Key::Esc => {
- self.stop_typing_search_term();
hide_self();
should_render = true;
},
@@ -190,54 +113,6 @@ impl ZellijPlugin for State {
},
_ => {},
},
- Event::FileSystemCreate(paths) => {
- let paths: Vec<String> = paths
- .iter()
- .map(|p| p.to_string_lossy().to_string())
- .collect();
- post_message_to(PluginMessage {
- worker_name: Some("file_name_search".into()),
- name: serde_json::to_string(&MessageToSearch::FileSystemCreate).unwrap(),
- payload: serde_json::to_string(&paths).unwrap(),
- });
- post_message_to(PluginMessage {
- worker_name: Some("file_contents_search".into()),
- name: serde_json::to_string(&MessageTo