setAsciiCells method
Implementation
void setAsciiCells(
int start,
String text,
int textStart,
int count,
CursorStyle style,
) {
assert(start >= 0 && start + count <= _length);
assert(textStart >= 0 && textStart + count <= text.length);
if (count <= 0) return;
_ensureCapacity(start + count - 1);
clearWideCellAt(start, style);
clearWideCellAt(start + count - 1, style);
final foreground = style.foreground;
final background = style.background;
final attributes = style.attrs |
(style.hyperlinkId << CellAttr.hyperlinkShift) |
style.semanticAttrs;
for (var offset = 0; offset < count; offset++) {
final cellOffset = (start + offset) * _cellSize;
final codeUnit = text.codeUnitAt(textStart + offset);
// Callers must have established that every unit occupies exactly one
// cell - see `ByteConsumer.printableTextRunLength`, which is where the
// run this writes comes from.
assert(isSingleCellPrintable(codeUnit));
_data[cellOffset + _cellForeground] = foreground;
_data[cellOffset + _cellBackground] = background;
_data[cellOffset + _cellAttributes] = attributes;
_data[cellOffset + _cellContent] =
codeUnit | (1 << CellContent.widthShift);
}
final end = start + count;
if (_combiningCharacters case final combiningCharacters?
when combiningCharacters.isNotEmpty) {
combiningCharacters.removeWhere(
(index, _) => index >= start && index < end,
);
}
if (style.underlineColor == 0) {
if (_underlineColors case final underlineColors?
when underlineColors.isNotEmpty) {
underlineColors.removeWhere(
(index, _) => index >= start && index < end,
);
}
return;
}
for (var index = start; index < end; index++) {
_mutableUnderlineColors[index] = style.underlineColor;
}
}