Handles CSI `~` sequences with multiple values (#70)
* Handles CSI `~` sequences with multiple values Fixes #62 * Fix doc typo
This commit is contained in:
parent
786001f095
commit
8c82c461f9
17
src/event.rs
17
src/event.rs
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue