Skip to content

AnsiToken

AnsiToken = { kind: "text"; text: string; } | { final: string; intermediates: string; kind: "csi"; parameters: string; } | { body: string; kind: "osc"; terminator: "bel" | "st"; }

Defined in: packages/format-ansi/src/ansi-token.ts:10

One unit of an ANSI byte stream.

text carries everything that is not an escape sequence; the sequence kinds keep their parameter and intermediate bytes verbatim, so an encoder can reproduce the original stream exactly.

{ kind: "text"; text: string; }


{ final: string; intermediates: string; kind: "csi"; parameters: string; }

readonly final: string

readonly intermediates: string

readonly kind: "csi"

ESC [ … final byte: cursor motion, erase, SGR.

readonly parameters: string


{ body: string; kind: "osc"; terminator: "bel" | "st"; }

readonly body: string

readonly kind: "osc"

ESC ] … BEL or ST: window title, OSC 8 hyperlink.

readonly terminator: "bel" | "st"

Which terminator closed it, since both are legal and round-trip.