setCell method

void setCell(
  1. int x,
  2. int y,
  3. String char,
  4. int fg,
  5. int bg,
  6. int mod, {
  7. bool? blend,
  8. int underlineColor = 0,
  9. String? uri,
})

Sets character, colors, and modifiers at coordinates.

When blend is true (or omitted when defaultBlend is true), fg and bg are alpha-blended over existing cell colors. When false, they replace existing colors directly so 0 resets to the terminal default.

Implementation

void setCell(
  int x,
  int y,
  String char,
  int fg,
  int bg,
  int mod, {
  bool? blend,
  int underlineColor = 0,
  String? uri,
}) {
  if (isCellValid(x, y)) {
    final useBlend = blend ?? defaultBlend;
    final cellIdx = y * width + x;
    final idx = cellIdx * 3;
    characters[cellIdx] = char;
    attributes[idx + 0] = useBlend ? blendColor(fg, attributes[idx + 0]) : fg;
    attributes[idx + 1] = useBlend ? blendColor(bg, attributes[idx + 1]) : bg;
    attributes[idx + 2] = mod;
    _setUnderlineColorAt(cellIdx, underlineColor);
    _setUriAt(cellIdx, uri);
  }
}