Esc key is not detected by Keys iterator
Created by: iamcodemaker
When Esc
is pressed, the Keys iterator will block waiting for additional bytes. This makes it impossible to distinguish a plain Esc
key press from other escape sequences (this is necessary to implement vi emulation). This could be worked around by requesting multiple bytes each iteration for the Keys iterator. When a plain Esc
is pressed, only one byte should be read into the buffer. For other escape sequences multiple bytes would be read into the buffer.
Pseudo code:
let mut buf = [0; 2];
let len = stdio().read(&buf).unwrap();
match len {
0 => Eof;
1 => PlainKeyPress; // maybe Esc
2 => EscapeSequence; // read more bytes if it starts with \x1B
}