Struct rat_widget::textarea::RTextAreaState

source ·
pub struct RTextAreaState {
    pub widget: TextAreaState,
    pub non_exhaustive: NonExhaustive,
}

Fields§

§widget: TextAreaState§non_exhaustive: NonExhaustive

Implementations§

source§

impl RTextAreaState

source

pub fn new() -> Self

source

pub fn clear(&mut self) -> bool

Reset to empty.

source

pub fn offset(&self) -> (usize, usize)

Offset shown.

source

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

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

source

pub fn cursor(&self) -> (usize, usize)

Cursor position.

source

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

Set the cursor position, reset selection.

source

pub fn anchor(&self) -> (usize, usize)

Selection anchor.

source

pub fn value(&self) -> String

Text.

source

pub fn value_range(&self, range: TextRange) -> Option<RopeSlice<'_>>

Text value

source

pub fn value_as_bytes(&self) -> Bytes<'_>

Text as Bytes iterator.

source

pub fn value_as_chars(&self) -> Chars<'_>

Text as Btes iterator.

source

pub fn set_value<S: AsRef<str>>(&mut self, s: S)

Set text.

source

pub fn set_value_rope(&mut self, s: Rope)

Set the text value as a Rope. Resets all internal state.

source

pub fn is_empty(&self) -> bool

Empty.

source

pub fn line_len(&self) -> usize

Text length as grapheme count.

source

pub fn line_width(&self, n: usize) -> Option<usize>

Line width as grapheme count.

source

pub fn line(&self, n: usize) -> Option<RopeGraphemes<'_>>

Grapheme iterator for a given line. This contains the \n at the end.

source

pub fn has_selection(&self) -> bool

Selection.

source

pub fn selection(&self) -> TextRange

Selection.

source

pub fn set_selection(&mut self, range: TextRange) -> bool

Selection.

source

pub fn select_all(&mut self) -> bool

Selection.

source

pub fn selected_value(&self) -> Option<RopeSlice<'_>>

Selection.

source

pub fn clear_styles(&mut self)

Clear all set styles.

source

pub fn add_style(&mut self, range: TextRange, style: usize)

Add a style for a TextRange. The style-nr refers to one of the styles set with the widget.

source

pub fn styles_at(&self, pos: (usize, usize), result: &mut Vec<usize>)

All styles active at the given position.

source

pub fn byte_pos(&self, byte: usize) -> Option<(usize, usize)>

Convert a byte position to a text area position. Uses grapheme based column indexes.

source

pub fn byte_at(&self, pos: (usize, usize)) -> Option<(usize, usize)>

Convert a text area position to a byte range. Uses grapheme based column indexes. Returns (byte-start, byte-end) of the grapheme at the given position.

source

pub fn char_pos(&self, byte: usize) -> Option<(usize, usize)>

Convert a char position to a text area position. Uses grapheme based column indexes.

source

pub fn char_at(&self, pos: (usize, usize)) -> Option<usize>

Convert a text area position to a char position. Uses grapheme based column indexes.

source

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

Insert a char at the current position.

source

pub fn insert_newline(&mut self) -> bool

Insert a line break at the cursor position.

source

pub fn delete_range(&mut self, range: TextRange) -> bool

Deletes the given range.

source

pub fn delete_next_char(&mut self) -> bool

Delete the char after the cursor.

source

pub fn delete_prev_char(&mut self) -> bool

Delete the char before the cursor.

source

pub fn delete_next_word(&mut self) -> bool

Deletes the next word.

source

pub fn delete_prev_word(&mut self) -> bool

Deletes the given range.

source

pub fn move_left(&mut self, n: usize, extend_selection: bool) -> bool

Move the cursor left. Scrolls the cursor to visible. Returns true if there was any real change.

source

pub fn move_right(&mut self, n: usize, extend_selection: bool) -> bool

Move the cursor right. Scrolls the cursor to visible. Returns true if there was any real change.

source

pub fn move_up(&mut self, n: usize, extend_selection: bool) -> bool

Move the cursor up. Scrolls the cursor to visible. Returns true if there was any real change.

source

pub fn move_down(&mut self, n: usize, extend_selection: bool) -> bool

Move the cursor down. Scrolls the cursor to visible. Returns true if there was any real change.

source

pub fn move_to_line_start(&mut self, extend_selection: bool) -> bool

Move the cursor to the start of the line. Scrolls the cursor to visible. Returns true if there was any real change.

