tsargp
    Preparing search index...

    Class AnsiString

    Implements concatenation of strings that can be printed on a terminal.

    Index

    Constructors

    Properties

    align: TextAlignment = 'left'

    Whether the string should be left- or right-aligned

    hook?: AnsiString

    The hooked string for line-wise wrapping.

    indent: number = 0

    The starting column for text wrapping

    lineCount: number = 1

    The number of lines in the string. Always positive.

    mergeFirst: boolean = false

    Whether the first word should be merged with the previous word.

    mergeLast: boolean = false

    Whether the last word should be merged with the next word.

    width: number = NaN

    The wrapping width relative to the indentation level

    words: (string | Style)[][] = []

    The list of words (including line feeds).

    Accessors

    Methods

    • Appends text that may contain styles.

      Parameters

      • text: StyledString

        The text to be appended (may be a plain string or another ANSI string)

      • split: boolean = false

        Whether to split the text if it is a plain string (defaults to false)

      Returns this

      The ANSI string instance

    • Appends line breaks.

      Parameters

      • count: number = 1

        The number of line breaks to insert (non-positive values are ignored)

      Returns this

      The ANSI string instance

    • Prepends text to the word at a specific position.

      Parameters

      • text: string

        The text to prepend (should contain no styles)

      • pos: number

        The position of the previously added word

      Returns this

      The ANSI string instance

    • Wraps the words to fit in a terminal width.

      Parameters

      • result: string[]

        The resulting list

      • currentColumn: number = 0

        The current terminal column

      • terminalWidth: number = NaN

        The desired terminal width (or zero or NaN to avoid wrapping)

      • emitStyles: boolean = false

        Whether styles should be emitted

      • emitSpaces: boolean = true

        Whether spaces should be emitted instead of move sequences

      • isHead: boolean = true

        Whether this string is the head of a chain for line-wise wrapping

      Returns number

      The updated terminal column