From 2c009f694bfe06c4170777ac2d8f69cf8efff162 Mon Sep 17 00:00:00 2001 From: nabijaczleweli Date: Mon, 10 Oct 2016 01:52:23 +0200 Subject: [PATCH] Add PauseBreak and F0 keys. Properly handle Tab --- src/backend/curses/pan.rs | 15 ++++++--------- src/event.rs | 6 ++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/backend/curses/pan.rs b/src/backend/curses/pan.rs index d570f0e..1811c9b 100644 --- a/src/backend/curses/pan.rs +++ b/src/backend/curses/pan.rs @@ -89,16 +89,14 @@ impl backend::Backend for PancursesBackend { pancurses::Input::Unknown(i) => Event::Unknown(i), // TODO: I honestly have no fucking idea what KeyCodeYes is pancurses::Input::KeyCodeYes => Event::Refresh, - // TODO: There seems to not be a Key::Break?? - pancurses::Input::KeyBreak => Event::Refresh, + pancurses::Input::KeyBreak => Event::Key(PauseBreak), pancurses::Input::KeyDown => Event::Key(Key::Down), pancurses::Input::KeyUp => Event::Key(Key::Up), pancurses::Input::KeyLeft => Event::Key(Key::Left), pancurses::Input::KeyRight => Event::Key(Key::Right), pancurses::Input::KeyHome => Event::Key(Key::Home), pancurses::Input::KeyBackspace => Event::Key(Key::Backspace), - // TODO: there seems to not be an F0 key for some reason? - pancurses::Input::KeyF0 => Event::Refresh, + pancurses::Input::KeyF0 => Event::Key(Key::F0), pancurses::Input::KeyF1 => Event::Key(Key::F1), pancurses::Input::KeyF2 => Event::Key(Key::F2), pancurses::Input::KeyF3 => Event::Key(Key::F3), @@ -129,10 +127,9 @@ impl backend::Backend for PancursesBackend { pancurses::Input::KeySR => Event::Refresh, pancurses::Input::KeyNPage => Event::Refresh, pancurses::Input::KeyPPage => Event::Refresh, - // TODO: no way to handle this - pancurses::Input::KeySTab => Event::Refresh, - pancurses::Input::KeyCTab => Event::CtrlChar('\t'), - pancurses::Input::KeyCATab => Event::Refresh, + pancurses::Input::KeySTab => Event::Shift(Key::Tab), + pancurses::Input::KeyCTab => Event::Ctrl(Key::Tab), + pancurses::Input::KeyCATab => Event::CtrlAlt(Key::Tab), pancurses::Input::KeyEnter => Event::Key(Key::Enter), // TODO: not sure what those are pancurses::Input::KeySReset => Event::Refresh, @@ -199,7 +196,7 @@ impl backend::Backend for PancursesBackend { pancurses::Input::KeyUndo => Event::Refresh, pancurses::Input::KeyResize => Event::Refresh, pancurses::Input::KeyEvent => Event::Refresh, - // TODO: not sure how to handle this + // TODO: mouse support pancurses::Input::KeyMouse => Event::Refresh, // TODO: not sure what those are pancurses::Input::KeyA1 => Event::Refresh, diff --git a/src/event.rs b/src/event.rs index 7abeaad..a677789 100644 --- a/src/event.rs +++ b/src/event.rs @@ -114,9 +114,14 @@ pub enum Key { /// Page Down key PageDown, + /// Pause Break key + PauseBreak, + /// The 5 in the center of the keypad, when numlock is disabled. NumpadCenter, + /// F0 key + F0, /// F1 key F1, /// F2 key @@ -153,6 +158,7 @@ impl Key { /// If `n == 0 || n > 12` pub fn from_f(n: u8) -> Key { match n { + 0 => Key::F0, 1 => Key::F1, 2 => Key::F2, 3 => Key::F3,