insertLineArea method
Inserts n lines at y within area (ansi IL semantics).
Upstream: third_party/ultraviolet/buffer.go (InsertLineArea).
Implementation
void insertLineArea(int y, int n, Cell? cell, Rectangle area) {
if (n <= 0 || y < area.minY || y >= area.maxY || y >= height()) return;
if (y + n > area.maxY) n = area.maxY - y;
for (var i = area.maxY - 1; i >= y + n; i--) {
for (var x = area.minX; x < area.maxX; x++) {
lines[i].cells[x] = lines[i - n].cells[x].clone();
}
touchLine(area.minX, i, area.maxX - area.minX);
touchLine(area.minX, i - n, area.maxX - area.minX);
}
for (var i = y; i < y + n; i++) {
for (var x = area.minX; x < area.maxX; x++) {
setCell(x, i, cell);
}
}
}