Handles CSI `~` sequences with multiple values (#70)

* Handles CSI `~` sequences with multiple values

Fixes #62

* Fix doc typo
This commit is contained in:
Alexandre Bury 2016-11-06 01:23:02 -08:00 committed by ticki
parent 786001f095
commit 8c82c461f9
1 changed files with 15 additions and 2 deletions

View File

@ -225,8 +225,21 @@ where I: Iterator<Item = Result<u8, Error>>
},
// Special key code.
b'~' => {
let num: u8 = String::from_utf8(buf).unwrap().parse().unwrap();
match num {
let str_buf = String::from_utf8(buf).unwrap();
// This CSI sequence can be a list of
// semicolon-separated numbers.
let nums: Vec<u8> = str_buf.split(';')
.map(|n| n.parse().unwrap())
.collect();
if nums.is_empty() {
return error;
}
// TODO: handle multiple values for key modififiers
// (ex: values [3, 2] means Shift+Delete)
match nums[0] {
1 | 7 => Event::Key(Key::Home),
2 => Event::Key(Key::Insert),
3 => Event::Key(Key::Delete),