aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/input/handler.rs
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-03-11 22:43:43 +0100
committera-kenji <aks.kenji@protonmail.com>2021-03-11 22:43:43 +0100
commitacc2524105f811d1b32e3b993d91c67968efe33e (patch)
tree7cc1220bcbcc03e8e182572b893ac3c1526662d6 /src/common/input/handler.rs
parentPoking (diff)
parentdocs(readme): update demo gif (diff)
downloadsl0ppij-acc2524105f811d1b32e3b993d91c67968efe33e.tar.gz
sl0ppij-acc2524105f811d1b32e3b993d91c67968efe33e.tar.xz
sl0ppij-acc2524105f811d1b32e3b993d91c67968efe33e.zip
Merge 'upstream/main' into config-file
Diffstat (limited to 'src/common/input/handler.rs')
-rw-r--r--src/common/input/handler.rs53
1 files changed, 36 insertions, 17 deletions
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs
index 3438bba8..862cc0d2 100644
--- a/src/common/input/handler.rs
+++ b/src/common/input/handler.rs
@@ -8,7 +8,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};
@@ -231,6 +231,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 => {}
}
@@ -249,13 +271,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.
@@ -264,6 +285,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,
@@ -287,12 +309,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()));
}
@@ -300,8 +317,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()));
}
@@ -309,13 +326,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 }
}