pub struct VtMachine { /* private fields */ }Expand description
Virtual terminal state machine.
This is the main type in this crate, which takes Unicode scalar values and translates them into low-level events to be interpreted by a higher-level terminal emulator implementation.
VtMachine implements a Unicode-native terminal state machine that does
not support any legacy character encodings. If working with a raw byte
stream, such as from a pseudoterminal provided by the host OS, the caller
must first interpret the bytes as UTF-8 sequences and provide the result to
either VtMachine::write_u8char.
This implementation is not suitable for emulating a legacy hardware video terminal that used switchable character sets.
Implementations§
Source§impl VtMachine
impl VtMachine
Sourcepub fn write_u8char<'m>(
&'m mut self,
c: u8char,
) -> impl Iterator<Item = VtEvent<'m>>
pub fn write_u8char<'m>( &'m mut self, c: u8char, ) -> impl Iterator<Item = VtEvent<'m>>
Consumes a single unicode scalar value given as a u8char, returning
a series of events that the character causes.
The caller should consume the entire iterator in order to stay properly
synchronized with the VtMachine.
Sourcepub fn write_char<'m>(
&'m mut self,
c: char,
) -> impl Iterator<Item = VtEvent<'m>>
pub fn write_char<'m>( &'m mut self, c: char, ) -> impl Iterator<Item = VtEvent<'m>>
Consumes a single unicode scalar value given as a char.
Note that VtMachine uses u8char as its primary representation
of characters, and so this function is really just converting the given
char to u8char and then passing it to Self::write_u8char. If
you already have a u8char value then it’s better to use the other
function directly.
Sourcepub fn write_end(&mut self) -> impl Iterator<Item = VtEvent<'static>>
pub fn write_end(&mut self) -> impl Iterator<Item = VtEvent<'static>>
Tells the VtMachine that no more bytes are expected, such as if
the stream that the data is arriving from is closed from the writer
end.
This can potentially return some final events caused by ending sequences that had not yet been explicitly terminated.
It’s okay to keep using the VtMachine after calling this function,
but any subsequent character written will be treated as if it is the
first character in a new stream.