resolveRegionForCell static method
SelectionRegion?
resolveRegionForCell(
- Buffer buffer,
- int col,
- int row, {
- SelectionMode mode = SelectionMode.character,
Resolves the confining SelectionRegion for a pointer gesture starting at
([col], [row]) in buffer, or returns null when selection should span
the full buffer unconstrained.
- In SelectionMode.block (
box), always returnsnullsoAlt+Dragrectangular selection is never clamped to pane dividers. - Checks Buffer.selectableRegions for the smallest sub-region containing
([col], [row]), narrowing further if vertical dividers exist inside it. - Falls back to scanning vertical box-drawing dividers (
│,┃,║), and only scans horizontal dividers (─,━,═) when vertical dividers were also found so plain shell horizontal rules are never clamped.
Implementation
static SelectionRegion? resolveRegionForCell(
Buffer buffer,
int col,
int row, {
SelectionMode mode = SelectionMode.character,
}) {
if (mode == SelectionMode.block ||
!_isWithinBufferBounds(buffer, col, row)) {
return null;
}
final subregion = _findSmallestSubregion(buffer, col, row);
if (subregion != null) {
return _narrowRegionByDividers(
buffer,
col,
row,
SelectionRegion.fromRect(subregion),
requireVerticalForReturn: false,
);
}
final fullBounds = SelectionRegion(
minCol: 0,
maxCol: buffer.width - 1,
minRow: 0,
maxRow: buffer.height - 1,
);
return _narrowRegionByDividers(
buffer,
col,
row,
fullBounds,
requireVerticalForReturn: true,
);
}