TextSelectOp

Struct TextSelectOp 

Source
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

Source

pub fn next() -> Self

Clear selection and move the caret to the next insert index.

This is the Right key operation.

Source

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.

Source

pub fn prev() -> Self

Clear selection and move the caret to the previous insert index.

This is the Left key operation.

Source

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.

Source

pub fn next_word() -> Self

Clear selection and move the caret to the next word insert index.

This is the CTRL+Right shortcut operation.

Source

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.

Source

pub fn prev_word() -> Self

Clear selection and move the caret to the previous word insert index.

This is the CTRL+Left shortcut operation.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn page_up() -> Self

Clear selection and move the caret one viewport up.

This is the PageUp key operation.

Source

pub fn select_page_up() -> Self

Extend or shrink selection by moving the caret one viewport up.

This is the SHIFT+PageUp key operation.

Source

pub fn page_down() -> Self

Clear selection and move the caret one viewport down.

This is the PageDown key operation.

Source

pub fn select_page_down() -> Self

Extend or shrink selection by moving the caret one viewport down.

This is the SHIFT+PageDown key operation.

Source

pub fn line_start() -> Self

Clear selection and move the caret to the start of the line.

This is the Home key operation.

Source

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.

Source

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.

Source

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.

Source

pub fn text_start() -> Self

Clear selection and move the caret to the text start.

This is the CTRL+Home shortcut operation.

Source

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.

Source

pub fn text_end() -> Self

Clear selection and move the caret to the text end.

This is the CTRL+End shortcut operation.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn select_all() -> Self

Select the full text.

Source

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.

Source

pub fn local_next() -> Self

Like next but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_next() -> Self

Like select_next but stays within the same text widget, ignores rich text context.

Source

pub fn local_prev() -> Self

Like prev but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_prev() -> Self

Like select_prev but stays within the same text widget, ignores rich text context.

Source

pub fn local_next_word() -> Self

Like next_word but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_next_word() -> Self

Like select_next_word but stays within the same text widget, ignores rich text context.

Source

pub fn local_prev_word() -> Self

Like prev_word but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_prev_word() -> Self

Like select_prev_word but stays within the same text widget, ignores rich text context.

Source

pub fn local_line_start() -> Self

Like line_start but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_line_start() -> Self

Like select_line_start but stays within the same text widget, ignores rich text context.

Source

pub fn local_line_end() -> Self

Like line_end but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_line_end() -> Self

Like select_line_end but stays within the same text widget, ignores rich text context.

Source

pub fn local_text_start() -> Self

Like text_start but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_text_start() -> Self

Like select_text_start but stays within the same text widget, ignores rich text context.

Source

pub fn local_text_end() -> Self

Like text_end but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_text_end() -> Self

Like select_text_end but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_all() -> Self

Like select_all but stays within the same text widget, ignores rich text context.

Source

pub fn local_clear_selection() -> Self

Like clear_selection but stays within the same text widget, ignores rich text context.

Source

pub fn local_line_up() -> Self

Like line_up but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_line_up() -> Self

Like select_line_up but stays within the same text widget, ignores rich text context.

Source

pub fn local_line_down() -> Self

Like line_down but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_line_down() -> Self

Like select_line_down but stays within the same text widget, ignores rich text context.

Source

pub fn local_page_up() -> Self

Like page_up but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_page_up() -> Self

Like select_page_up but stays within the same text widget, ignores rich text context.

Source

pub fn local_page_down() -> Self

Like page_down but stays within the same text widget, ignores rich text context.

Source

pub fn local_select_page_down() -> Self

Like select_page_down but stays within the same text widget, ignores rich text context.

Source

pub fn local_nearest_to(window_point: DipPoint) -> Self

Like nearest_to but stays within the same text widget, ignores rich text context.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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
where D0: Default + Send + 'static, D1: Send + 'static, D2: Default + Send + 'static,

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

Source§

fn clone(&self) -> TextSelectOp

Returns a duplicate 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 TextSelectOp

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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
Source§

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