pub struct TextSelectOp { /* private fields */ }Expand description
Represents a text caret/selection operation that can be send to an editable text using SELECT_CMD.
The provided operations work in rich texts by default, unless they are named with prefix local_. In
rich text contexts the operation may generate other SELECT_CMD requests as it propagates to all involved component texts.
The local_ operations are for use by other operations only, direct use inside rich text requires updating the rich text state
to match.
Implementations§
Source§impl TextSelectOp
impl TextSelectOp
Sourcepub fn next() -> Self
pub fn next() -> Self
Clear selection and move the caret to the next insert index.
This is the Right key operation.
Sourcepub fn select_next() -> Self
pub fn select_next() -> Self
Extend or shrink selection by moving the caret to the next insert index.
This is the SHIFT+Right key operation.
Sourcepub fn prev() -> Self
pub fn prev() -> Self
Clear selection and move the caret to the previous insert index.
This is the Left key operation.
Sourcepub fn select_prev() -> Self
pub fn select_prev() -> Self
Extend or shrink selection by moving the caret to the previous insert index.
This is the SHIFT+Left key operation.
Sourcepub fn next_word() -> Self
pub fn next_word() -> Self
Clear selection and move the caret to the next word insert index.
This is the CTRL+Right shortcut operation.
Sourcepub fn select_next_word() -> Self
pub fn select_next_word() -> Self
Extend or shrink selection by moving the caret to the next word insert index.
This is the CTRL+SHIFT+Right shortcut operation.
Sourcepub fn prev_word() -> Self
pub fn prev_word() -> Self
Clear selection and move the caret to the previous word insert index.
This is the CTRL+Left shortcut operation.
Sourcepub fn select_prev_word() -> Self
pub fn select_prev_word() -> Self
Extend or shrink selection by moving the caret to the previous word insert index.
This is the CTRL+SHIFT+Left shortcut operation.
Sourcepub fn line_up() -> Self
pub fn line_up() -> Self
Clear selection and move the caret to the nearest insert index on the previous line.
This is the Up key operation.
Sourcepub fn select_line_up() -> Self
pub fn select_line_up() -> Self
Extend or shrink selection by moving the caret to the nearest insert index on the previous line.
This is the SHIFT+Up key operation.
Sourcepub fn line_down() -> Self
pub fn line_down() -> Self
Clear selection and move the caret to the nearest insert index on the next line.
This is the Down key operation.
Sourcepub fn select_line_down() -> Self
pub fn select_line_down() -> Self
Extend or shrink selection by moving the caret to the nearest insert index on the next line.
This is the SHIFT+Down key operation.
Sourcepub fn page_up() -> Self
pub fn page_up() -> Self
Clear selection and move the caret one viewport up.
This is the PageUp key operation.
Sourcepub fn select_page_up() -> Self
pub fn select_page_up() -> Self
Extend or shrink selection by moving the caret one viewport up.
This is the SHIFT+PageUp key operation.
Sourcepub fn page_down() -> Self
pub fn page_down() -> Self
Clear selection and move the caret one viewport down.
This is the PageDown key operation.
Sourcepub fn select_page_down() -> Self
pub fn select_page_down() -> Self
Extend or shrink selection by moving the caret one viewport down.
This is the SHIFT+PageDown key operation.
Sourcepub fn line_start() -> Self
pub fn line_start() -> Self
Clear selection and move the caret to the start of the line.
This is the Home key operation.
Sourcepub fn select_line_start() -> Self
pub fn select_line_start() -> Self
Extend or shrink selection by moving the caret to the start of the line.
This is the SHIFT+Home key operation.
Sourcepub fn line_end() -> Self
pub fn line_end() -> Self
Clear selection and move the caret to the end of the line (before the line-break if any).
This is the End key operation.
Sourcepub fn select_line_end() -> Self
pub fn select_line_end() -> Self
Extend or shrink selection by moving the caret to the end of the line (before the line-break if any).
This is the SHIFT+End key operation.
Sourcepub fn text_start() -> Self
pub fn text_start() -> Self
Clear selection and move the caret to the text start.
This is the CTRL+Home shortcut operation.
Sourcepub fn select_text_start() -> Self
pub fn select_text_start() -> Self
Extend or shrink selection by moving the caret to the text start.
This is the CTRL+SHIFT+Home shortcut operation.
Sourcepub fn text_end() -> Self
pub fn text_end() -> Self
Clear selection and move the caret to the text end.
This is the CTRL+End shortcut operation.
Sourcepub fn select_text_end() -> Self
pub fn select_text_end() -> Self
Extend or shrink selection by moving the caret to the text end.
This is the CTRL+SHIFT+End shortcut operation.
Sourcepub fn nearest_to(window_point: DipPoint) -> Self
pub fn nearest_to(window_point: DipPoint) -> Self
Clear selection and move the caret to the insert point nearest to the window_point.
This is the mouse primary button down operation.
Sourcepub fn select_nearest_to(window_point: DipPoint) -> Self
pub fn select_nearest_to(window_point: DipPoint) -> Self
Extend or shrink selection by moving the caret to the insert point nearest to the window_point.
This is the mouse primary button down when holding SHIFT operation.
Sourcepub fn select_word_nearest_to(
replace_selection: bool,
window_point: DipPoint,
) -> Self
pub fn select_word_nearest_to( replace_selection: bool, window_point: DipPoint, ) -> Self
Replace or extend selection with the word nearest to the window_point
This is the mouse primary button double click.
Sourcepub fn select_line_nearest_to(
replace_selection: bool,
window_point: DipPoint,
) -> Self
pub fn select_line_nearest_to( replace_selection: bool, window_point: DipPoint, ) -> Self
Replace or extend selection with the line nearest to the window_point
This is the mouse primary button triple click.
Sourcepub fn select_index_nearest_to(
window_point: DipPoint,
move_selection_index: bool,
) -> Self
pub fn select_index_nearest_to( window_point: DipPoint, move_selection_index: bool, ) -> Self
Extend or shrink selection by moving the caret index or caret selection index to the insert point nearest to window_point.
This is the touch selection caret drag operation.
Sourcepub fn select_all() -> Self
pub fn select_all() -> Self
Select the full text.
Sourcepub fn clear_selection() -> Self
pub fn clear_selection() -> Self
Clear selection and keep the caret at the same position.
This is the Esc shortcut operation.
Source§impl TextSelectOp
Operations that ignore the rich text context, for internal use only.
impl TextSelectOp
Operations that ignore the rich text context, for internal use only.
Sourcepub fn local_next() -> Self
pub fn local_next() -> Self
Like next but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_next() -> Self
pub fn local_select_next() -> Self
Like select_next but stays within the same text widget, ignores rich text context.
Sourcepub fn local_prev() -> Self
pub fn local_prev() -> Self
Like prev but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_prev() -> Self
pub fn local_select_prev() -> Self
Like select_prev but stays within the same text widget, ignores rich text context.
Sourcepub fn local_next_word() -> Self
pub fn local_next_word() -> Self
Like next_word but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_next_word() -> Self
pub fn local_select_next_word() -> Self
Like select_next_word but stays within the same text widget, ignores rich text context.
Sourcepub fn local_prev_word() -> Self
pub fn local_prev_word() -> Self
Like prev_word but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_prev_word() -> Self
pub fn local_select_prev_word() -> Self
Like select_prev_word but stays within the same text widget, ignores rich text context.
Sourcepub fn local_line_start() -> Self
pub fn local_line_start() -> Self
Like line_start but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_line_start() -> Self
pub fn local_select_line_start() -> Self
Like select_line_start but stays within the same text widget, ignores rich text context.
Sourcepub fn local_line_end() -> Self
pub fn local_line_end() -> Self
Like line_end but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_line_end() -> Self
pub fn local_select_line_end() -> Self
Like select_line_end but stays within the same text widget, ignores rich text context.
Sourcepub fn local_text_start() -> Self
pub fn local_text_start() -> Self
Like text_start but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_text_start() -> Self
pub fn local_select_text_start() -> Self
Like select_text_start but stays within the same text widget, ignores rich text context.
Sourcepub fn local_text_end() -> Self
pub fn local_text_end() -> Self
Like text_end but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_text_end() -> Self
pub fn local_select_text_end() -> Self
Like select_text_end but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_all() -> Self
pub fn local_select_all() -> Self
Like select_all but stays within the same text widget, ignores rich text context.
Sourcepub fn local_clear_selection() -> Self
pub fn local_clear_selection() -> Self
Like clear_selection but stays within the same text widget, ignores rich text context.
Sourcepub fn local_line_up() -> Self
pub fn local_line_up() -> Self
Like line_up but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_line_up() -> Self
pub fn local_select_line_up() -> Self
Like select_line_up but stays within the same text widget, ignores rich text context.
Sourcepub fn local_line_down() -> Self
pub fn local_line_down() -> Self
Like line_down but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_line_down() -> Self
pub fn local_select_line_down() -> Self
Like select_line_down but stays within the same text widget, ignores rich text context.
Sourcepub fn local_page_up() -> Self
pub fn local_page_up() -> Self
Like page_up but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_page_up() -> Self
pub fn local_select_page_up() -> Self
Like select_page_up but stays within the same text widget, ignores rich text context.
Sourcepub fn local_page_down() -> Self
pub fn local_page_down() -> Self
Like page_down but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_page_down() -> Self
pub fn local_select_page_down() -> Self
Like select_page_down but stays within the same text widget, ignores rich text context.
Sourcepub fn local_nearest_to(window_point: DipPoint) -> Self
pub fn local_nearest_to(window_point: DipPoint) -> Self
Like nearest_to but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_nearest_to(window_point: DipPoint) -> Self
pub fn local_select_nearest_to(window_point: DipPoint) -> Self
Like select_nearest_to but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_index_nearest_to(
window_point: DipPoint,
move_selection_index: bool,
) -> Self
pub fn local_select_index_nearest_to( window_point: DipPoint, move_selection_index: bool, ) -> Self
Like select_index_nearest_to but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_word_nearest_to(
replace_selection: bool,
window_point: DipPoint,
) -> Self
pub fn local_select_word_nearest_to( replace_selection: bool, window_point: DipPoint, ) -> Self
Like select_word_nearest_to but stays within the same text widget, ignores rich text context.
Sourcepub fn local_select_line_nearest_to(
replace_selection: bool,
window_point: DipPoint,
) -> Self
pub fn local_select_line_nearest_to( replace_selection: bool, window_point: DipPoint, ) -> Self
Like select_line_nearest_to but stays within the same text widget, ignores rich text context.
Source§impl TextSelectOp
impl TextSelectOp
Sourcepub fn new(op: impl FnMut() + Send + 'static) -> Self
pub fn new(op: impl FnMut() + Send + 'static) -> Self
New text select operation.
The editable text widget that handles SELECT_CMD will call op during event handling in
the node::layout_text context. You can position the caret using TEXT.resolve_caret and TEXT.resolve_rich_caret,
the text widget will detect changes to it and react accordingly (updating caret position and animation),
the caret index is also snapped to the nearest grapheme start.
Sourcepub fn new_rich<D0, D1, D2>(
rich_caret_index: impl FnOnce(&RichText) -> (WidgetId, D0) + Send + 'static,
local_caret_index: impl FnOnce(D0) -> (CaretIndex, D1) + Send + 'static,
rich_selection_index: impl FnOnce(&RichText, D1) -> Option<(WidgetId, D2)> + Send + 'static,
local_selection_index: impl FnOnce(D2) -> Option<CaretIndex> + Send + 'static,
) -> Self
pub fn new_rich<D0, D1, D2>( rich_caret_index: impl FnOnce(&RichText) -> (WidgetId, D0) + Send + 'static, local_caret_index: impl FnOnce(D0) -> (CaretIndex, D1) + Send + 'static, rich_selection_index: impl FnOnce(&RichText, D1) -> Option<(WidgetId, D2)> + Send + 'static, local_selection_index: impl FnOnce(D2) -> Option<CaretIndex> + Send + 'static, ) -> Self
New text selection operation with helpers for implementing rich selection.
The input closures are:
rich_caret_index- Called if the op executes inside a rich text, must return the leaf widget that will contain the rich text caret.local_caret_index- Called in the caret widget context, must return the local caret index.rich_selection_index- Called if the op executes inside a rich text, must return the leaf widget that will contain the rich text selection end.local_selection_index- Called in selection end widget context, must return the local selection end index.
Data can be passed between each stage with types D0 from rich_caret_index to local_caret_index, D1 from local_caret_index to
rich_selection_index and D2 from rich_selection_index to local_selection_index.
If the op is not called inside a rich text only local_caret_index and local_selection_index are called with the default data values.
The rich selection is updated if needed. If the local caret or selection index of an widget is set to 0(start) it is automatically corrected to the end of the previous rich leaf.
Trait Implementations§
Source§impl Clone for TextSelectOp
impl Clone for TextSelectOp
Source§fn clone(&self) -> TextSelectOp
fn clone(&self) -> TextSelectOp
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TextSelectOp
impl !RefUnwindSafe for TextSelectOp
impl Send for TextSelectOp
impl Sync for TextSelectOp
impl Unpin for TextSelectOp
impl !UnwindSafe for TextSelectOp
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