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.
Procedures
Section titled “Procedures”skipAnsi
Section titled “skipAnsi”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.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
|
i |
var int |
stripAnsi
Section titled “stripAnsi”proc stripAnsi(s: string): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
ansiVisibleWidth
Section titled “ansiVisibleWidth”Terminal columns ≈ rune count, ignoring ANSI escapes.
proc ansiVisibleWidth(s: string): int {.raises: [], tags: [], forbids: [].}Returns: int.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
wrapAnsi
Section titled “wrapAnsi”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].
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
|
width |
int |
|
preferSpaces |
inferred |
false |