pub struct Cursor {
pub head: CursorPosition,
pub anchor: CursorPosition,
pub preferred_column: Option<usize>,
}Available on crate feature
editor only.Expand description
A cursor in the editor, with head and anchor for selection.
Fields§
§head: CursorPositionThe head (active end) of the cursor/selection
anchor: CursorPositionThe anchor (fixed end) of the cursor/selection
preferred_column: Option<usize>Preferred column for vertical movement (remembers column when moving through short lines)
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub const fn new(position: CursorPosition) -> Self
pub const fn new(position: CursorPosition) -> Self
Create a new cursor at a position (no selection).
Sourcepub const fn with_selection(
head: CursorPosition,
anchor: CursorPosition,
) -> Self
pub const fn with_selection( head: CursorPosition, anchor: CursorPosition, ) -> Self
Create a cursor with a selection range.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Check if the cursor has an active selection.
Sourcepub fn selection_start(&self) -> CursorPosition
pub fn selection_start(&self) -> CursorPosition
Get the selection start (minimum position).
Sourcepub fn selection_end(&self) -> CursorPosition
pub fn selection_end(&self) -> CursorPosition
Get the selection end (maximum position).
Sourcepub fn move_to(&mut self, position: CursorPosition, extend_selection: bool)
pub fn move_to(&mut self, position: CursorPosition, extend_selection: bool)
Move the cursor to a new position, optionally extending selection.
Sourcepub fn set_preferred_column(&mut self, column: usize)
pub fn set_preferred_column(&mut self, column: usize)
Set the preferred column for vertical movement.
Sourcepub fn clear_preferred_column(&mut self)
pub fn clear_preferred_column(&mut self)
Clear the preferred column.
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 Copy for Cursor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Source§fn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
Tries to deserialize the data, given only the
submit event.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.