diff options
| author | denis <denismaximov98@gmail.com> | 2021-03-31 14:32:54 +0300 |
|---|---|---|
| committer | denis <denismaximov98@gmail.com> | 2021-03-31 14:32:54 +0300 |
| commit | b8ee02d4bbb9a8af2fc89bab920fa1a92c2ab9b4 (patch) | |
| tree | 2c59a82d428443b03ce9f0ff105a2531ca3f0d3e /src/common | |
| parent | wip: need to set the default for Palette in the plugins (diff) | |
| parent | fix(plugin): send mode updates to subscribed plugins on load (diff) | |
| download | sl0ppij-b8ee02d4bbb9a8af2fc89bab920fa1a92c2ab9b4.tar.gz sl0ppij-b8ee02d4bbb9a8af2fc89bab920fa1a92c2ab9b4.tar.xz sl0ppij-b8ee02d4bbb9a8af2fc89bab920fa1a92c2ab9b4.zip | |
wip: does it take too long to load colors from xrdb?
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/errors.rs | 4 | ||||
| -rw-r--r-- | src/common/input/handler.rs | 2 | ||||
| -rw-r--r-- | src/common/mod.rs | 7 | ||||
| -rw-r--r-- | src/common/screen.rs | 15 |
4 files changed, 17 insertions, 11 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs index f5aeae85..56bf27f4 100644 --- a/src/common/errors.rs +++ b/src/common/errors.rs @@ -200,7 +200,7 @@ pub enum ScreenContext { CloseTab, GoToTab, UpdateTabName, - ChangeInputMode, + ChangeMode, } // FIXME: Just deriving EnumDiscriminants from strum will remove the need for any of this!!! @@ -241,7 +241,7 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::CloseTab => ScreenContext::CloseTab, ScreenInstruction::GoToTab(_) => ScreenContext::GoToTab, ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName, - ScreenInstruction::ChangeInputMode(_) => ScreenContext::ChangeInputMode, + ScreenInstruction::ChangeMode(_) => ScreenContext::ChangeMode, } } } diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index a843c7cc..c2f9ce93 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -130,7 +130,7 @@ impl InputHandler { )) .unwrap(); self.send_screen_instructions - .send(ScreenInstruction::ChangeInputMode(mode)) + .send(ScreenInstruction::ChangeMode(get_mode_info(mode))) .unwrap(); self.send_screen_instructions .send(ScreenInstruction::Render) diff --git a/src/common/mod.rs b/src/common/mod.rs index 1d9345b8..38f3b533 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -39,7 +39,7 @@ use wasm_vm::{wasi_stdout, wasi_write_string, zellij_imports, PluginInstruction} use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value}; use wasmer_wasi::{Pipe, WasiState}; use xrdb::Colors; -use zellij_tile::data::{EventType, InputMode, Palette}; +use zellij_tile::data::{EventType, InputMode, ModeInfo, Palette}; #[derive(Serialize, Deserialize, Debug)] pub enum ApiCommand { @@ -321,6 +321,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) { &full_screen_ws, os_input, max_panes, + ModeInfo::default(), InputMode::Normal, colors, ); @@ -455,8 +456,8 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) { ScreenInstruction::UpdateTabName(c) => { screen.update_active_tab_name(c); } - ScreenInstruction::ChangeInputMode(input_mode) => { - screen.change_input_mode(input_mode); + ScreenInstruction::ChangeMode(mode_info) => { + screen.change_mode(mode_info); } ScreenInstruction::Quit => { break; diff --git a/src/common/screen.rs b/src/common/screen.rs index e11b734d..bd8a72c9 100644 --- a/src/common/screen.rs +++ b/src/common/screen.rs @@ -13,7 +13,7 @@ use crate::tab::Tab; use crate::{errors::ErrorContext, wasm_vm::PluginInstruction}; use crate::{layout::Layout, panes::PaneId}; -use zellij_tile::data::{Event, InputMode, Palette, TabInfo}; +use zellij_tile::data::{Event, InputMode, ModeInfo, Palette, TabInfo}; /// Instructions that can be sent to the [`Screen`]. #[derive(Debug, Clone)] @@ -50,7 +50,7 @@ pub enum ScreenInstruction { CloseTab, GoToTab(u32), UpdateTabName(Vec<u8>), - ChangeInputMode(InputMode), + ChangeMode(ModeInfo), } /// A [`Screen`] holds multiple [`Tab`]s, each one holding multiple [`panes`](crate::client::panes). @@ -74,6 +74,7 @@ pub struct Screen { active_tab_index: Option<usize>, /// The [`OsApi`] this [`Screen`] uses. os_api: Box<dyn OsApi>, + mode_info: ModeInfo, input_mode: InputMode, colors: Palette, } @@ -88,6 +89,7 @@ impl Screen { full_screen_ws: &PositionAndSize, os_api: Box<dyn OsApi>, max_panes: Option<usize>, + mode_info: ModeInfo, input_mode: InputMode, colors: Palette, ) -> Self { @@ -101,6 +103,7 @@ impl Screen { active_tab_index: None, tabs: BTreeMap::new(), os_api, + mode_info, input_mode, colors, } @@ -122,6 +125,7 @@ impl Screen { self.send_app_instructions.clone(), self.max_panes, Some(PaneId::Terminal(pane_id)), + self.mode_info.clone(), self.input_mode, self.colors, ); @@ -265,6 +269,7 @@ impl Screen { self.send_app_instructions.clone(), self.max_panes, None, + self.mode_info.clone(), self.input_mode, self.colors, ); @@ -306,10 +311,10 @@ impl Screen { } self.update_tabs(); } - pub fn change_input_mode(&mut self, input_mode: InputMode) { - self.input_mode = input_mode; + pub fn change_mode(&mut self, mode_info: ModeInfo) { + self.mode_info = mode_info; for tab in self.tabs.values_mut() { - tab.input_mode = self.input_mode; + tab.mode_info = self.mode_info.clone(); } } } |
