Add an Iterator on Read that provides both the parsed event and the byte sequence that defines it
Created by: ftilde
This is useful, e.g., for implementing a terminal multiplexer where the raw input should in some cases be passed on to another tty.
Some thoughts on the implementation:
- The function that creates the trait is implemented in a separate extension trait. This is kind of ugly, but (as far as I understand) necessary to ensure backwards compatibility. Although I don't see why the would, users may have implemented
TermRead
for their own types. My suggestion is to provide the newly added functionevents_and_raw
in a separate trait for following point releases, but merge it intoTermRead
in a future 2.0 release of Termion. - The byte sequence is provided as a
Vec<u8>
. This follows the definition of Event::Unsupported. Other options may includeBox<[u8]>
, which is smaller on the stack (as far as i know), but less versatile. We could also pull in smallvec and use something likeSmallVec4<u8>
, but I am not sure if this is worth it. Tell me if you would like me to change the type.