From 072c1d9b5c4c88f86e025f71992aa44b17b00e55 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Tue, 11 Oct 2016 12:31:15 -0700 Subject: [PATCH] Fix some input in pancurses backend --- src/backend/curses/pan.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/backend/curses/pan.rs b/src/backend/curses/pan.rs index 7fbe5a4..eb01eec 100644 --- a/src/backend/curses/pan.rs +++ b/src/backend/curses/pan.rs @@ -86,7 +86,13 @@ impl backend::Backend for Concrete { if let Some(ev) = self.window.getch() { match ev { pancurses::Input::Character('\n') => Event::Key(Key::Enter), + // TODO: wait for a very short delay. If more keys are + // pipelined, it may be an escape sequence. + pancurses::Input::Character('\u{1b}') => Event::Key(Key::Esc), + pancurses::Input::Character('\u{7f}') => Event::Key(Key::Backspace), pancurses::Input::Character(c) => Event::Char(c), + // TODO: Some key combos are not recognized by pancurses, + // but are sent as Unknown. We could still parse them here. pancurses::Input::Unknown(i) => Event::Unknown(i), // TODO: I honestly have no fucking idea what KeyCodeYes is pancurses::Input::KeyCodeYes => Event::Refresh, @@ -114,15 +120,15 @@ impl backend::Backend for Concrete { pancurses::Input::KeyF14 => Event::Shift(Key::F2), pancurses::Input::KeyF15 => Event::Shift(Key::F3), pancurses::Input::KeyDL => Event::Refresh, - pancurses::Input::KeyIL => Event::Key(Key::Ins), + pancurses::Input::KeyIL => Event::Refresh, pancurses::Input::KeyDC => Event::Key(Key::Del), - pancurses::Input::KeyIC => Event::Refresh, + pancurses::Input::KeyIC => Event::Key(Key::Ins), pancurses::Input::KeyEIC => Event::Refresh, pancurses::Input::KeyClear => Event::Refresh, pancurses::Input::KeyEOS => Event::Refresh, pancurses::Input::KeyEOL => Event::Refresh, - pancurses::Input::KeySF => Event::Refresh, - pancurses::Input::KeySR => Event::Refresh, + pancurses::Input::KeySF => Event::Shift(Key::Down), + pancurses::Input::KeySR => Event::Shift(Key::Up), pancurses::Input::KeyNPage => Event::Key(Key::PageDown), pancurses::Input::KeyPPage => Event::Key(Key::PageUp), pancurses::Input::KeySTab => Event::Shift(Key::Tab), @@ -143,7 +149,7 @@ impl backend::Backend for Concrete { pancurses::Input::KeyCommand => Event::Refresh, pancurses::Input::KeyCopy => Event::Refresh, pancurses::Input::KeyCreate => Event::Refresh, - pancurses::Input::KeyEnd => Event::Refresh, + pancurses::Input::KeyEnd => Event::Key(Key::End), pancurses::Input::KeyExit => Event::Refresh, pancurses::Input::KeyFind => Event::Refresh, pancurses::Input::KeyHelp => Event::Refresh, @@ -175,7 +181,7 @@ impl backend::Backend for Concrete { pancurses::Input::KeySFind => Event::Refresh, pancurses::Input::KeySHome => Event::Shift(Key::Home), pancurses::Input::KeySIC => Event::Shift(Key::Ins), - pancurses::Input::KeySLeft => Event::Refresh, + pancurses::Input::KeySLeft => Event::Shift(Key::Left), pancurses::Input::KeySMessage => Event::Refresh, pancurses::Input::KeySMove => Event::Refresh, pancurses::Input::KeySNext => Event::Shift(Key::PageDown), @@ -184,14 +190,14 @@ impl backend::Backend for Concrete { pancurses::Input::KeySPrint => Event::Refresh, pancurses::Input::KeySRedo => Event::Refresh, pancurses::Input::KeySReplace => Event::Refresh, - pancurses::Input::KeySRight => Event::Refresh, + pancurses::Input::KeySRight => Event::Shift(Key::Right), pancurses::Input::KeySResume => Event::Refresh, pancurses::Input::KeySSave => Event::Refresh, pancurses::Input::KeySSuspend => Event::Refresh, pancurses::Input::KeySUndo => Event::Refresh, pancurses::Input::KeySuspend => Event::Refresh, pancurses::Input::KeyUndo => Event::Refresh, - pancurses::Input::KeyResize => Event::Refresh, + pancurses::Input::KeyResize => Event::WindowResize, pancurses::Input::KeyEvent => Event::Refresh, // TODO: mouse support pancurses::Input::KeyMouse => Event::Refresh,