diff options
| author | Jonah Caplan <jonahcaplan@gmail.com> | 2021-03-08 04:06:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-08 10:06:23 +0100 |
| commit | 44b0246e91ae65b09f3e2d9b111772a6b093135b (patch) | |
| tree | c1a422e0f9ffb02cb978ae4d5bb68018deb2a998 /src/common/input/handler.rs | |
| parent | New tab styling (#216) (diff) | |
| download | sl0ppij-44b0246e91ae65b09f3e2d9b111772a6b093135b.tar.gz sl0ppij-44b0246e91ae65b09f3e2d9b111772a6b093135b.tar.xz sl0ppij-44b0246e91ae65b09f3e2d9b111772a6b093135b.zip | |
feat(tabs): add ability to set tab name (#212)
* send all tabs in vec
* works but no input filtering
* add event types
* add event handler for tab events
* fmt fixups
* update tab name in place, and escape rename works
* rename handle_tab_event handle_tab_rename_keypress
* handle empty new_name when renaming
* fix(tabs): pad active tab name too
* fix(tabs): report proper length
* fix(tabs): always render active tab
* style(fmt): rustfmt
Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'src/common/input/handler.rs')
| -rw-r--r-- | src/common/input/handler.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 5c4f1971..52db9b4f 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 => {} } @@ -265,6 +287,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, @@ -310,10 +333,14 @@ 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())); |
