Enum modalkit::editing::cursor::CursorState
source · pub enum CursorState {
Location(Cursor),
Selection(Cursor, Cursor, TargetShape),
}
Expand description
Current position and selection state for a member of a cursor group.
Variants§
Location(Cursor)
Current position of a cursor.
Selection(Cursor, Cursor, TargetShape)
The current position of a cursor, and the anchor and shape of its selection.
Implementations§
source§impl CursorState
impl CursorState
sourcepub fn shape(&self) -> TargetShape
pub fn shape(&self) -> TargetShape
Get the shape of the selection.
sourcepub fn unselect(&mut self)
pub fn unselect(&mut self)
Convert this to a CursorState::Location if it isn’t already.
sourcepub fn is_selection(&self) -> bool
pub fn is_selection(&self) -> bool
Indicates if this is a CursorState::Selection.
sourcepub fn set(&mut self, update: CursorState)
pub fn set(&mut self, update: CursorState)
Set fields in this CursorState using those in another.
sourcepub fn set_cursor(&mut self, new: Cursor)
pub fn set_cursor(&mut self, new: Cursor)
Set the cursor.
sourcepub fn set_anchor(&mut self, anchor: Cursor)
pub fn set_anchor(&mut self, anchor: Cursor)
Set the anchor for the selection.
The value will be converted to a CursorState::Selection if needed.
sourcepub fn set_shape(&mut self, shape: TargetShape)
pub fn set_shape(&mut self, shape: TargetShape)
Set the shape of the selection.
The value will be converted to a CursorState::Selection if needed.
sourcepub fn to_selection(&self) -> Option<Selection>
pub fn to_selection(&self) -> Option<Selection>
If this is a CursorState::Selection, return it as a Selection.
sourcepub fn to_triple(&self) -> (Cursor, Cursor, TargetShape)
pub fn to_triple(&self) -> (Cursor, Cursor, TargetShape)
Return a triple of cursor, anchor, and shape.
sourcepub fn len(&self, rope: &EditRope) -> usize
pub fn len(&self, rope: &EditRope) -> usize
The number of characters contained by the selection.
sourcepub fn direction(&self) -> MoveDir1D
pub fn direction(&self) -> MoveDir1D
Indicates the direction of the cursor relatie to the anchor.
sourcepub fn start(&self) -> &Cursor
pub fn start(&self) -> &Cursor
Returns the cursor or the anchor, depending on which comes earlier in the text.
sourcepub fn end(&self) -> &Cursor
pub fn end(&self) -> &Cursor
Returns the cursor or the anchor, depending on which comes later in the text.
sourcepub fn overlaps(&self, other: &Self) -> bool
pub fn overlaps(&self, other: &Self) -> bool
Returns the intersection of this selection with another.
sourcepub fn intersect(&self, other: &Self) -> Self
pub fn intersect(&self, other: &Self) -> Self
Returns the intersection of this selection with another.
sourcepub fn merge(
&self,
other: &Self,
style: &CursorMergeStyle,
rope: &EditRope
) -> Self
pub fn merge( &self, other: &Self, style: &CursorMergeStyle, rope: &EditRope ) -> Self
Merge this selection with another.
Trait Implementations§
source§impl Adjustable for CursorState
impl Adjustable for CursorState
source§fn adjust(&mut self, adj: &[CursorAdjustment])
fn adjust(&mut self, adj: &[CursorAdjustment])
source§impl Clone for CursorState
impl Clone for CursorState
source§fn clone(&self) -> CursorState
fn clone(&self) -> CursorState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CursorState
impl Debug for CursorState
source§impl Default for CursorState
impl Default for CursorState
source§impl From<Cursor> for CursorState
impl From<Cursor> for CursorState
source§impl Ord for CursorState
impl Ord for CursorState
source§fn cmp(&self, other: &CursorState) -> Ordering
fn cmp(&self, other: &CursorState) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for CursorState
impl PartialEq for CursorState
source§fn eq(&self, other: &CursorState) -> bool
fn eq(&self, other: &CursorState) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for CursorState
impl PartialOrd for CursorState
source§fn partial_cmp(&self, other: &CursorState) -> Option<Ordering>
fn partial_cmp(&self, other: &CursorState) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for CursorState
impl StructuralPartialEq for CursorState
Auto Trait Implementations§
impl Freeze for CursorState
impl RefUnwindSafe for CursorState
impl Send for CursorState
impl Sync for CursorState
impl Unpin for CursorState
impl UnwindSafe for CursorState
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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.