Struct rat_input::input::TextInputState

source ·
pub struct TextInputState {
    pub cursor: Option<Position>,
    pub area: Rect,
    pub mouse: MouseFlags,
    pub value: InputCore,
    pub non_exhaustive: NonExhaustive,
}
Expand description

Input state data.

Fields§

§cursor: Option<Position>

The position of the cursor in screen coordinates. Can be directly used for [Frame::set_cursor()]

§area: Rect

Area inside a possible block.

§mouse: MouseFlags

Mouse selection in progress.

§value: InputCore

Editing core

§non_exhaustive: NonExhaustive

Construct with ..Default::default()

Implementations§

source§

impl TextInputState

source

pub fn reset(&mut self)

Reset to empty.

source

pub fn offset(&self) -> usize

Offset shown.

source

pub fn set_offset(&mut self, offset: usize)

Offset shown. This is corrected if the cursor wouldn’t be visible.

source

pub fn set_cursor(&mut self, cursor: usize, extend_selection: bool)

Set the cursor position, reset selection.

source

pub fn cursor(&self) -> usize

Cursor position.

source

pub fn set_value<S: Into<String>>(&mut self, s: S)

Set text.

source

pub fn value(&self) -> &str

Text.

source

pub fn as_str(&self) -> &str

Text

source

pub fn is_empty(&self) -> bool

Empty.

source

pub fn len(&self) -> usize

Text length as grapheme count.

source

pub fn has_selection(&self) -> bool

Selection.

source

pub fn set_selection(&mut self, anchor: usize, cursor: usize)

Selection.

source

pub fn select_all(&mut self)

Selection.

source

pub fn selection(&self) -> Range<usize>

Selection.

source

pub fn selection_str(&self) -> &str

Selection.

source

pub fn prev_word_boundary(&self) -> usize

Previous word boundary

source

pub fn next_word_boundary(&self) -> usize

Next word boundary

source

pub fn set_visual_cursor(&mut self, rpos: isize, extend_selection: bool)

Set the cursor position from a visual position relative to the origin.

source

pub fn screen_cursor(&self) -> Option<Position>

The current text cursor as an absolute screen position.

source

pub fn move_to_next(&mut self, extend_selection: bool)

Move to the next char.

source

pub fn move_to_prev(&mut self, extend_selection: bool)

Move to the previous char.

source

pub fn insert_char(&mut self, c: char)

Insert a char a the current position.

source

pub fn replace(&mut self, range: Range<usize>, new: &str)

Replace the given range with a new string.

source

pub fn delete_prev_char(&mut self)

Delete the char before the cursor.

source

pub fn delete_next_char(&mut self)

Delete the char after the cursor.

Trait Implementations§

source§

impl Clone for TextInputState

source§

fn clone(&self) -> TextInputState

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 TextInputState

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for TextInputState

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl HandleEvent<Event, FocusKeys, Outcome> for TextInputState

source§

fn handle(&mut self, event: &Event, _keymap: FocusKeys) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, MouseOnly, Outcome> for TextInputState

source§

fn handle(&mut self, event: &Event, _keymap: MouseOnly) -> Outcome

Handle an event. 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.