touchLine method
Implementation
void touchLine(int x, int y, int width) {
if (y < 0 || y >= lines.length) return;
if (y >= touched.length) {
touched = [
...touched,
...List<LineData?>.filled(y - touched.length + 1, null),
];
}
final ch = touched[y];
final first = x;
final last = x + width;
if (ch == null) {
touched[y] = LineData(firstCell: first, lastCell: last);
} else {
final prevFirst = ch.firstCell == -1 ? first : ch.firstCell;
final prevLast = ch.lastCell == -1 ? last : ch.lastCell;
touched[y] = LineData(
firstCell: first < prevFirst ? first : prevFirst,
lastCell: last > prevLast ? last : prevLast,
);
}
}