ui/ansi library
ANSI styling, and helpers that measure, truncate and wrap styled text by the number of terminal columns it takes up.
Classes
Functions
-
displayWidth(
String text) → int -
Columns
texttakes up on screen, ignoring escape sequences. -
padRight(
String text, int width) → String -
Pads
textwith spaces on the right towidthcolumns. -
runeWidth(
int rune) → int -
Columns taken by
rune: 0 for control and combining characters, 2 for wide East Asian characters and most emoji, 1 otherwise. -
truncate(
String text, int width, {String ellipsis = '…'}) → String -
Shortens
textto at mostwidthcolumns, ending it withellipsis. -
wrapText(
String text, int width) → List< String> -
Word-wraps
texttowidthcolumns. Escape sequences are kept and take no space; words longer than a line are broken.