stringWidth function

int stringWidth(
  1. String text
)

Returns the total display width of text in terminal columns.

Implementation

int stringWidth(String text) {
  int width = 0;
  for (int i = 0; i < text.length; i++) {
    width += charWidth(text.codeUnitAt(i));
  }
  return width;
}