Skip to content

nimterm/ansi

This page is generated from the module’s exported API and ## documentation comments.

ANSI-aware string walking, wrapping, and slicing for the TUI.

If s[i] starts an ANSI sequence, advance i past it and return true.

proc skipAnsi(s: string; i: var int): bool {.raises: [], tags: [], forbids: [].}

Returns: bool.

Name Type Default
s string
i var int

View source

proc stripAnsi(s: string): string {.raises: [], tags: [], forbids: [].}

Returns: string.

Name Type Default
s string

View source

Terminal columns ≈ rune count, ignoring ANSI escapes.

proc ansiVisibleWidth(s: string): int {.raises: [], tags: [], forbids: [].}

Returns: int.

Name Type Default
s string

View source

Wrap ANSI text without counting escape sequences as columns.

proc wrapAnsi(s: string; width: int; preferSpaces = false): seq[string] {.
raises: [], tags: [], forbids: [].}

Returns: seq[string].

Name Type Default
s string
width int
preferSpaces inferred false

View source