Add support for some ctrl keys

Ctrl-{Ins,Del,Home,End} now work in some terminals.
Tested with xterm and konsole. May not work fot VTE-based ones
(gnome and xfce).
This commit is contained in:
Alexandre Bury 2015-06-01 10:49:43 -07:00
parent f81a9b2768
commit 405cd1e961

View File

@ -35,13 +35,16 @@ pub enum Key {
PageDown, PageDown,
Backspace, Backspace,
Home, Home,
CtrlHome,
End, End,
CtrlEnd,
/// Delete key /// Delete key
Del, Del,
ShiftDel, ShiftDel,
CtrlDel, CtrlDel,
/// Insert key /// Insert key
Ins, Ins,
CtrlIns,
/// Escape key. Often buffered by the terminal, /// Escape key. Often buffered by the terminal,
/// may appear with a delay or along with the next key. /// may appear with a delay or along with the next key.
Esc, Esc,
@ -79,6 +82,9 @@ impl Key {
// Those keys don't seem to be documented... // Those keys don't seem to be documented...
515 => Key::CtrlDel, 515 => Key::CtrlDel,
521 => Key::CtrlDown, 521 => Key::CtrlDown,
526 => Key::CtrlEnd,
531 => Key::CtrlHome,
536 => Key::CtrlIns,
541 => Key::CtrlLeft, 541 => Key::CtrlLeft,
542 => Key::CtrlShiftLeft, 542 => Key::CtrlShiftLeft,
546 => Key::CtrlPageDown, 546 => Key::CtrlPageDown,
@ -144,13 +150,16 @@ impl fmt::Display for Key {
Key::PageUp => "PageUp", Key::PageUp => "PageUp",
Key::PageDown => "PageDown", Key::PageDown => "PageDown",
Key::Home => "Home", Key::Home => "Home",
Key::CtrlHome => "Ctrl-Home",
Key::End => "End", Key::End => "End",
Key::CtrlEnd => "Ctrl-End",
Key::Backspace => "Backspace", Key::Backspace => "Backspace",
Key::Del => "Del", Key::Del => "Del",
Key::Enter => "Enter", Key::Enter => "Enter",
Key::ShiftTab => "Shift-Tab", Key::ShiftTab => "Shift-Tab",
Key::Tab => "Tab", Key::Tab => "Tab",
Key::Ins => "Ins", Key::Ins => "Ins",
Key::CtrlIns => "Ctrl-Ins",
Key::Esc => "Esc", Key::Esc => "Esc",
_ => "Missing key label", _ => "Missing key label",
}), }),