drawText method
Draws text starting at (x,y), one cell per rune, clipped to the row
and to maxWidth columns (when given). Tabs expand to a single space.
Returns the column just past the last painted cell.
Implementation
int drawText(int x, int y, String text, Style style, {int? maxWidth}) {
if (y < 0 || y >= height) return x;
final limit = maxWidth == null ? width : (x + maxWidth).clamp(0, width);
var col = x;
for (final rune in text.runes) {
if (col >= limit || col >= width) break;
if (col >= 0) {
final ch = rune == 0x09 ? ' ' : String.fromCharCode(rune);
_cells[_index(col, y)] = Cell(ch, style);
}
col++;
}
return col;
}