From 6be23659ef5e532eb5825380d436fa86cecd39d7 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Mon, 4 Jul 2016 09:24:51 -0700 Subject: Correctly handle Backspace and Delete The default characters sent for this were incorrect. Delete now sends xterm-compatible escapes (dch1, kdch1), and Backspace sends the delete code 0x7f. --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 5cf1be15..0cd1e674 100644 --- a/src/main.rs +++ b/src/main.rs @@ -230,8 +230,14 @@ fn main() { match event { glutin::Event::Closed => break 'main_loop, glutin::Event::ReceivedCharacter(c) => { - let encoded = c.encode_utf8(); - writer.write(encoded.as_slice()).unwrap(); + match c { + // Ignore BACKSPACE and DEL. These are handled specially. + '\u{8}' | '\u{7f}' => (), + _ => { + let encoded = c.encode_utf8(); + writer.write(encoded.as_slice()).unwrap(); + } + } }, glutin::Event::Resized(w, h) => { terminal.resize(w as f32, h as f32); -- cgit