diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-03-25 14:24:11 +0000 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-03-25 14:24:11 +0000 |
| commit | f2f77583848bce219fc098508fffde30fa366b89 (patch) | |
| tree | 391ac6129ddcc6ea0fe760dd206abaa97bde3b35 /src/common | |
| parent | Remove a dead input enum variant (diff) | |
| parent | fix(render): various rendering issues (#238) (diff) | |
| download | sl0ppij-f2f77583848bce219fc098508fffde30fa366b89.tar.gz sl0ppij-f2f77583848bce219fc098508fffde30fa366b89.tar.xz sl0ppij-f2f77583848bce219fc098508fffde30fa366b89.zip | |
Merge in changes from main and fix clippy lints
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/errors.rs | 2 | ||||
| -rw-r--r-- | src/common/input/handler.rs | 3 | ||||
| -rw-r--r-- | src/common/mod.rs | 4 | ||||
| -rw-r--r-- | src/common/screen.rs | 14 |
4 files changed, 22 insertions, 1 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs index b12a57a1..9afa694f 100644 --- a/src/common/errors.rs +++ b/src/common/errors.rs @@ -200,6 +200,7 @@ pub enum ScreenContext { CloseTab, GoToTab, UpdateTabName, + ChangeInputMode, } // FIXME: Just deriving EnumDiscriminants from strum will remove the need for any of this!!! @@ -240,6 +241,7 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::CloseTab => ScreenContext::CloseTab, ScreenInstruction::GoToTab(_) => ScreenContext::GoToTab, ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName, + ScreenInstruction::ChangeInputMode(_) => ScreenContext::ChangeInputMode, } } } diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 4b948cbf..f48ec7c9 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -132,6 +132,9 @@ impl InputHandler { input_mode: self.mode, }); self.send_screen_instructions + .send(ScreenInstruction::ChangeInputMode(self.mode)) + .unwrap(); + self.send_screen_instructions .send(ScreenInstruction::Render) .unwrap(); } diff --git a/src/common/mod.rs b/src/common/mod.rs index add50d47..d8957003 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -295,6 +295,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) { &full_screen_ws, os_input, max_panes, + InputMode::Normal, ); loop { let (event, mut err_ctx) = screen @@ -429,6 +430,9 @@ 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::Quit => { break; } diff --git a/src/common/screen.rs b/src/common/screen.rs index 57d893c9..89205f73 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::TabInfo; +use zellij_tile::data::{InputMode, TabInfo}; /// Instructions that can be sent to the [`Screen`]. #[derive(Debug, Clone)] @@ -50,6 +50,7 @@ pub enum ScreenInstruction { CloseTab, GoToTab(u32), UpdateTabName(Vec<u8>), + ChangeInputMode(InputMode), } /// A [`Screen`] holds multiple [`Tab`]s, each one holding multiple [`panes`](crate::client::panes). @@ -74,6 +75,7 @@ pub struct Screen { /// The [`OsApi`] this [`Screen`] uses. os_api: Box<dyn OsApi>, tabname_buf: String, + input_mode: InputMode, } impl Screen { @@ -86,6 +88,7 @@ impl Screen { full_screen_ws: &PositionAndSize, os_api: Box<dyn OsApi>, max_panes: Option<usize>, + input_mode: InputMode, ) -> Self { Screen { receiver: receive_screen_instructions, @@ -98,6 +101,7 @@ impl Screen { tabs: BTreeMap::new(), os_api, tabname_buf: String::new(), + input_mode, } } @@ -117,6 +121,7 @@ impl Screen { self.send_app_instructions.clone(), self.max_panes, Some(PaneId::Terminal(pane_id)), + self.input_mode, ); self.active_tab_index = Some(tab_index); self.tabs.insert(tab_index, tab); @@ -258,6 +263,7 @@ impl Screen { self.send_app_instructions.clone(), self.max_panes, None, + self.input_mode, ); tab.apply_layout(layout, new_pids); self.active_tab_index = Some(tab_index); @@ -302,4 +308,10 @@ impl Screen { } } } + pub fn change_input_mode(&mut self, input_mode: InputMode) { + self.input_mode = input_mode; + for tab in self.tabs.values_mut() { + tab.input_mode = self.input_mode; + } + } } |
