From 4bc411998786b0893a18df4d88012470d42abf91 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Sat, 16 Jul 2016 12:25:57 -0700 Subject: Fix Control-H bug Glutin sends both a received character and the key pressed event when a key is pressed. Because delete and backspace are mapped in reverse by terminal standards, we ignore the received character 0x07 and 0x7f values. However, this breaks Control-H since this normally sends 0x07 as well. The fix here adds handling for Control-H through the input tracking system. --- src/input.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/input.rs b/src/input.rs index 22e8eeb3..f452aa4e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -230,6 +230,15 @@ static F12_BINDINGS: &'static [Binding] = &[ Binding { mods: modifier::ANY, send: "\x1b[24~", mode: mode::ANY, notmode: mode::NONE }, ]; +/// Bindings for the H key +/// +/// Control-H sends 0x08 normally, but we capture that in ReceivedCharacter +/// since DEL and BACKSPACE are inverted. This binding is a work around to that +/// capture. +static H_BINDINGS: &'static [Binding] = &[ + Binding { mods: modifier::CONTROL, send: "\x08", mode: mode::ANY, notmode: mode::NONE }, +]; + /// Bindings for the Backspace key static BACKSPACE_BINDINGS: &'static [Binding] = &[ Binding { mods: modifier::ANY, send: "\x7f", mode: mode::ANY, notmode: mode::NONE }, @@ -300,6 +309,7 @@ impl Processor { VirtualKeyCode::F12 => F12_BINDINGS, VirtualKeyCode::Back => BACKSPACE_BINDINGS, VirtualKeyCode::Delete => DELETE_BINDINGS, + VirtualKeyCode::H => H_BINDINGS, // Mode keys ignored now VirtualKeyCode::LAlt | VirtualKeyCode::RAlt | VirtualKeyCode::LShift | VirtualKeyCode::RShift | VirtualKeyCode::LControl | VirtualKeyCode::RControl | @@ -307,7 +317,7 @@ impl Processor { // All of the alphanumeric keys get passed through here as well, but there's no work // to be done for them. VirtualKeyCode::A | VirtualKeyCode::B | VirtualKeyCode::C | VirtualKeyCode::D | - VirtualKeyCode::E | VirtualKeyCode::F | VirtualKeyCode::G | VirtualKeyCode::H | + VirtualKeyCode::E | VirtualKeyCode::F | VirtualKeyCode::G | VirtualKeyCode::I | VirtualKeyCode::J | VirtualKeyCode::K | VirtualKeyCode::L | VirtualKeyCode::M | VirtualKeyCode::N | VirtualKeyCode::O | VirtualKeyCode::P | VirtualKeyCode::Q | VirtualKeyCode::R | VirtualKeyCode::S | VirtualKeyCode::T | -- cgit