mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 11:16:03 +00:00
Add Insert and Fn keys.
TODO: keys are apparently treated differently when shift is pressed. Find a better representation.
This commit is contained in:
parent
35c48e13d8
commit
6c69453639
55
src/event.rs
55
src/event.rs
@ -22,7 +22,9 @@ pub enum EventResult {
|
|||||||
|
|
||||||
#[derive(PartialEq,Eq,Clone,Copy,Hash)]
|
#[derive(PartialEq,Eq,Clone,Copy,Hash)]
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
|
/// Both Enter and numpad Enter
|
||||||
Enter,
|
Enter,
|
||||||
|
/// Tabulation key
|
||||||
Tab,
|
Tab,
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
ArrowRight,
|
ArrowRight,
|
||||||
@ -33,7 +35,25 @@ pub enum Key {
|
|||||||
Backspace,
|
Backspace,
|
||||||
Home,
|
Home,
|
||||||
End,
|
End,
|
||||||
|
/// Delete key
|
||||||
Del,
|
Del,
|
||||||
|
/// Insert key
|
||||||
|
Ins,
|
||||||
|
F1,
|
||||||
|
F2,
|
||||||
|
F3,
|
||||||
|
F4,
|
||||||
|
F5,
|
||||||
|
F6,
|
||||||
|
F7,
|
||||||
|
F8,
|
||||||
|
F9,
|
||||||
|
F10,
|
||||||
|
F11,
|
||||||
|
F12,
|
||||||
|
F13,
|
||||||
|
F14,
|
||||||
|
F15,
|
||||||
Unknown(i32),
|
Unknown(i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +61,11 @@ impl Key {
|
|||||||
pub fn from_ncurses(ch: i32) -> Self {
|
pub fn from_ncurses(ch: i32) -> Self {
|
||||||
match ch {
|
match ch {
|
||||||
9 => Key::Tab,
|
9 => Key::Tab,
|
||||||
10 => Key::Enter,
|
// Treat Return and the numpad Enter the same
|
||||||
|
10 | ncurses::KEY_ENTER => Key::Enter,
|
||||||
127 => Key::Backspace,
|
127 => Key::Backspace,
|
||||||
330 => Key::Del,
|
330 => Key::Del,
|
||||||
|
331 => Key::Ins,
|
||||||
ncurses::KEY_LEFT => Key::ArrowLeft,
|
ncurses::KEY_LEFT => Key::ArrowLeft,
|
||||||
ncurses::KEY_RIGHT => Key::ArrowRight,
|
ncurses::KEY_RIGHT => Key::ArrowRight,
|
||||||
ncurses::KEY_UP => Key::ArrowUp,
|
ncurses::KEY_UP => Key::ArrowUp,
|
||||||
@ -52,6 +74,21 @@ impl Key {
|
|||||||
ncurses::KEY_NPAGE => Key::PageDown,
|
ncurses::KEY_NPAGE => Key::PageDown,
|
||||||
ncurses::KEY_HOME => Key::Home,
|
ncurses::KEY_HOME => Key::Home,
|
||||||
ncurses::KEY_END => Key::End,
|
ncurses::KEY_END => Key::End,
|
||||||
|
ncurses::KEY_F1 => Key::F1,
|
||||||
|
ncurses::KEY_F2 => Key::F2,
|
||||||
|
ncurses::KEY_F3 => Key::F3,
|
||||||
|
ncurses::KEY_F4 => Key::F4,
|
||||||
|
ncurses::KEY_F5 => Key::F5,
|
||||||
|
ncurses::KEY_F6 => Key::F6,
|
||||||
|
ncurses::KEY_F7 => Key::F7,
|
||||||
|
ncurses::KEY_F8 => Key::F8,
|
||||||
|
ncurses::KEY_F9 => Key::F9,
|
||||||
|
ncurses::KEY_F10 => Key::F10,
|
||||||
|
ncurses::KEY_F11 => Key::F11,
|
||||||
|
ncurses::KEY_F12 => Key::F12,
|
||||||
|
ncurses::KEY_F13 => Key::F13,
|
||||||
|
ncurses::KEY_F14 => Key::F14,
|
||||||
|
ncurses::KEY_F15 => Key::F15,
|
||||||
_ => Key::Unknown(ch),
|
_ => Key::Unknown(ch),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,6 +111,22 @@ impl fmt::Display for Key {
|
|||||||
Key::Del => "Del",
|
Key::Del => "Del",
|
||||||
Key::Enter => "Enter",
|
Key::Enter => "Enter",
|
||||||
Key::Tab => "Tab",
|
Key::Tab => "Tab",
|
||||||
|
Key::Ins => "Ins",
|
||||||
|
Key::F1 => "F1",
|
||||||
|
Key::F2 => "F2",
|
||||||
|
Key::F3 => "F3",
|
||||||
|
Key::F4 => "F4",
|
||||||
|
Key::F5 => "F5",
|
||||||
|
Key::F6 => "F6",
|
||||||
|
Key::F7 => "F7",
|
||||||
|
Key::F8 => "F8",
|
||||||
|
Key::F9 => "F9",
|
||||||
|
Key::F10 => "F10",
|
||||||
|
Key::F11 => "F11",
|
||||||
|
Key::F12 => "F12",
|
||||||
|
Key::F13 => "F13",
|
||||||
|
Key::F14 => "F14",
|
||||||
|
Key::F15 => "F15",
|
||||||
_ => "",
|
_ => "",
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user