Improved reading when no flags are specified.

This commit is contained in:
Erik C. Thauvin 2021-10-16 14:58:30 -07:00
parent edb77726f1
commit 96b4784fc8

View file

@ -125,14 +125,16 @@ Future<void> _writeStream(
!numberNonBlank && !numberNonBlank &&
!showTabs && !showTabs &&
!squeezeBlank && !squeezeBlank &&
!showNonPrinting; !showNonPrinting) {
await stream.transform(utf8.decoder).forEach(out.write);
} else {
const tab = 9;
int squeeze = 0;
final sb = StringBuffer(); final sb = StringBuffer();
await stream.forEach((data) { await stream.forEach((data) {
sb.clear(); sb.clear();
for (final ch in utf8.decode(data).runes) { for (final ch in utf8.decode(data).runes) {
if (noFlags) {
sb.writeCharCode(ch);
} else {
if (lastLine.lastChar == _lineFeed) { if (lastLine.lastChar == _lineFeed) {
if (squeezeBlank) { if (squeezeBlank) {
if (ch == _lineFeed) { if (ch == _lineFeed) {
@ -189,9 +191,9 @@ Future<void> _writeStream(
} }
sb.writeCharCode(ch); sb.writeCharCode(ch);
} }
}
if (sb.isNotEmpty) { if (sb.isNotEmpty) {
out.write(sb); out.write(sb);
} }
}); });
}
} }