measureStringWidth function
Measures the physical cell width of a string in a terminal, correctly accounting for CJK and Emoji characters that occupy 2 cells.
Implementation
int measureStringWidth(String text) {
if (text.isEmpty) return 0;
var width = 0;
for (final char in text.characters) {
width += isWideGrapheme(char) ? 2 : 1;
}
return width;
}