writeNarrow method
Writes the characters of text from start to end, each one cell wide
and a whole UTF-16 code unit: what the parser's fast path hands over.
Implementation
//
// Under grapheme clustering (mode 2027, on by default) writeChar asks the
// characters package of every letter outside ASCII whether it joins the
// cell before, and that, not the parser, is what made Cyrillic slow. A letter that cannot join what came before fills its cell
// as ASCII does; any other goes through writeChar, a Devanagari vowel sign
// to its consonant.
void writeNarrow(String text, int start, int end) {
if (!terminal.graphemeClusterMode) {
writeAscii(text, start, end);
return;
}
var fastStart = start;
var afterPlainLetter = false;
for (var index = start; index < end; index++) {
final codeUnit = text.codeUnitAt(index);
if (codeUnit <= 0x7e ||
afterPlainLetter && _startsItsOwnGrapheme(codeUnit)) {
afterPlainLetter = true;
continue;
}
writeAscii(text, fastStart, index);
writeChar(codeUnit);
fastStart = index + 1;
afterPlainLetter = _startsItsOwnGrapheme(codeUnit);
}
writeAscii(text, fastStart, end);
}