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
impl CaretInfo
sourcepub fn set_index(&mut self, index: CaretIndex)
pub fn set_index(&mut self, index: CaretIndex)
Set the index and update the index version.
sourcepub fn set_selection(&mut self, start: CaretIndex, end: CaretIndex)
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.
sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clears selection.
sourcepub fn set_char_index(&mut self, index: usize)
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.
sourcepub fn set_char_selection(&mut self, start: usize, end: usize)
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.
sourcepub fn selection_range(&self) -> Option<Range<CaretIndex>>
pub fn selection_range(&self) -> Option<Range<CaretIndex>>
Gets the selection range if both index
and selection_index
are set.
sourcepub fn selection_char_range(&self) -> Option<Range<usize>>
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§
Auto Trait Implementations§
impl Freeze for CaretInfo
impl !RefUnwindSafe for CaretInfo
impl Send for CaretInfo
impl Sync for CaretInfo
impl Unpin for CaretInfo
impl !UnwindSafe for CaretInfo
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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