Fix some input in pancurses backend

This commit is contained in:
Alexandre Bury 2016-10-11 12:31:15 -07:00
parent 3e766d3a28
commit 072c1d9b5c

View File

@ -86,7 +86,13 @@ impl backend::Backend for Concrete {
if let Some(ev) = self.window.getch() { if let Some(ev) = self.window.getch() {
match ev { match ev {
pancurses::Input::Character('\n') => Event::Key(Key::Enter), 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), 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), pancurses::Input::Unknown(i) => Event::Unknown(i),
// TODO: I honestly have no fucking idea what KeyCodeYes is // TODO: I honestly have no fucking idea what KeyCodeYes is
pancurses::Input::KeyCodeYes => Event::Refresh, pancurses::Input::KeyCodeYes => Event::Refresh,
@ -114,15 +120,15 @@ impl backend::Backend for Concrete {
pancurses::Input::KeyF14 => Event::Shift(Key::F2), pancurses::Input::KeyF14 => Event::Shift(Key::F2),
pancurses::Input::KeyF15 => Event::Shift(Key::F3), pancurses::Input::KeyF15 => Event::Shift(Key::F3),
pancurses::Input::KeyDL => Event::Refresh, 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::KeyDC => Event::Key(Key::Del),
pancurses::Input::KeyIC => Event::Refresh, pancurses::Input::KeyIC => Event::Key(Key::Ins),
pancurses::Input::KeyEIC => Event::Refresh, pancurses::Input::KeyEIC => Event::Refresh,
pancurses::Input::KeyClear => Event::Refresh, pancurses::Input::KeyClear => Event::Refresh,
pancurses::Input::KeyEOS => Event::Refresh, pancurses::Input::KeyEOS => Event::Refresh,
pancurses::Input::KeyEOL => Event::Refresh, pancurses::Input::KeyEOL => Event::Refresh,
pancurses::Input::KeySF => Event::Refresh, pancurses::Input::KeySF => Event::Shift(Key::Down),
pancurses::Input::KeySR => Event::Refresh, pancurses::Input::KeySR => Event::Shift(Key::Up),
pancurses::Input::KeyNPage => Event::Key(Key::PageDown), pancurses::Input::KeyNPage => Event::Key(Key::PageDown),
pancurses::Input::KeyPPage => Event::Key(Key::PageUp), pancurses::Input::KeyPPage => Event::Key(Key::PageUp),
pancurses::Input::KeySTab => Event::Shift(Key::Tab), pancurses::Input::KeySTab => Event::Shift(Key::Tab),
@ -143,7 +149,7 @@ impl backend::Backend for Concrete {
pancurses::Input::KeyCommand => Event::Refresh, pancurses::Input::KeyCommand => Event::Refresh,
pancurses::Input::KeyCopy => Event::Refresh, pancurses::Input::KeyCopy => Event::Refresh,
pancurses::Input::KeyCreate => 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::KeyExit => Event::Refresh,
pancurses::Input::KeyFind => Event::Refresh, pancurses::Input::KeyFind => Event::Refresh,
pancurses::Input::KeyHelp => Event::Refresh, pancurses::Input::KeyHelp => Event::Refresh,
@ -175,7 +181,7 @@ impl backend::Backend for Concrete {
pancurses::Input::KeySFind => Event::Refresh, pancurses::Input::KeySFind => Event::Refresh,
pancurses::Input::KeySHome => Event::Shift(Key::Home), pancurses::Input::KeySHome => Event::Shift(Key::Home),
pancurses::Input::KeySIC => Event::Shift(Key::Ins), 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::KeySMessage => Event::Refresh,
pancurses::Input::KeySMove => Event::Refresh, pancurses::Input::KeySMove => Event::Refresh,
pancurses::Input::KeySNext => Event::Shift(Key::PageDown), pancurses::Input::KeySNext => Event::Shift(Key::PageDown),
@ -184,14 +190,14 @@ impl backend::Backend for Concrete {
pancurses::Input::KeySPrint => Event::Refresh, pancurses::Input::KeySPrint => Event::Refresh,
pancurses::Input::KeySRedo => Event::Refresh, pancurses::Input::KeySRedo => Event::Refresh,
pancurses::Input::KeySReplace => 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::KeySResume => Event::Refresh,
pancurses::Input::KeySSave => Event::Refresh, pancurses::Input::KeySSave => Event::Refresh,
pancurses::Input::KeySSuspend => Event::Refresh, pancurses::Input::KeySSuspend => Event::Refresh,
pancurses::Input::KeySUndo => Event::Refresh, pancurses::Input::KeySUndo => Event::Refresh,
pancurses::Input::KeySuspend => Event::Refresh, pancurses::Input::KeySuspend => Event::Refresh,
pancurses::Input::KeyUndo => Event::Refresh, pancurses::Input::KeyUndo => Event::Refresh,
pancurses::Input::KeyResize => Event::Refresh, pancurses::Input::KeyResize => Event::WindowResize,
pancurses::Input::KeyEvent => Event::Refresh, pancurses::Input::KeyEvent => Event::Refresh,
// TODO: mouse support // TODO: mouse support
pancurses::Input::KeyMouse => Event::Refresh, pancurses::Input::KeyMouse => Event::Refresh,