pub struct Selection {
pub anchor: CursorPosition,
pub head: CursorPosition,
}Expand description
A text selection defined by an anchor and a head position.
The anchor is where the selection started and the head is where
the cursor currently is. The anchor may come before or after the
head — use Selection::ordered to get (start, end).
Fields§
§anchor: CursorPositionThe position where the selection started.
head: CursorPositionThe current cursor position (moving end of the selection).
Implementations§
Source§impl Selection
impl Selection
Sourcepub fn new(anchor: CursorPosition, head: CursorPosition) -> Self
pub fn new(anchor: CursorPosition, head: CursorPosition) -> Self
Create a new selection.
Sourcepub fn ordered(&self) -> (CursorPosition, CursorPosition)
pub fn ordered(&self) -> (CursorPosition, CursorPosition)
Return the selection as (start, end) in document order.
Sourcepub fn contains(&self, pos: CursorPosition) -> bool
pub fn contains(&self, pos: CursorPosition) -> bool
Check if a position is contained within the selection.
Sourcepub fn line_range(&self) -> (usize, usize)
pub fn line_range(&self) -> (usize, usize)
Return the range of lines spanned by the selection.
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 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
Mutably borrows from an owned value. Read more