pub struct Selection {
pub id: SelectionId,
pub goal: Option<u32>,
/* private fields */
}Expand description
A directional byte-offset range. start <= end is an invariant; reversed
records whether the caret is at start (true) or end (false).
Fields§
§id: SelectionIdStable identity within its set.
goal: Option<u32>Goal for vertical movement: a display cell — the caret’s visual column, kept through tab stops and collapsed folds. Cleared by any horizontal move or edit.
Implementations§
Source§impl Selection
impl Selection
Sourcepub fn caret(id: SelectionId, offset: u32) -> Self
pub fn caret(id: SelectionId, offset: u32) -> Self
A caret (empty selection) with the given id at offset.
Sourcepub fn from_anchor(id: SelectionId, anchor: u32, head: u32) -> Self
pub fn from_anchor(id: SelectionId, anchor: u32, head: u32) -> Self
A selection from anchor to head (either order); reversed is derived
so the caret sits at head.
Sourcepub fn set_head(&mut self, offset: u32)
pub fn set_head(&mut self, offset: u32)
Move the head to offset, keeping the tail fixed (extends/shrinks the
selection, flipping direction if the head crosses the tail). Clears the
goal column.
Sourcepub fn collapse_to_head(&mut self)
pub fn collapse_to_head(&mut self)
Collapse to a caret at the head.
Sourcepub fn move_to_caret(&mut self, offset: u32)
pub fn move_to_caret(&mut self, offset: u32)
Collapse to a caret at offset, keeping this selection’s id and clearing
the goal column. The movement layer’s “plain move” primitive.
Trait Implementations§
impl Copy for Selection
impl Eq for Selection
impl StructuralPartialEq for Selection
Auto Trait Implementations§
impl Freeze for Selection
impl RefUnwindSafe for Selection
impl Send for Selection
impl Sync for Selection
impl Unpin for Selection
impl UnsafeUnpin for Selection
impl UnwindSafe for Selection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.