Expand description
Host-side selection helpers.
The editor holds no selection state. It reports gestures — a node or link
was clicked, the background was clicked, a marquee was released — and
renders the selected flag it finds on the rows of your models. Everything
between those two ends is the host’s, and this module is what the host
needs to do it:
resolve_clickandresolve_boxhold the policy: what a click, a shift-click, a marquee and a shift-marquee mean. They are pure — no storage, no interior mutability — so the host is free to keep the selection wherever it already keeps its state.project_selectionwrites a selection back into the rows, andselected_rowsreads it back out, so a host that wants no separate store can let the rows be the selection.
§Contract
Every intent resolves to an absolute set: the resolvers take the current selection and return the new one in full, never a delta. There is no “add” or “remove” call, and no reachable state in which a selection was half-applied.
§Order
Both resolvers are order-stable: surviving members keep their relative order and new members are appended. Order is presentation-stable and semantically meaningless — it is what an introspecting client sees, and nothing may interpret it. If you ever need a distinguished member (a paste anchor, a “primary” selection), that is an explicit concept to add, never a position in this vector.
Functions§
- apply_
box - Apply a released marquee to a model whose rows carry the selection.
- apply_
click - Apply a click to a model whose rows carry the selection.
- clear_
selection - Deselect every row of a model.
- project_
selection - Project a selection into a model’s per-row
selectedflag. - resolve_
box - Resolve a released marquee against the current selection.
- resolve_
click - Resolve a click on
itemagainst the current selection. - selected_
rows - Collect a key for every row the model currently shows as selected.