dioxus_native_core::utils::cursor

Struct Cursor

Source
pub struct Cursor {
    pub start: Pos,
    pub end: Option<Pos>,
}
Expand description

A cursor is a selection of text. It has a start and end position of the selection.

Fields§

§start: Pos

The start position of the selection. The start position is the origin of the selection, not necessarily the first position.

§end: Option<Pos>

The end position of the selection. If the end position is None, the cursor is a caret.

Implementations§

Source§

impl Cursor

Source

pub fn from_start(pos: Pos) -> Self

Create a new cursor with the given start position.

Source

pub fn new(start: Pos, end: Pos) -> Self

Create a new cursor with the given start and end position.

Source

pub fn move_cursor(&mut self, f: impl FnOnce(&mut Pos), shift: bool)

Move the cursor position. If shift is true, the end position will be moved instead of the start position.

Source

pub fn delete_selection<T: Text + ?Sized>( &mut self, text: &mut impl TextEditable<T>, )

Delete the currently selected text and update the cursor position.

Source

pub fn handle_input<T: Text + ?Sized>( &mut self, code: &Code, key: &Key, modifiers: &Modifiers, text: &mut impl TextEditable<T>, max_text_length: usize, )

Handle moving the cursor with the given key.

Source

pub fn with_end(&mut self, f: impl FnOnce(&mut Pos))

Modify the end selection position

Source

pub fn first(&self) -> &Pos

Returns first position of the selection (this could be the start or the end depending on the position)

Source

pub fn last(&self) -> &Pos

Returns last position of the selection (this could be the start or the end depending on the position)

Source

pub fn selection_len(&self, text: &(impl Text + ?Sized)) -> usize

Returns the length of the selection

Trait Implementations§

Source§

impl Clone for Cursor

Source§

fn clone(&self) -> Cursor

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cursor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Cursor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Cursor

Source§

fn eq(&self, other: &Cursor) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Cursor

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> CloneAny for T
where T: Any + Clone,