#[non_exhaustive]pub struct CaretInfo {
pub opacity: Var<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 context.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.opacity: Var<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: boolIf the index was set by using the caret_retained_x.
skip_next_scroll: boolDon’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§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