visibleLength function

int visibleLength(
  1. String text
)

Returns the visible (printable) character count of text after stripping ANSI.

Use this when calculating column widths for styled text.

Example:

visibleLength('\x1B[32mHi\x1B[0m'); // 2

Implementation

int visibleLength(String text) {
  return stripAnsi(text).runes.length;
}