mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-12 20:23:35 +00:00
Recognizes more modified keys
Shift-tab and a few others
This commit is contained in:
parent
dd11d34206
commit
ae93b68c05
20
src/event.rs
20
src/event.rs
@ -26,6 +26,7 @@ pub enum Key {
|
||||
Enter,
|
||||
/// Tabulation key
|
||||
Tab,
|
||||
ShiftTab,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
@ -43,12 +44,17 @@ pub enum Key {
|
||||
/// may appear with a delay or along with the next key.
|
||||
Esc,
|
||||
// Left arrow while shift is pressed
|
||||
CtrlPageUp,
|
||||
CtrlPageDown,
|
||||
ShiftLeft,
|
||||
ShiftRight,
|
||||
ShiftCtrlLeft,
|
||||
ShiftCtrlRight,
|
||||
CtrlLeft,
|
||||
CtrlRight,
|
||||
CtrlUp,
|
||||
CtrlDown,
|
||||
CtrlDel,
|
||||
F(u8),
|
||||
CtrlChar(char),
|
||||
Unknown(i32),
|
||||
@ -64,10 +70,17 @@ impl Key {
|
||||
127 | ncurses::KEY_BACKSPACE => Key::Backspace,
|
||||
330 => Key::Del,
|
||||
331 => Key::Ins,
|
||||
// Those keys don't seem to be documented...
|
||||
515 => Key::CtrlDel,
|
||||
521 => Key::CtrlDown,
|
||||
541 => Key::CtrlLeft,
|
||||
542 => Key::ShiftCtrlLeft,
|
||||
546 => Key::CtrlPageDown,
|
||||
551 => Key::CtrlPageUp,
|
||||
556 => Key::CtrlRight,
|
||||
557 => Key::ShiftCtrlRight,
|
||||
562 => Key::CtrlUp,
|
||||
ncurses::KEY_BTAB => Key::ShiftTab,
|
||||
ncurses::KEY_SLEFT => Key::ShiftLeft,
|
||||
ncurses::KEY_SRIGHT => Key::ShiftRight,
|
||||
ncurses::KEY_LEFT => Key::Left,
|
||||
@ -79,6 +92,7 @@ impl Key {
|
||||
ncurses::KEY_HOME => Key::Home,
|
||||
ncurses::KEY_END => Key::End,
|
||||
f @ ncurses::KEY_F1 ... ncurses::KEY_F15 => Key::F((f - ncurses::KEY_F0) as u8),
|
||||
// Avoids 8-10 (H,I,J), they are used by other commands.
|
||||
c @ 1 ... 7 | c @ 11 ... 25 => Key::CtrlChar(('a' as u8 + (c-1) as u8) as char),
|
||||
_ => Key::Unknown(ch),
|
||||
}
|
||||
@ -96,12 +110,17 @@ impl fmt::Display for Key {
|
||||
Key::Right => "Right",
|
||||
Key::Down => "Down",
|
||||
Key::Up => "Up",
|
||||
Key::ShiftCtrlLeft => "Shift-Ctrl-Left",
|
||||
Key::ShiftCtrlRight => "Shift-Ctrl-Right",
|
||||
Key::ShiftLeft => "Shift-Left",
|
||||
Key::ShiftRight => "Shift-Right",
|
||||
Key::CtrlDel => "Ctrl-Del",
|
||||
Key::CtrlLeft => "Ctrl-Left",
|
||||
Key::CtrlRight => "Ctrl-Right",
|
||||
Key::CtrlUp => "Ctrl-Up",
|
||||
Key::CtrlDown => "Ctrl-Down",
|
||||
Key::CtrlPageUp => "Ctrl-PageUp",
|
||||
Key::CtrlPageDown => "Ctrl-PageDown",
|
||||
Key::PageUp => "PageUp",
|
||||
Key::PageDown => "PageDown",
|
||||
Key::Home => "Home",
|
||||
@ -109,6 +128,7 @@ impl fmt::Display for Key {
|
||||
Key::Backspace => "Backspace",
|
||||
Key::Del => "Del",
|
||||
Key::Enter => "Enter",
|
||||
Key::ShiftTab => "Shift-Tab",
|
||||
Key::Tab => "Tab",
|
||||
Key::Ins => "Ins",
|
||||
Key::Esc => "Esc",
|
||||
|
Loading…
Reference in New Issue
Block a user