clamp_selection(
widget: Widget,
selection: Selection,
) -> Selection | None| Name | Type | Description |
|---|---|---|
widget* | Widget | The row the selection applies to. Anything that is not a
|
selection* | Selection | The geometry Textual computed for this row. |
Return selection shifted past a diff row's gutter, if one is set.
Every form a selection can take over a single-line row covers the gutter unless its start is moved past it:
Selection(None, None) — the row sits mid-selection. Textual extracts
the row's full text, so the start must move to the gutter's end even
though no endpoint lands here.Selection(None, end) — entered from above; same move, plus an end
still inside the gutter means nothing selectable is covered, reported
as None so the row drops out of the screen's selection map.Selection(start, None) / Selection(start, end) — pull any endpoint
inside the gutter forward to its end; a range that then collapses
(wholly gutter) is None.An endpoint counts as "inside the gutter" only on the row's first visual
line (y == 0). A row wrapped by Textual continues at column 0 of each
following visual line, where the gutter no longer exists — an x there
already indexes source text, so a continuation coordinate must pass through
untouched or a drag starting on a continuation would skip its first
gutter-width characters, and one ending within them would drop source the
user visibly selected.