setAttributes method

void setAttributes(
  1. int x,
  2. int y, {
  3. String? char,
  4. int? fg,
  5. int? bg,
  6. int? modifiers,
})

Sets the cell attributes at (x, y). Does nothing if coordinates are out of bounds.

Implementation

void setAttributes(
  int x,
  int y, {
  String? char,
  int? fg,
  int? bg,
  int? modifiers,
}) {
  if (x < 0 || x >= width || y < 0 || y >= height) return;
  final idx = (y * width + x) * 3;
  if (char != null) characters[y * width + x] = char;
  if (fg != null) attributes[idx + 0] = fg;
  if (bg != null) attributes[idx + 1] = bg;
  if (modifiers != null) attributes[idx + 2] = modifiers;
}