TextAreaState

Struct TextAreaState 

Source
pub struct TextAreaState {
Show 20 fields pub area: Rect, pub inner: Rect, pub rendered: Size, pub screen_cursor: Option<(u16, u16)>, pub hscroll: ScrollState, pub vscroll: ScrollState, pub sub_row_offset: u32, pub dark_offset: (u16, u16), pub scroll_to_cursor: Rc<Cell<bool>>, pub value: TextCore<TextRope>, pub move_col: Option<i16>, pub auto_indent: bool, pub auto_quote: bool, pub text_wrap: TextWrap, pub newline: String, pub tab_width: u32, pub expand_tabs: bool, pub focus: FocusFlag, pub mouse: MouseFlags, pub non_exhaustive: NonExhaustive,
}
Expand description

State & event handling.

Fields§

§area: Rect

The whole area with block. read only renewed with each render.

§inner: Rect

Area inside a possible block. read only renewed with each render.

§rendered: Size

Rendered dimension. This may differ from (inner.width, inner.height) if the text area has been relocated/clipped. This holds the original rendered dimension before any relocation/clipping.

§screen_cursor: Option<(u16, u16)>

Cursor position on the screen.

§hscroll: ScrollState

Horizontal scroll. When text-break is active this value is ignored. read+write

§vscroll: ScrollState

Vertical offset. read+write

§sub_row_offset: u32

When text-break is active, this is the grapheme-offset into the first visible text-row where the display actually starts. read+write but it’s not advised.

§dark_offset: (u16, u16)

Dark offset due to clipping. Set during render. read only ignore this value.

§scroll_to_cursor: Rc<Cell<bool>>

The scroll offset will be adjusted to display the cursor. This will be the minimal adjustment, the cursor will stay at the same screen position if it’s already visible or appear at the start/end if it’s not. read only use scroll_cursor_to_visible.

§value: TextCore<TextRope>

Text edit core

§move_col: Option<i16>

Memory-column for up/down movement.

Up/down movement tries to place the cursor at this column, but might have to clip it, because the current line is too short.

This is kept as a relative screen-position. It may be less than 0, if the widget has been relocated. read only

§auto_indent: bool

auto indent active read only

§auto_quote: bool

quote selection active read only

§text_wrap: TextWrap

text breaking read only

§newline: String

new-line bytes read only

§tab_width: u32

tab-width read only

§expand_tabs: bool

expand tabs read only

§focus: FocusFlag

Current focus state. read + write But don’t write it.

§mouse: MouseFlags

Mouse selection in progress. read+write

§non_exhaustive: NonExhaustive

Implementations§

Source§

impl TextAreaState

Source

pub fn new() -> TextAreaState

New State.

Source

pub fn named(name: &str) -> TextAreaState

New state with a focus name.

Source

pub fn set_newline(&mut self, br: impl Into<String>)

Sets the line ending used for insert. There is no auto-detection or conversion done for set_value().

Caution: If this doesn’t match the line ending used in the value, you will get a value with mixed line endings.

Source

pub fn newline(&self) -> &str

Line ending used for insert.

Source

pub fn set_auto_indent(&mut self, indent: bool)

Sets auto-indent on new-line.

Source

pub fn set_auto_quote(&mut self, quote: bool)

Activates ‘add quotes to selection’.

Source

pub fn set_tab_width(&mut self, tabs: u32)

Set tab-width.

Source

pub fn tab_width(&self) -> u32

Tab-width

Source

pub fn set_expand_tabs(&mut self, expand: bool)

Expand tabs to spaces. Only for new inputs.

Source

pub fn expand_tabs(&self) -> bool

Expand tabs to spaces. Only for new inputs.

Source

pub fn set_show_ctrl(&mut self, show_ctrl: bool)

Show glyphs for control characters.

Source

pub fn show_ctrl(&self) -> bool

Show glyphs for control characters.

Source

pub fn set_wrap_ctrl(&mut self, wrap_ctrl: bool)

Show glyphs for text-wrapping. Shows inserted line-breaks, zero-width space (U+200B) or the soft hyphen (U+00AD).

Source

pub fn wrap_ctrl(&self) -> bool

Show glyphs for text-wrapping. Shows inserted line-breaks, zero-width space (U+200B) or the soft hyphen (U+00AD).

Source

pub fn set_text_wrap(&mut self, text_wrap: TextWrap)

