Skip to content

AnsiDoc

141 exports Added in v1.0.0 Source

Commands

Moves the cursor backward by the specified number of columns (default 1) relative to the current cursor position.

If the cursor is already at the edge of the screen, this has no effect.

Signature

declare const cursorBackward: (columns?: number) => AnsiDoc;

cursorDown

Added in v1.0.0 Source

Moves the cursor down by the specified number of lines (default 1) relative to the current cursor position.

If the cursor is already at the edge of the screen, this has no effect.

Signature

declare const cursorDown: (lines?: number) => AnsiDoc;

Moves the cursor forward by the specified number of columns (default 1) relative to the current cursor position.

If the cursor is already at the edge of the screen, this has no effect.

Signature

declare const cursorForward: (columns?: number) => AnsiDoc;

cursorHide

Added in v1.0.0 Source

Hides the cursor.

Signature

declare const cursorHide: AnsiDoc;

cursorLeft

Added in v1.0.0 Source

Moves the cursor to the first column of the current row.

Signature

declare const cursorLeft: AnsiDoc;

Moves cursor to beginning of the line the specified number of rows down (default 1).

Signature

declare const cursorNextLine: (rows?: number) => AnsiDoc;

Moves cursor to beginning of the line the specified number of rows up (default 1).

Signature

declare const cursorPrevLine: (rows?: number) => AnsiDoc;

Restores the cursor position, encoding shift state and formatting attributes from the previous save, if any, otherwise resets these all to their defaults.

Signature

declare const cursorRestorePosition: AnsiDoc;

Saves the cursor position, encoding shift state and formatting attributes.

Signature

declare const cursorSavePosition: AnsiDoc;

cursorShow

Added in v1.0.0 Source

Shows the cursor.

Signature

declare const cursorShow: AnsiDoc;

cursorUp

Added in v1.0.0 Source

Moves the cursor up by the specified number of lines (default 1) relative to the current cursor position.

If the cursor is already at the edge of the screen, this has no effect.

Signature

declare const cursorUp: (lines?: number) => AnsiDoc;

eraseDown

Added in v1.0.0 Source

Clears from the current cursor position to the end of the screen.

The current cursor position does not change.

Signature

declare const eraseDown: AnsiDoc;

eraseEndLine

Added in v1.0.0 Source

Clears from the current cursor position to the end of the current line.

The current cursor position does not change.

Signature

declare const eraseEndLine: AnsiDoc;

eraseLine

Added in v1.0.0 Source

Clears the current line.

The current cursor position does not change.

Signature

declare const eraseLine: AnsiDoc;

eraseLines

Added in v1.0.0 Source

Erase from the current cursor position up the specified amount of rows.

Signature

declare const eraseLines: (rows: number) => AnsiDoc;

eraseScreen

Added in v1.0.0 Source

Clears the entire screen and move the cursor to the upper left.

Signature

declare const eraseScreen: AnsiDoc;

Clears from the current cursor position to the start of the current line.

The current cursor position does not change.

Signature

declare const eraseStartLine: AnsiDoc;

eraseUp

Added in v1.0.0 Source

Clears from the current cursor position to the beginning of the screen.

The current cursor position does not change.

Signature

declare const eraseUp: AnsiDoc;

Constructors

beep

Added in v1.0.0 Source

Play a beeping sound.

Signature

declare const beep: AnsiDoc;

cursorMove

Added in v1.0.0 Source

Move the cursor position the specified number of rows and columns relative to the current cursor position.

If the cursor is already at the edge of the screen in either direction, then additional movement will have no effect.

Signature

declare const cursorMove: (column: number, row?: number) => AnsiDoc;

cursorTo

Added in v1.0.0 Source

Moves the cursor to the specified row and column.

Though the ANSI Control Sequence for Cursor Position is 1-based, this method takes row and column values starting from 0 and adjusts them to 1- based values.

Signature

declare const cursorTo: (column: number, row?: number) => AnsiDoc;

Destructors

render

Added in v1.0.0 Source

Text leaves are rendered verbatim, including control characters. Apply sanitize to untrusted subtrees before writing the result to a terminal. Use the raw document when embedded terminal sequences are trusted and intentional.

Signature

declare const render: {
  (config: RenderConfig): (self: Doc) => string;
  (self: Doc, config: RenderConfig): string;
};

Model

AnsiDoc type

Added in v1.0.0 Source

Signature

type AnsiDoc = Doc<Ansi>;

Other

Signature

type Annotated = any;

AnsiDoc

Added in v1.0.0 Source