isCellSelected method

bool isCellSelected(
  1. int x,
  2. int y, {
  3. int topVirtualRow = 0,
  4. int leftVirtualCol = 0,
})

Returns whether the viewport cell at ([x], [y]) (offset by topVirtualRow and leftVirtualCol) is currently selected.

Implementation

bool isCellSelected(
  int x,
  int y, {
  int topVirtualRow = 0,
  int leftVirtualCol = 0,
}) {
  final a = _anchor;
  final b = _focus;
  if (a == null || b == null || x < 0 || y < 0) return false;

  final vx = x + leftVirtualCol;
  final vy = y + topVirtualRow;
  if (vx < 0) return false;

  final r = _region;
  if (r != null && !r.contains(vx, vy)) return false;

  return switch (_mode) {
    SelectionMode.block => _isCellInBlock(a, b, vx, vy),
    SelectionMode.line => vy >= min(a.row, b.row) && vy <= max(a.row, b.row),
    SelectionMode.character ||
    SelectionMode.word => _isCellInStream(a, b, vx, vy, r),
  };
}