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 more