pub struct SelectionSet { /* private fields */ }Expand description
A non-empty, sorted, disjoint set of selections. Merged after every mutation so no two selections overlap.
Implementations§
Source§impl SelectionSet
impl SelectionSet
Sourcepub fn from_offsets(offsets: &[u32]) -> Self
pub fn from_offsets(offsets: &[u32]) -> Self
A set of carets at the given offsets (merged). Used by the verbs layer to
place carets after an edit. Panics if offsets is empty — a set is never
empty.
Sourcepub fn from_ranges(ranges: &[(u32, u32)], newest: usize) -> Self
pub fn from_ranges(ranges: &[(u32, u32)], newest: usize) -> Self
Build a set from (anchor, head) ranges (any order); the range at index
newest becomes the primary (largest id) — the autoscroll target. Used to
install a column (box) selection. Panics if ranges is empty or
newest is out of bounds.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Always false — a set is never empty. Present for lint-friendliness
alongside SelectionSet::len.
Sourcepub fn newest(&self) -> &Selection
pub fn newest(&self) -> &Selection
The newest selection (largest id) — the autoscroll / primary target.
Sourcepub fn add_caret(&mut self, offset: u32)
pub fn add_caret(&mut self, offset: u32)
Add a caret at offset, merging into any selection it touches.
Sourcepub fn add_selection(&mut self, anchor: u32, head: u32)
pub fn add_selection(&mut self, anchor: u32, head: u32)
Add a selection from anchor to head, merging as needed.
Sourcepub fn set_single(&mut self, sel: Selection)
pub fn set_single(&mut self, sel: Selection)
Replace the whole set with a single selection (Escape collapses to the oldest; here the caller supplies it).
Sourcepub fn collapse_to_newest(&mut self)
pub fn collapse_to_newest(&mut self)
Collapse to just the newest selection, as a caret at its head (the standard Escape behavior for multi-cursor).
Sourcepub fn collapse_to_primary(&mut self)
pub fn collapse_to_primary(&mut self)
Collapse to just the oldest selection (smallest id), as a caret at its head — the multi-cursor Escape that keeps the primary cursor. With a single ranged selection this simply deselects it to a caret.
Sourcepub fn map_each(&mut self, f: impl FnMut(&mut Selection))
pub fn map_each(&mut self, f: impl FnMut(&mut Selection))
Mutate every selection through f, then re-merge. The building block for
movement.
Sourcepub fn rebase(&mut self, patch: &Patch)
pub fn rebase(&mut self, patch: &Patch)
Rebase every selection through an edit’s Patch — the eager mover that
keeps every endpoint current as text is inserted and deleted. Endpoints
use Left bias for the start and Right for the end so a selection
grows over text typed at its edges; carets follow the insertion.
Re-merges afterward.
Trait Implementations§
Source§impl Clone for SelectionSet
impl Clone for SelectionSet
Source§fn clone(&self) -> SelectionSet
fn clone(&self) -> SelectionSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more