diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/run.rs | 38 |
2 files changed, 27 insertions, 13 deletions
@@ -45,4 +45,4 @@ devicons = [ "phf" ] file_mimetype = [] mouse = [] recycle_bin = [ "trash" ] -default = [ "clipboard", "mouse", "phf", "recycle_bin" ] +default = [ "clipboard", "phf", "recycle_bin" ] @@ -1,6 +1,6 @@ use termion::event::Event; -use crate::commands::{CommandKeybind, JoshutoRunnable}; +use crate::commands::{CommandKeybind, JoshutoRunnable, KeyCommand}; use crate::config::{JoshutoCommandMapping, JoshutoConfig}; use crate::context::JoshutoContext; use crate::tab::JoshutoTab; @@ -45,26 +45,40 @@ pub fn run(config_t: JoshutoConfig, keymap_t: JoshutoCommandMapping) -> std::io: if !context.message_queue_ref().is_empty() { context.pop_msg(); } - match keymap_t.as_ref().get(&key) { - None => { - context.push_msg(format!("Unmapped input: {}", key.to_string())); + match key { + Event::Unsupported(s) if s.as_slice() == [27, 79, 65] => { + let command = KeyCommand::CursorMoveUp(1); + if let Err(e) = command.execute(&mut context, &mut backend) { + context.push_msg(e.to_string()); + } } - Some(CommandKeybind::SimpleKeybind(command)) => { + Event::Unsupported(s) if s.as_slice() == [27, 79, 66] => { + let command = KeyCommand::CursorMoveDown(1); if let Err(e) = command.execute(&mut context, &mut backend) { context.push_msg(e.to_string()); } } - Some(CommandKeybind::CompositeKeybind(m)) => { - let cmd = { - let mut menu = TuiCommandMenu::new(); - menu.get_input(&mut backend, &mut context, &m) - }; - - if let Some(command) = cmd { + key => match keymap_t.as_ref().get(&key) { + None => { + context.push_msg(format!("Unmapped input: {}", key.to_string())); + } + Some(CommandKeybind::SimpleKeybind(command)) => { if let Err(e) = command.execute(&mut context, &mut backend) { context.push_msg(e.to_string()); } } + Some(CommandKeybind::CompositeKeybind(m)) => { + let cmd = { + let mut menu = TuiCommandMenu::new(); + menu.get_input(&mut backend, &mut context, &m) + }; + + if let Some(command) = cmd { + if let Err(e) = command.execute(&mut context, &mut backend) { + context.push_msg(e.to_string()); + } + } + } } } context.flush_event(); |