play method
Replays output and gives back the rows, without trailing spaces.
Implementation
List<String> play(String output) {
final codes = RegExp(
r'\x1B\[([0-9;?]*)([A-Za-z])|\x1B\][^\x07\x1B]*(?:\x07|\x1B\\)|\x1B.',
);
var at = 0;
for (final match in codes.allMatches(output)) {
_text(output.substring(at, match.start));
_code(match.group(1) ?? '', match.group(2) ?? '');
at = match.end;
}
_text(output.substring(at));
final rows = [for (final row in _rows) row.join().trimRight()];
while (rows.isNotEmpty && rows.last.isEmpty) {
rows.removeLast();
}
return rows;
}