deleteCellArea method

void deleteCellArea(
  1. int x,
  2. int y,
  3. int n,
  4. Cell? cell,
  5. Rectangle area,
)

Deletes n cells at (x,y) within area (ansi DCH semantics).

Upstream: third_party/ultraviolet/buffer.go (DeleteCellArea).

Implementation

void deleteCellArea(int x, int y, int n, Cell? cell, Rectangle area) {
  if (n <= 0 ||
      y < area.minY ||
      y >= area.maxY ||
      y >= height() ||
      x < area.minX ||
      x >= area.maxX ||
      x >= width()) {
    return;
  }

  final remainingCells = area.maxX - x;
  if (n > remainingCells) n = remainingCells;

  for (var i = x; i < area.maxX - n; i++) {
    if (i + n < area.maxX) {
      setCell(i, y, cellAt(i + n, y));
    }
  }
  touchLine(x, y, n);

  for (var i = area.maxX - n; i < area.maxX; i++) {
    setCell(i, y, cell);
  }
}