diff options
| author | denis <denismaximov98@gmail.com> | 2021-03-17 10:05:43 +0200 |
|---|---|---|
| committer | denis <denismaximov98@gmail.com> | 2021-03-17 10:05:43 +0200 |
| commit | 448c426c2b8ca925f2a8016171988a5c824f66d3 (patch) | |
| tree | 610d3f367fc78bdf73e37343118892f78c3f05ad /src/common/input/handler.rs | |
| parent | wip: need to debug somehow (diff) | |
| parent | Performance: only render panes that should be updated (#234) (diff) | |
| download | sl0ppij-448c426c2b8ca925f2a8016171988a5c824f66d3.tar.gz sl0ppij-448c426c2b8ca925f2a8016171988a5c824f66d3.tar.xz sl0ppij-448c426c2b8ca925f2a8016171988a5c824f66d3.zip | |
Merge branch 'main' into focused-pane
Diffstat (limited to 'src/common/input/handler.rs')
| -rw-r--r-- | src/common/input/handler.rs | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 5c4f1971..57bb46fb 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -7,7 +7,7 @@ use crate::errors::ContextType; use crate::os_input_output::OsApi; use crate::pty_bus::PtyInstruction; use crate::screen::ScreenInstruction; -use crate::wasm_vm::PluginInstruction; +use crate::wasm_vm::{EventType, PluginInputType, PluginInstruction}; use crate::CommandIsExecuting; use serde::{Deserialize, Serialize}; @@ -232,6 +232,28 @@ impl InputHandler { .send(ScreenInstruction::GoToTab(i)) .unwrap(); } + Action::TabNameInput(c) => { + self.send_plugin_instructions + .send(PluginInstruction::Input( + PluginInputType::Event(EventType::Tab), + c.clone(), + )) + .unwrap(); + self.send_screen_instructions + .send(ScreenInstruction::UpdateTabName(c)) + .unwrap(); + } + Action::SaveTabName => { + self.send_plugin_instructions + .send(PluginInstruction::Input( + PluginInputType::Event(EventType::Tab), + vec![b'\n'], + )) + .unwrap(); + self.send_screen_instructions + .send(ScreenInstruction::UpdateTabName(vec![b'\n'])) + .unwrap(); + } Action::NoOp => {} } @@ -250,13 +272,12 @@ impl InputHandler { /// Describes the different input modes, which change the way that keystrokes will be interpreted. #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, EnumIter, Serialize, Deserialize)] pub enum InputMode { - /// In `Normal` mode, input is always written to the terminal, except for one special input that - /// triggers the switch to [`InputMode::Command`] mode. + /// In `Normal` mode, input is always written to the terminal, except for the shortcuts leading + /// to other modes Normal, - /// In `Command` mode, input is bound to actions (more precisely, sequences of actions). - /// `Command` mode gives access to the other modes non-`InputMode::Normal` modes. - /// etc. - Command, + /// In `Locked` mode, input is always written to the terminal and all shortcuts are disabled + /// except the one leading back to normal mode + Locked, /// `Resize` mode allows resizing the different existing panes. Resize, /// `Pane` mode allows creating and closing panes, as well as moving between them. @@ -265,6 +286,7 @@ pub enum InputMode { Tab, /// `Scroll` mode allows scrolling up and down within a pane. Scroll, + RenameTab, } /// Represents the contents of the help message that is printed in the status bar, @@ -288,12 +310,7 @@ impl Default for InputMode { pub fn get_help(mode: InputMode) -> Help { let mut keybinds: Vec<(String, String)> = vec![]; match mode { - InputMode::Normal | InputMode::Command => { - keybinds.push(("p".to_string(), "PANE".to_string())); - keybinds.push(("t".to_string(), "TAB".to_string())); - keybinds.push(("r".to_string(), "RESIZE".to_string())); - keybinds.push(("s".to_string(), "SCROLL".to_string())); - } + InputMode::Normal | InputMode::Locked => {} InputMode::Resize => { keybinds.push(("←↓↑→".to_string(), "Resize".to_string())); } @@ -301,8 +318,8 @@ pub fn get_help(mode: InputMode) -> Help { keybinds.push(("←↓↑→".to_string(), "Move focus".to_string())); keybinds.push(("p".to_string(), "Next".to_string())); keybinds.push(("n".to_string(), "New".to_string())); - keybinds.push(("d".to_string(), "Split down".to_string())); - keybinds.push(("r".to_string(), "Split right".to_string())); + keybinds.push(("d".to_string(), "Down split".to_string())); + keybinds.push(("r".to_string(), "Right split".to_string())); keybinds.push(("x".to_string(), "Close".to_string())); keybinds.push(("f".to_string(), "Fullscreen".to_string())); } @@ -310,13 +327,15 @@ pub fn get_help(mode: InputMode) -> Help { keybinds.push(("←↓↑→".to_string(), "Move focus".to_string())); keybinds.push(("n".to_string(), "New".to_string())); keybinds.push(("x".to_string(), "Close".to_string())); + keybinds.push(("r".to_string(), "Rename".to_string())); } InputMode::Scroll => { keybinds.push(("↓↑".to_string(), "Scroll".to_string())); } + InputMode::RenameTab => { + keybinds.push(("Enter".to_string(), "when done".to_string())); + } } - keybinds.push(("ESC".to_string(), "BACK".to_string())); - keybinds.push(("q".to_string(), "QUIT".to_string())); Help { mode, keybinds } } |
