pub struct Selection {
pub anchor: Position,
pub focus: Position,
}Expand description
A text selection representing an active cursor caret or highlighted range.
Fields§
§anchor: PositionFixed anchor origin where selection started.
focus: PositionActive focus point where the caret currently sits.
Implementations§
Source§impl Selection
impl Selection
Sourcepub const fn range(anchor: Position, focus: Position) -> Self
pub const fn range(anchor: Position, focus: Position) -> Self
Constructs a selection range between anchor and focus.
Sourcepub fn is_collapsed(&self) -> bool
pub fn is_collapsed(&self) -> bool
Returns whether this selection is a collapsed single-point caret.
Sourcepub fn ordered_range(&self) -> (Position, Position)
pub fn ordered_range(&self) -> (Position, Position)
Returns the ordered start and end positions (start, end) where start <= end.
Sourcepub fn contains(&self, pos: Position) -> bool
pub fn contains(&self, pos: Position) -> bool
Returns whether this selection contains the given position.
Sourcepub fn touches_or_overlaps(&self, other: &Selection) -> bool
pub fn touches_or_overlaps(&self, other: &Selection) -> bool
Checks if this selection overlaps or directly touches another selection.
Trait Implementations§
impl Copy for Selection
Source§impl<'de> Deserialize<'de> for Selection
impl<'de> Deserialize<'de> for Selection
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Selection
impl StructuralPartialEq for Selection
Auto Trait Implementations§
impl Forget for Selection
impl Freeze for Selection
impl Move 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
Compare self to
key and return true if they are equal.