isCellSelected method
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),
};
}