pub struct SelectionSet { /* private fields */ }Expand description
The editor’s selections: a primary plus zero or more extras.
Invariants (enforced by normalize): extras sorted, deduped, none
equal to the primary’s head.
Implementations§
Source§impl SelectionSet
impl SelectionSet
pub fn primary(&self) -> Selection
pub fn extra_heads(&self) -> &[Selection]
pub fn count(&self) -> usize
Sourcepub fn collapse_primary(&mut self, at: usize)
pub fn collapse_primary(&mut self, at: usize)
Move head and anchor together (leaving visual mode, plain moves).
Sourcepub fn stretch_primary(&mut self, anchor: usize, head: usize)
pub fn stretch_primary(&mut self, anchor: usize, head: usize)
Enter/extend visual: the anchor stays, the head walks.
Sourcepub fn toggle_extra(&mut self)
pub fn toggle_extra(&mut self)
Q: drop the extra under the primary, else plant one there.
Sourcepub fn plant_extra(&mut self, at: usize)
pub fn plant_extra(&mut self, at: usize)
Plant an extra cursor (both ends at at). Never on the
primary’s head — Space c and match-planting skip that spot;
stacking on the primary is Q’s job (toggle_extra).
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Sorted, deduped. An extra MAY sit on the primary’s head — Q
plants exactly there, then a motion walks them apart (0013).
Sourcepub fn collapse_extras(&mut self)
pub fn collapse_extras(&mut self)
Esc: extras die, primary stays.
Sourcepub fn set_extras(&mut self, heads: impl IntoIterator<Item = usize>)
pub fn set_extras(&mut self, heads: impl IntoIterator<Item = usize>)
Replace the extras wholesale — the motion cascade replants computed heads, and stacked-on-primary extras survive (they were planted by Q on purpose, 0013 §3).
Sourcepub fn plant_extra_selection(&mut self, anchor: usize, head: usize)
pub fn plant_extra_selection(&mut self, anchor: usize, head: usize)
Plant a real (stretched) extra selection — occurrence selection
(0049 §7) keeps anchor/head, unlike the collapsed Space c
cursor. Skips ranges already owned by the primary or an extra.
Sourcepub fn set_extra_selections(
&mut self,
selections: impl IntoIterator<Item = Selection>,
)
pub fn set_extra_selections( &mut self, selections: impl IntoIterator<Item = Selection>, )
Replace the extras wholesale, keeping each anchor/head and direction — occurrence selections are real ranges, so the motion/insert cascades replant full selections where the plain cursor flow replants heads.
Sourcepub fn remove_extra(&mut self, selection: Selection) -> Option<Selection>
pub fn remove_extra(&mut self, selection: Selection) -> Option<Selection>
Drop one extra by exact identity (occurrence pop, 0049 §7). Returns the removed selection when one matched.
Sourcepub fn map_positions(&mut self, map: impl FnMut(usize) -> usize)
pub fn map_positions(&mut self, map: impl FnMut(usize) -> usize)
Map every endpoint in place, preserving selection direction and capacity.
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