AnsiDecoder
Defined in: packages/format-ansi/src/ansi-decoder.ts:40
Decodes an ANSI/VT100 character stream into text runs and escape sequences.
The single implementation of the ANSI read grammar: stripAnsiEscapes and
AnsiParseStream are both driven by this rather than repeating it.
Covers CSI (ESC [ and the 8-bit \u009B) and OSC (ESC ], terminated by
BEL or ST) — what this package’s own builders emit. An escape sequence still
arriving is reported as incomplete, so a sequence split across chunks is
reassembled rather than mistaken for text; an unterminated one at end of
input is emitted as text, which is the only lossless option left.
Written against string rather than Uint8Array because a text run must not
be split mid-character; byte-to-text conversion is the buffer’s job
(TextDecodeBuffer).
Implements
Section titled “Implements”Decoder<AnsiToken,string>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AnsiDecoder():
AnsiDecoder
Returns
Section titled “Returns”AnsiDecoder
Methods
Section titled “Methods”decode()
Section titled “decode()”decode(
view,context):DecodeResult<AnsiToken>
Defined in: packages/format-ansi/src/ansi-decoder.ts:41
Attempt to decode one value from the front of view.
view is a window into the driver’s buffer and is invalidated as soon as
this call returns. Copy anything retained in the returned value.
Parameters
Section titled “Parameters”string
context
Section titled “context”DecodeContext
Returns
Section titled “Returns”DecodeResult<AnsiToken>
Implementation of
Section titled “Implementation of”Decoder.decode