getCellOffset method

CellOffset getCellOffset(
  1. Offset offset
)

Get the CellOffset of the cell that offset is in.

Implementation

CellOffset getCellOffset(Offset offset) {
  final x = offset.dx - _padding.left;
  final y = offset.dy - _padding.top + _scrollOffset;
  final row = y ~/ _painter.cellSize.height;
  final col = x ~/ _painter.cellSize.width;
  return CellOffset(
    col.clamp(0, _terminal.viewWidth - 1),
    row.clamp(0, _terminal.buffer.lines.length - 1),
  );
}