pub struct Cursor {
pub position: usize,
pub anchor: Option<usize>,
}Expand description
A cursor position in a document.
Fields§
§position: usizeThe position (character offset) in the document.
anchor: Option<usize>Optional anchor for selection (selection goes from anchor to position).
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub fn with_selection(anchor: usize, position: usize) -> Self
pub fn with_selection(anchor: usize, position: usize) -> Self
Create a cursor with a selection.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Check if this cursor has a selection.
Sourcepub fn selection_range(&self) -> Option<(usize, usize)>
pub fn selection_range(&self) -> Option<(usize, usize)>
Get the selection range (start, end).
Sourcepub fn selection_length(&self) -> usize
pub fn selection_length(&self) -> usize
Get the selection length.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cursor
impl<'de> Deserialize<'de> for Cursor
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 Cursor
impl StructuralPartialEq for Cursor
Auto Trait Implementations§
impl Freeze for Cursor
impl RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl UnwindSafe for Cursor
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