source

pub fn move_to_line_end(&mut self, extend_selection: bool) -> bool

Move the cursor to the end of the line. Scrolls to visible, if necessary. Returns true if there was any real change.

source

pub fn move_to_start(&mut self, extend_selection: bool) -> bool

Move the cursor to the document start.

source

pub fn move_to_end(&mut self, extend_selection: bool) -> bool

Move the cursor to the document end.

source

pub fn move_to_screen_start(&mut self, extend_selection: bool) -> bool

Move the cursor to the start of the visible area.

source

pub fn move_to_screen_end(&mut self, extend_selection: bool) -> bool

Move the cursor to the end of the visible area.

source

pub fn move_to_next_word(&mut self, extend_selection: bool) -> bool

source

pub fn move_to_prev_word(&mut self, extend_selection: bool) -> bool

source

pub fn from_screen_col(&self, row: usize, x: usize) -> Option<usize>

Converts from a widget relative screen coordinate to a grapheme index. Row is a row-index into the value, not a screen-row. x is the relative screen position.

source

pub fn to_screen_col(&self, pos: (usize, usize)) -> Option<u16>

Converts a grapheme based position to a screen position relative to the widget area.

source

pub fn screen_cursor(&self) -> Option<(u16, u16)>

The current text cursor as an absolute screen position.

source

pub fn set_screen_cursor( &mut self, cursor: (i16, i16), extend_selection: bool, ) -> bool

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

Trait Implementations§

source§

impl Clone for RTextAreaState

source§

fn clone(&self) -> RTextAreaState

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 RTextAreaState

source§

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

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

impl Default for RTextAreaState

source§

fn default() -> Self

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

impl HandleEvent<Event, FocusKeys, TextOutcome> for RTextAreaState

source§

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

Handle an event. Read more
source§

impl HandleEvent<Event, MouseOnly, TextOutcome> for RTextAreaState

source§

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

Handle an event. Read more
source§

impl HandleEvent<Event, ReadOnly, TextOutcome> for RTextAreaState

source§

fn handle(&mut self, event: &Event, _keymap: ReadOnly) -> TextOutcome

Handle an event. Read more
source§

impl HasFocusFlag for RTextAreaState

source§

fn focus(&self) -> &FocusFlag

Access to the flag for the rest.
source§

fn area(&self) -> Rect

Access the area for mouse focus.
source§

fn is_focused(&self) -> bool

Focused?
source§

fn lost_focus(&self) -> bool

Just lost focus.
source§

fn gained_focus(&self) -> bool

Just gained focus.
source§

impl ScrollingState for RTextAreaState

source§

fn vertical_max_offset(&self) -> usize

Maximum offset that is accessible with scrolling. Read more
source§

fn vertical_offset(&self) -> usize

Current vertical offset.
source§

fn vertical_page(&self) -> usize

Vertical page-size at the current offset.
source§

fn horizontal_max_offset(&self) -> usize

Maximum offset that is accessible with scrolling. Read more
source§

fn horizontal_offset(&self) -> usize

Current horizontal offset.
source§

fn horizontal_page(&self) -> usize

Horizontal page-size at the current offset.
source§

fn set_vertical_offset(&mut self, offset: usize) -> bool

Change the vertical offset. Read more
source§

fn set_horizontal_offset(&mut self, offset: usize) -> bool

Change the horizontal offset. Read more
source§

fn vertical_scroll(&self) -> usize

Suggested scroll per scroll-event.
source§

fn horizontal_scroll(&self) -> usize

Suggested scroll per scroll-event.
source§

fn scroll_up(&mut self, n: usize) -> bool

Scroll up by n items. The widget returns true if the offset changed at all.
source§

fn scroll_down(&mut self, n: usize) -> bool

Scroll down by n items. The widget returns true if the offset changed at all.
source§

fn scroll_left(&mut self, n: usize) -> bool

Scroll up by n items. The widget returns true if the offset changed at all.
source§

fn scroll_right(&mut self, n: usize) -> bool

Scroll down by n items. The widget returns true if the offset changed at all.
source§

impl<'a> ScrollingWidget<RTextAreaState> for RTextArea<'a>

source§

fn need_scroll(&self, area: Rect, state: &mut RTextAreaState) -> (bool, bool)

Widget wants a (horizontal, vertical) scrollbar. This gets combined with the ScrollbarPolicy.

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.