Text wrapping mode.

  • TextWrap::Shift means no wrapping.

  • TextWrap::Hard hard-wraps at the right border.

  • TextWrap::Word(n) does word wrapping. n gives the size of the break-region close to the right border. The first space that falls in this region is taken as a break. If that is not possible this will break at the last space before. If there is no space it will hard-wrap the word.

    Space is used as word separator. Hyphen will be used to break a word, and soft-hyphen and zero-width-space will be recognized too.

Source

pub fn text_wrap(&self) -> TextWrap

Text wrapping.

Source

pub fn set_move_col(&mut self, col: Option<i16>)

Extra column information for cursor movement.

The cursor position is capped to the current line length, so if you move up one row, you might end at a position left of the current column. If you move up once more you want to return to the original position. That’s what is stored here.

This stores the relative screen-column, it may be less than 0 if the widget has been relocated.

Source

pub fn move_col(&mut self) -> Option<i16>

Extra column information for cursor movement.

Source§

impl TextAreaState

Source

pub fn set_clipboard(&mut self, clip: Option<impl Clipboard + 'static>)

Clipboard used. Default is to use the global_clipboard().

Source

pub fn clipboard(&self) -> Option<&dyn Clipboard>

Clipboard used. Default is to use the global_clipboard().

Source

pub fn copy_to_clip(&mut self) -> bool

Copy selection to clipboard.

Source

pub fn cut_to_clip(&mut self) -> bool

Cut selection to clipboard.

Source

pub fn paste_from_clip(&mut self) -> bool

Paste from clipboard.

Source§

impl TextAreaState

Source

pub fn set_undo_buffer(&mut self, undo: Option<impl UndoBuffer + 'static>)

Set the undo buffer.

Default is an undo-buffer with 99 undoes.

Adjacent edits will be merged automatically into a single undo. (Type multiple characters, they will be undone in one go.)

Source

pub fn undo_buffer(&self) -> Option<&dyn UndoBuffer>

Access the undo buffer.

Source

pub fn undo_buffer_mut(&mut self) -> Option<&mut dyn UndoBuffer>

Access the undo buffer.

Source

pub fn begin_undo_seq(&mut self)

Begin a sequence of changes that should be undone in one go.

Call begin_undo_seq(), then call any edit-functions. When you are done call end_undo_seq(). Any changes will be undone in a single step.

Source

pub fn end_undo_seq(&mut self)

End a sequence of changes that should be undone in one go.

Source

pub fn recent_replay_log(&mut self) -> Vec<UndoEntry>

Get all recent replay recordings. This log can be sent to a second TextAreaState and can be applied with replay_log().

There are some caveats.

Source

pub fn replay_log(&mut self, replay: &[UndoEntry])

Apply the replay recording.

There are some caveats.

Source

pub fn undo(&mut self) -> bool

Do one undo.

Source

pub fn redo(&mut self) -> bool

Do one redo.

Source§

impl TextAreaState

Source

pub fn set_styles(&mut self, styles: Vec<(Range<usize>, usize)>)

Set and replace all styles.

The ranges are byte-ranges into the text. There is no verification that the ranges fit the text.

Each byte-range maps to an index into the styles set with the widget.

Any style-idx that don’t have a match there are just ignored. You can use this to store other range based information. The ranges are corrected during edits, no need to recalculate everything after each keystroke.

But this is only a very basic correction based on insertions and deletes. If you use this for syntax-highlighting you probably need to rebuild the styles.

Source

pub fn set_range_styles( &mut self, styles: Vec<(TextRange, usize)>, ) -> Result<(), TextError>

Set and replace all styles.

The ranges are TextRanges into the text. Each byte-range maps to an index into the styles set with the widget.

Any style-idx that don’t have a match there are just ignored. You can use this to store other range based information. The ranges are corrected during edits, no need to recalculate everything after each keystroke.

Source

pub fn add_style(&mut self, range: Range<usize>, style: usize)

Add a style for a byte-range.

The style-idx refers to one of the styles set with the widget. Missing styles are just ignored.

Source

pub fn add_range_style( &mut self, range: impl Into<TextRange>, style: usize, ) -> Result<(), TextError>

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

Source

pub fn remove_style(&mut self, range: Range<usize>, style: usize)

Remove the exact byte-range and style.

Source

pub fn remove_style_fully(&mut self, style: usize)

Remove all ranges for the given style.

Source

pub fn remove_range_style( &mut self, range: impl Into<TextRange>, style: usize, ) -> Result<(), TextError>

Remove the exact TextRange and style.

Source

pub fn styles_in( &self, range: Range<usize>, buf: &mut Vec<(Range<usize>, usize)>, )

Find all styles that touch the given range.

Source

pub fn styles_in_match( &self, range: Range<usize>, style: usize, buf: &mut Vec<(Range<usize>, usize)>, )

Find all styles that touch the given range.

Source

pub fn styles_at(&self, byte_pos: usize, buf: &mut Vec<(Range<usize>, usize)>)

All styles active at the given position.

Source

pub fn styles_at_match( &self, byte_pos: usize, style: usize, ) -> Option<Range<usize>>

Check if the given style applies at the position and return the complete range for the style.

Source

pub fn styles(&self) -> Option<impl Iterator<Item = (Range<usize>, usize)>>

List of all styles.

Source§

impl TextAreaState

Source

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

Current offset for scrolling.

Source

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

Set the offset for scrolling.

The offset uses usize, but it shouldn’t exceed (u32::MAX, u32::MAX). This is due to the internal ScrollState that only knows usize.

Source

pub fn set_sub_row_offset(&mut self, sub_row_offset: u32) -> bool

Scrolling uses the offset() for the start of the displayed text. When text-wrapping is active, this is not enough. This gives an extra offset into the first row where rendering should start.

You probably don’t want to set this value. Use set_cursor() instead, it will automatically scroll to make the cursor visible.

If you really want, pos_to_line_start() can help to find the start-position of a visual row. The x-value of the returned TextPosition is a valid value for this function.

Source

pub fn sub_row_offset(&self) -> u32

Returns the extra offset into the first row where rendering starts. This is only valid if text-wrapping is active.

Returns the index of the column.

Source

pub fn cursor(&self) -> TextPosition

Cursor position.

Source

pub fn set_cursor( &mut self, cursor: impl Into<TextPosition>, extend_selection: bool, ) -> bool

Set the cursor position and scroll the cursor to a visible offset.

Source

pub fn anchor(&self) -> TextPosition

Selection anchor.

Source

pub fn has_selection(&self) -> bool

Has a selection?

Source

pub fn selection(&self) -> TextRange

Current selection.

Source

pub fn set_selection( &mut self, anchor: impl Into<TextPosition>, cursor: impl Into<TextPosition>, ) -> bool

Set the selection, anchor and cursor are capped to a valid value. Scrolls the cursor to a visible position.

Source

pub fn select_all(&mut self) -> bool

Select all. Scrolls the cursor to a visible position.

Source

pub fn selected_text(&self) -> Cow<'_, str>

Selected text.

Source§

impl TextAreaState

Source

pub fn clear(&mut self) -> bool

Clear everything.

Source

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

Set the text value.

Resets all internal state.

Source

pub fn text(&self) -> String

Copy of the text-value.

Source

pub fn set_rope(&mut self, r: Rope)

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

Source

pub fn rope(&self) -> &Rope

Access the underlying rope.

Source

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

Set the text value.

Resets all internal state.

Source

pub fn value(&self) -> String

Copy of the text-value.

Source

pub fn is_empty(&self) -> bool

Empty.

Source

pub fn str_slice_byte(&self, range: Range<usize>) -> Cow<'_, str>

Text slice as Cow<str>. Uses a byte range.

Panics for an invalid range.

Source

pub fn try_str_slice_byte( &self, range: Range<usize>, ) -> Result<Cow<'_, str>, TextError>

Text slice as Cow<str>. Uses a byte range.

Source

pub fn str_slice(&self, range: impl Into<TextRange>) -> Cow<'_, str>

Text slice as Cow<str>

Panics for an invalid range.

Source

pub fn try_str_slice( &self, range: impl Into<TextRange>, ) -> Result<Cow<'_, str>, TextError>

Text slice as Cow<str>

Source

pub fn len_lines(&self) -> u32

Line count.

Source

pub fn len_bytes(&self) -> usize

Length in bytes.

Source

pub fn line_width(&self, row: u32) -> u32

Line width as grapheme count.

Panics for an invalid row.

Source

pub fn try_line_width(&self, row: u32) -> Result<u32, TextError>

Line width as grapheme count.

Source

pub fn line_at(&self, row: u32) -> Cow<'_, str>

Line as Cow<str>. This contains the \n at the end.

Panics for an invalid row.

Source

pub fn try_line_at(&self, row: u32) -> Result<Cow<'_, str>, TextError>

Line as Cow<str>. This contains the \n at the end.

Source

pub fn lines_at(&self, row: u32) -> impl Iterator<Item = Cow<'_, str>>

Iterate over text-lines, starting at offset.

Panics for an invalid row.

Source

pub fn try_lines_at( &self, row: u32, ) -> Result<impl Iterator<Item = Cow<'_, str>>, TextError>

Iterate over text-lines, starting at offset.

Source

pub fn line_graphemes( &self, row: u32, ) -> <TextRope as TextStore>::GraphemeIter<'_>

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

Panics for an invalid row.

Source

pub fn try_line_graphemes( &self, row: u32, ) -> Result<<TextRope as TextStore>::GraphemeIter<'_>, TextError>

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

Source

pub fn text_graphemes( &self, pos: impl Into<TextPosition>, ) -> <TextRope as TextStore>::GraphemeIter<'_>

Get a cursor over all the text with the current position set at pos.

Panics for an invalid pos.

Source

pub fn try_text_graphemes( &self, pos: impl Into<TextPosition>, ) -> Result<<TextRope as TextStore>::GraphemeIter<'_>, TextError>

Get a cursor over all the text with the current position set at pos.

Source

pub fn graphemes( &self, range: impl Into<TextRange>, pos: impl Into<TextPosition>, ) -> <TextRope as TextStore>::GraphemeIter<'_>

Get a cursor over the text-range the current position set at pos.

Panics for an invalid pos.

Source

pub fn try_graphemes( &self, range: impl Into<TextRange>, pos: impl Into<TextPosition>, ) -> Result<<TextRope as TextStore>::GraphemeIter<'_>, TextError>

Get a cursor over the text-range the current position set at pos.

Source

pub fn byte_at(&self, pos: impl Into<TextPosition>) -> Range<usize>

Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.

Panics for an invalid pos.

Source

pub fn try_byte_at( &self, pos: impl Into<TextPosition>, ) -> Result<Range<usize>, TextError>

Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.

Source

pub fn bytes_at_range(&self, range: impl Into<TextRange>) -> Range<usize>

Grapheme range to byte range.

Panics for an invalid range.

Source

pub fn try_bytes_at_range( &self, range: impl Into<TextRange>, ) -> Result<Range<usize>, TextError>

Grapheme range to byte range.

Source

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

Byte position to grapheme position. Returns the position that contains the given byte index.

Panics for an invalid byte pos.

Source

pub fn try_byte_pos(&self, byte: usize) -> Result<TextPosition, TextError>

Byte position to grapheme position. Returns the position that contains the given byte index.

Source

pub fn byte_range(&self, bytes: Range<usize>) -> TextRange

Byte range to grapheme range.

Panics for an invalid range.

Source

pub fn try_byte_range( &self, bytes: Range<usize>, ) -> Result<TextRange, TextError>

Byte range to grapheme range.

Source§

impl TextAreaState

Source

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

Insert a character at the cursor position. Removes the selection and inserts the char.

This function can handle ‘\t’ and ‘\n’ well. They call insert_tab() and insert_newline() respectively.

Source

pub fn insert_tab(&mut self) -> bool

Inserts tab at the current position. This respects the tab-width set.

If there is a text-selection the text-rows will be indented instead. This can be deactivated with auto_indent=false.

Source

pub fn insert_backtab(&mut self) -> bool

Dedent the selected text by tab-width. If there is no selection this does nothing.

This can be deactivated with auto_indent=false.

Source

pub fn insert_str(&mut self, t: impl AsRef<str>) -> bool

Insert text at the cursor position. Removes the selection and inserts the text.

Source

pub fn insert_newline(&mut self) -> bool

Insert a line break at the cursor position.

If auto_indent is set the new line starts with the same indent as the current.

Source

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

Deletes the given range.

Panics for an invalid range.

Source

pub fn try_delete_range( &mut self, range: impl Into<TextRange>, ) -> Result<bool, TextError>

Deletes the given range.

Source

pub fn duplicate_text(&mut self) -> bool

Duplicates the selection or the current line. Returns true if there was any real change.

Source

pub fn delete_line(&mut self) -> bool

Deletes the current line. Returns true if there was any real change.

Source

pub fn delete_next_char(&mut self) -> bool

Deletes the next char or the current selection. Returns true if there was any real change.

Source

pub fn delete_prev_char(&mut self) -> bool

Deletes the previous char or the selection. Returns true if there was any real change.

Source

pub fn next_word_start(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the start of the next word. If the position is at the start or inside a word, the same position is returned.

Panics for an invalid pos.

Source

pub fn try_next_word_start( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the start of the next word. If the position is at the start or inside a word, the same position is returned.

Source

pub fn next_word_end(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the end of the next word. Skips whitespace first, then goes on until it finds the next whitespace.

Panics for an invalid pos.

Source

pub fn try_next_word_end( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the end of the next word. Skips whitespace first, then goes on until it finds the next whitespace.

Source

pub fn prev_word_start(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the start of the prev word. Skips whitespace first, then goes on until it finds the next whitespace.

Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Panics for an invalid range.

Source

pub fn try_prev_word_start( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the start of the prev word. Skips whitespace first, then goes on until it finds the next whitespace.

Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Source

pub fn prev_word_end(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the end of the previous word. Word is everything that is not whitespace. Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Panics for an invalid range.

Source

pub fn try_prev_word_end( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the end of the previous word. Word is everything that is not whitespace. Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Source

pub fn is_word_boundary(&self, pos: impl Into<TextPosition>) -> bool

Is the position at a word boundary?

Panics for an invalid range.

Source

pub fn try_is_word_boundary( &self, pos: impl Into<TextPosition>, ) -> Result<bool, TextError>

Is the position at a word boundary?

Source

pub fn word_start(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the start of the word at pos. Returns pos if the position is not inside a word.

Panics for an invalid range.

Source

pub fn try_word_start( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the start of the word at pos. Returns pos if the position is not inside a word.

Source

pub fn word_end(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the end of the word at pos. Returns pos if the position is not inside a word.

Panics for an invalid range.

Source

pub fn try_word_end( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the end of the word at pos. Returns pos if the position is not inside a word.

Source

pub fn delete_next_word(&mut self) -> bool

Delete the next word. This alternates deleting the whitespace between words and the words themselves.

If there is a selection, removes only the selected text.

Source

pub fn delete_prev_word(&mut self) -> bool

Deletes the previous word. This alternates deleting the whitespace between words and the words themselves.

If there is a selection, removes only the selected text.

Source

pub fn search(&mut self, re: &str) -> Result<bool, TextError>

Search for a regex.

Uses match_style for highlighting the matches. This doesn’t change the cursor/selection, use [move_to_next_match] or [move_to_prev_match] for this.

Return

Returns true if the search found anything.

Source

pub fn move_to_next_match(&mut self) -> bool

Move to the next match.

Source

pub fn move_to_prev_match(&mut self) -> bool

Move to the next match.

Clear the search.

Source

pub fn move_left(&mut self, n: u16, 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: u16, 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: u16, 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: u16, 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

Move the cursor to the next word.

Source

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

Move the cursor to the previous word.

Source§

impl TextAreaState

Source

pub fn relative_screen_to_pos( &self, scr_pos: (i16, i16), ) -> Option<TextPosition>

Find the text-position for the widget-relative screen-position.

Source

pub fn screen_to_pos(&self, scr_pos: (u16, u16)) -> Option<TextPosition>

Find the text-position for an absolute screen-position.

Source

pub fn pos_to_relative_screen( &self, pos: impl Into<TextPosition>, ) -> Option<(i16, i16)>

Return the screen_position for the given text position relative to the origin of the widget.

This may be outside the visible area, if the text-area has been relocated. It may even be outside the screen, so this returns an (i16, i16).

If the text-position is outside the rendered area, this will return None.

Source

pub fn pos_to_screen(&self, pos: impl Into<TextPosition>) -> Option<(u16, u16)>

Find the absolute screen-position for a text-position.

Source

pub fn pos_to_line_start(&self, pos: impl Into<TextPosition>) -> TextPosition

Return the starting position for the visible line containing the given position.

Source

pub fn pos_to_line_end(&self, pos: impl Into<TextPosition>) -> TextPosition

Return the end position for the visible line containing the given position.

Source

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

Set the cursor position from screen coordinates.

The cursor positions are relative to the inner rect. They may be negative too, this allows setting the cursor to a position that is currently scrolled away.

Source

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

Set the cursor position from screen coordinates, rounds the position to the next word start/end.

The cursor positions are relative to the inner rect. They may be negative too, this allows setting the cursor to a position that is currently scrolled away.

Source§

impl TextAreaState

Source

pub fn vertical_max_offset(&self) -> u32

Maximum offset that is accessible with scrolling.

This is set to len_lines - page_size for shift-mode, and to len_lines for any wrapping-mode.

Source

pub fn vertical_offset(&self) -> u32

Current vertical offset.

Source

pub fn vertical_page(&self) -> u32

Rendered height of the widget.

Source

pub fn vertical_scroll(&self) -> u32

Suggested scroll per scroll-event.

Source

pub fn horizontal_max_offset(&self) -> u32

Maximum horizontal offset.

This is set to 0 when text-wrapping is active. Otherwise, it can be set manually, but is always ignored by all scroll-functions. This widget doesn’t try to find an overall text-width.

It will be used to render the scrollbar though.

Source

pub fn horizontal_offset(&self) -> u32

Current horizontal offset.

Source

pub fn horizontal_page(&self) -> u32

Rendered width of the text-area.

Source

pub fn horizontal_scroll(&self) -> u32

Suggested scroll-by per scroll-event.

Source

pub fn set_vertical_offset(&mut self, row_offset: u32) -> bool

Change the vertical offset. There is no limit to this offset.

Return

true if the offset changed at all.

Source

pub fn set_horizontal_offset(&mut self, col_offset: u32) -> bool

Change the horizontal offset.

There is no limit to this offset. If there is text-wrapping this offset will be ignored.

Return

true if the offset changed at all.

Source

pub fn scroll_cursor_to_visible(&mut self)

Scroll that the cursor is visible.

This positioning happens with the next render.

All move-fn do this automatically.

Source

pub fn scroll_to_pos(&mut self, pos: impl Into<TextPosition>) -> bool

Scrolls to make the given position visible.

Caveat

This function works correctly after the first render.

Source

pub fn scroll_to_row(&mut self, pos: u32) -> bool

Scrolls to make the given row visible.

Adjusts the offset just enough to make this happen. Does nothing if the position is already visible.

Return

true if the offset changed.

Source

pub fn scroll_to_col(&mut self, pos: u32) -> bool

Scroll to make the given column visible.

This scroll-offset is ignored if there is any text-wrapping.

Return

true if the offset changed.

Source

pub fn scroll_up(&mut self, delta: u32) -> bool

Scroll up by delta rows.

Return

true if the offset changes.

Source

pub fn scroll_down(&mut self, delta: u32) -> bool

Scroll down by delta rows.

Return

true if the offset changes.

Source

pub fn scroll_left(&mut self, delta: u32) -> bool

Scroll left by delta columns.

This ignores the max_offset, as that is never correct anyway.

Return

true if the offset changes.

Caveat

Does nothing if text-wrapping is active.

Source

pub fn scroll_right(&mut self, delta: u32) -> bool

Scroll right by delta columns.

This ignores the max_offset, as that is never correct anyway.

Return

trueif the offset changes.

Caveat

Does nothing if text-wrapping is active.

Trait Implementations§

Source§

impl Clone for TextAreaState

Source§

fn clone(&self) -> TextAreaState

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 TextAreaState

Source§

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

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

impl Default for TextAreaState

Source§

fn default() -> TextAreaState

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

impl HandleEvent<Event, MouseOnly, TextOutcome> for TextAreaState

Source§

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

Handle an event. Read more
Source§

impl HandleEvent<Event, ReadOnly, TextOutcome> for TextAreaState

Source§

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

Handle an event. Read more
Source§

impl HandleEvent<Event, Regular, TextOutcome> for TextAreaState

Source§

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

Handle an event. Read more
Source§

impl HasFocus for TextAreaState

Source§

fn build(&self, builder: &mut FocusBuilder)

Build the focus-structure for the container.
Source§

fn focus(&self) -> FocusFlag

Access to the flag for the rest.
Source§

fn area(&self) -> Rect

Area for mouse focus. Read more
Source§

fn navigable(&self) -> Navigation

Declares how the widget interacts with focus. Read more
Source§

fn id(&self) -> usize

Provide a unique id for the widget.
Source§

fn area_z(&self) -> u16

Z value for the area. Read more
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 HasScreenCursor for TextAreaState

Source§

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

Cursor position on the screen.

Source§

impl RelocatableState for TextAreaState

Source§

fn relocate(&mut self, shift: (i16, i16), clip: Rect)

Relocate the areas in this widgets state. Read more
Source§

fn relocate_popup(&mut self, shift: (i16, i16), clip: Rect)

Relocate only popup areas. As rendering the popups is a separate render, this has to be separate too.
Source§

fn relocate_popup_hidden(&mut self)

Relocate all popup areas to a clip-rect (0,0+0x0).
Source§

fn relocate_hidden(&mut self)

Relocate all areas to a clip-rect (0,0+0x0).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
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, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
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> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
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, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. 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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.