diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-01-27 17:52:39 -0500 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-01-27 17:52:39 -0500 |
commit | 9d7f75b2b5b5c51a723dc55b0e8ec3b999b21bcb (patch) | |
tree | 515794c057cff46651978380f1fa0621f7ea6b5a | |
parent | 25b2128bbfdf0b6b0e3431900c6b01a7b1ece080 (diff) |
add mouse scroll support without mouse terminal
-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(); |