style library
The styles, the state and the parser, without the tables of constants.
A program that reads escape codes rather than writing them has no use for the several hundred ready-to-use strings the main import also brings, and this is the same surface without them. The styles and the parser live in one library, so both come together: writing a style and reading one back are two halves of the same thing.
Classes
- Apc
-
An application program command,
APC ... ST. - Color
- A colour a terminal can be asked for: one of the sixteen it names itself (Color16), one of the 256 in the table (Color256), or any of the sixteen million (ColorRgb).
- Color16
-
One of the sixteen colours a terminal names itself, set by
CSI 30throughCSI 37and their high-intensity pairs. - Color256
-
One of the 256 colours of the table
CSI 38;5,CSI 48;5andCSI 58;5reach: the sixteen the terminal names, a 6×6×6 cube, and 24 greys. - ColorRgb
-
A 24-bit colour, set by
CSI 38;2;r;g;band its background and underline pairs. - ControlString
-
A control string: an opener, a body, and the
STthat ends it. - Csi
-
A control sequence:
CSI, the parameters, and the byte that says what to do with them. - CsiCommon
- A control sequence the parser knows the name of.
- CsiParam
- A parameter of a control sequence, as it was written.
- CsiParamDefault
-
A parameter left out, standing for whatever default the sequence gives it:
the row of
CSI ;5 H, and both ofCSI H. - CsiParamNumber
-
A parameter carrying one number: the
5ofCSI 5 A. - CsiParamNumbers
-
A parameter carrying sub-parameters, separated by
:: the4:3ofCSI 4:3 m, the curly underline. - CsiPrivate
-
A control sequence the standard leaves to the terminal:
CSI ? 7 hand the rest of the private area, which is not a mistake but is not this package's to name. - CsiUnknown
- A control sequence whose final bytes name no function the standard allots, or whose parameters could not be read as numbers.
- CursorDown
-
Moves the cursor down n lines.
CSI n B, ControlSequencesFunctions.CUD. - CursorHPos
-
Moves the cursor to column n.
CSI n G, ControlSequencesFunctions.CHA. - CursorHVPos
-
Moves the cursor to row and col.
CSI row ; col f, ControlSequencesFunctions.HVP. - CursorLeft
-
Moves the cursor left n characters.
CSI n D, ControlSequencesFunctions.CUB. - CursorNextLine
-
Moves the cursor to the beginning of the line n lines down.
CSI n E, ControlSequencesFunctions.CNL. - CursorPos
-
Moves the cursor to row and col.
CSI row ; col H, ControlSequencesFunctions.CUP. - CursorPrevLine
-
Moves the cursor to the beginning of the line n lines up.
CSI n F, ControlSequencesFunctions.CPL. - CursorRight
-
Moves the cursor right n characters.
CSI n C, ControlSequencesFunctions.CUF. - CursorUp
-
Moves the cursor up n lines.
CSI n A, ControlSequencesFunctions.CUU. - Dcs
-
A device control string,
DCS ... ST: what a terminal reads as instructions for a device rather than for the screen — a sixel image, aDECRQSSquery, a termcap answer. - Entity
- A piece of a parsed string: either Text or an EscapeCode.
- EraseInLine
-
Erases part of the line.
CSI n K, ControlSequencesFunctions.EL. - EraseInPage
-
Erases part of the page.
CSI n J, ControlSequencesFunctions.ED. - Esc
-
An escape sequence that is
ESCand what follows it, without the[a Csi would have. - EscapeCode
- An escape code: a Csi control sequence, a ControlString — the Osc and the four the standard puts beside it — an Esc sequence, or something none of those could be made of.
- EscCommon
-
One of the independent control functions, ESC Fs:
RIS,LS2,DMIand the seven others the standard allots. - EscUnknown
-
An escape sequence this package has no name for: a byte the standard
keeps in reserve, or a sequence carrying intermediate bytes, such as the
ESC ( Bthat designates a character set. - ExtendedColor
-
A colour that only the extended sequences can set: the 256-colour table
and 24-bit RGB, which
CSI 38,CSI 48andCSI 58reach. - HideCursor
-
Hides the cursor.
CSI ? 25 l, the sequence hideCursor is written with. - NoStyle
- A style that adds nothing to the text.
- Osc
-
An operating system command:
OSC ... ST, the escape codes that talk to the terminal rather than to the screen. - OscLink
-
A hyperlink,
OSC 8: the text between an open and a close is what the terminal makes clickable. - OscUnknown
- An operating system command this package has no name for: setting the window title, asking after a colour, whatever else the terminal answers to.
- Parser
- A parser that processes strings containing ANSI escape codes and tracks the current Style.
-
Piece<
S extends State< S> > - One piece of a parsed string, and where and in what state it was found.
-
Pieces<
S extends State< S> > - An iterable collection of Piece objects representing the parsed ANSI escape codes and text segments in a string.
- Pm
-
A privacy message,
PM ... ST. - Printer
- A printer that processes ANSI escape codes and replaces the default text style.
- RestoreCursor
-
ESC 8, which brings back what SaveCursor put away, or the defaults where nothing was saved. - SaveCursor
-
ESC 7, which puts the cursor position and the style away for RestoreCursor to bring back. - ScrollDown
-
Scrolls the page down by n lines.
CSI n T, ControlSequencesFunctions.SD. - ScrollUp
-
Scrolls the page up by n lines.
CSI n S, ControlSequencesFunctions.SU. - Sgr
-
A Select Graphic Rendition sequence,
CSI ... m: the one that says how the text after it is to look. - SgrColorFunction
- A function setting one of the three colours: the foreground, the background or the underline.
- SgrDefaultFunction
-
A parameter left out, which stands for the reset:
CSI mtakes every style off, asCSI 0 mdoes. - SgrFunction
- One of the functions an Sgr sequence carries.
- SgrFunctionWithCode
- A function whose code this package has a name for.
- SgrSimpleFunction
-
A function that is its code and nothing else: the
1ofCSI 1 m, bold. - SgrUnderlineFunction
-
An underline function written with sub-parameters:
CSI 4:n m. - SgrUnknownColorFunctionFromParams
-
A colour whose parameters name no colour space this package reads: the
7ofCSI 38;7;1 m, where a5or a2was expected. - SgrUnknownColorFunctionFromValues
-
What SgrUnknownColorFunctionFromParams is, for a colour written with
sub-parameters: the
38:7:1ofCSI 38:7:1 m. - SgrUnknownParamFunction
-
A parameter naming no function this package knows: the
99ofCSI 99 m. - SgrUnknownParamsFunction
-
Sub-parameters naming no function this package knows: the
99:1ofCSI 99:1 m. - ShowCursor
-
Shows the cursor.
CSI ? 25 h, the sequence showCursor is written with. - SinkPrinter
- A printer that processes ANSI escape codes and writes the output to a StringSink.
- Sos
-
A string opened by
SOS, which the standard leaves for the application to interpret. - Stack
- Represents an active text style that tracks history via a stack.
- StackedParser
- A parser that processes strings containing ANSI escape codes and tracks the Stack of styles.
- StackedPrinter
- A printer that processes ANSI escape codes, replaces the default text style, and tracks the Stack of styles.
- StackedSinkPrinter
- A printer that processes ANSI escape codes, writes the output to a StringSink, and tracks the Stack of styles.
-
State<
S extends State< S> > - The base class for tracking the state of ANSI escape codes.
- Style
- Represents the currently active text style.
- Styles
- Every style that carries one thing, named and constant.
- Text
- A run of text, carrying no escape codes.
- UnknownEscapeCode
- What an escape code falls back to when it is none of Csi, ControlString or Esc.
- UseAlternateScreen
-
Switches to the alternate screen.
CSI ? 1049 h, the sequence useAlternateScreen is written with. - UseMainScreen
-
Switches back to the main screen.
CSI ? 1049 l, the sequence useMainScreen is written with.
Enums
- BlinkStyle
- Which blink the text carries.
- Colors
- ColorTarget
- What a colour is being set on.
- ControlFunctionsC0
- Control functions: elements of the C0 set.
- ControlFunctionsC1
- Control functions: elements of the C1 set.
- ControlFunctionsEscFs
- Independent control functions: the escape sequences of the form ESC Fs.
- ControlFunctionsSGR
- SGR control functions.
- ControlSequencesFunctions
- Control sequences.
- ErasePart
- The part of the page or of the line an erasing sequence takes out.
- FontSelection
- Which of the ten standard fonts is selected.
- FontShape
- Which slanted letter shape is active.
- FrameStyle
- Which of the two the text is wrapped in.
- IdeogramStyle
- Which ideogram rendition is active.
- ScriptStyle
- Where the text sits on the line.
- UnderlineStyle
- Which underline the text carries; underlining twice puts the single line out rather than adding to it.
Mixins
- UnrecognizedEscapeCode
- What a code has in common with the others this package cannot name.
Extensions
- StyleColors on Style
- Every colour of the 256-colour table, as a style of its own.
Functions
-
runZonedPrinter<
R> (R run(), {Style defaultStyle = Style.terminalColors, void output(String s)?, bool ansiCodesEnabled = true}) → R - Runs the given function in a zone where all print statements are processed by the printer.
-
runZonedStackedPrinter<
R> (R run(), {Style defaultStyle = Style.terminalColors, void output(String s)?, bool ansiCodesEnabled = true}) → R - Runs the given function in a zone where all print statements are processed by the stacked printer.
Exceptions / Errors
- UnfinishedSequenceException
- Thrown where an insertion would land inside a control sequence the parser could not finish.