Struct zng_wgt_text::node::CaretInfo

source ·
pub struct CaretInfo {
    pub opacity: ReadOnlyArcVar<Factor>,
    pub index: Option<CaretIndex>,
    pub selection_index: Option<CaretIndex>,
    pub initial_selection: Option<(Range<CaretIndex>, bool)>,
    pub index_version: Wrapping<u8>,
    pub used_retained_x: bool,
    pub skip_next_scroll: bool,
}
Expand description

Represents the caret position at the ResolvedText level.

Fields§

§opacity: ReadOnlyArcVar<Factor>

Caret opacity.

This variable is replaced often, the text resolver subscribes to it for UpdateOp::RenderUpdate automatically.

§index: Option<CaretIndex>

Caret byte offset in the text string.

This is the insertion offset on the text, it can be the text length.

§selection_index: Option<CaretIndex>

Second index that defines the start or end of a selection range.

§initial_selection: Option<(Range<CaretIndex>, bool)>

Selection by word or line sets this value, selection extend by word or line grows from this central selection. The value is (selection, is_word).

§index_version: Wrapping<u8>

Value incremented by one every time the index is set.

This is used to signal interaction with the index value by TextEditOp even if the interaction only sets-it to the index same value.

§used_retained_x: bool

If the index was set by using the caret_retained_x.

§skip_next_scroll: bool

Don’t scroll to new caret position on the next update.

If this is set to true the next time index or index_version changes auto-scroll is skipped once.

Implementations§

source§

impl CaretInfo

source

pub fn set_index(&mut self, index: CaretIndex)

Set the index and update the index version.

source

pub fn set_selection(&mut self, start: CaretIndex, end: CaretIndex)

Sets the selection start, end and update the index version.

The end is the caret position.

source

pub fn clear_selection(&mut self)

Clears selection.

source

pub fn set_char_index(&mut self, index: usize)

Set the char byte index and update the index version.

The caret line is always snapped when the caret changes, so the line value will be updated.

source

pub fn set_char_selection(&mut self, start: usize, end: usize)

Set the char byte index of the selection start, end and update the index version.

The end is the caret position.

The caret and selection lines are always snapped when the caret changes, so the line values will be updated.

source

pub fn selection_range(&self) -> Option<Range<CaretIndex>>

Gets the selection range if both index and selection_index are set.

source

pub fn selection_char_range(&self) -> Option<Range<usize>>

Gets the character range of the selection if both index and selection_index are set.

Trait Implementations§

source§

impl Clone for CaretInfo

source§

fn clone(&self) -> CaretInfo

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 CaretInfo

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 T)

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FsChangeNote for T
where T: Debug + Any + Send + Sync,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Access any.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

source§

impl<T> StateValue for T
where T: Any + Send + Sync,