pub struct TextAreaState {Show 13 fields
pub area: Rect,
pub inner: Rect,
pub hscroll: ScrollState,
pub vscroll: ScrollState,
pub dark_offset: (u16, u16),
pub scroll_to_cursor: bool,
pub value: TextCore<TextRope>,
pub move_col: Option<upos_type>,
pub auto_indent: bool,
pub auto_quote: bool,
pub focus: FocusFlag,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
State & event handling.
Fields§
§area: RectThe whole area with block. read only renewed with each render.
inner: RectArea inside a possible block. read only renewed with each render.
hscroll: ScrollStateHorizontal scroll read+write
vscroll: ScrollStateVertical offset read+write
dark_offset: (u16, u16)Dark offset due to clipping. read only secondary offset due to clipping.
scroll_to_cursor: boolThe 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+write use scroll_cursor_to_visible().
value: TextCore<TextRope>Text edit core
move_col: Option<upos_type>movement column
auto_indent: boolauto indent active
auto_quote: boolquote selection active
focus: FocusFlagCurrent focus state.
mouse: MouseFlagsMouse selection in progress. read+write
non_exhaustive: NonExhaustiveImplementations§
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn set_newline(&mut self, br: impl Into<String>)
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.
Sourcepub fn set_auto_indent(&mut self, indent: bool)
pub fn set_auto_indent(&mut self, indent: bool)
Sets auto-indent on new-line.
Sourcepub fn set_auto_quote(&mut self, quote: bool)
pub fn set_auto_quote(&mut self, quote: bool)
Activates ‘add quotes to selection’.
Sourcepub fn set_tab_width(&mut self, tabs: u16)
pub fn set_tab_width(&mut self, tabs: u16)
Set tab-width.
Sourcepub fn set_expand_tabs(&mut self, expand: bool)
pub fn set_expand_tabs(&mut self, expand: bool)
Expand tabs to spaces. Only for new inputs.
Sourcepub fn expand_tabs(&self) -> bool
pub fn expand_tabs(&self) -> bool
Expand tabs to spaces. Only for new inputs.
Sourcepub fn set_show_ctrl(&mut self, show_ctrl: bool)
pub fn set_show_ctrl(&mut self, show_ctrl: bool)
Show control characters.
Sourcepub fn set_move_col(&mut self, col: Option<upos_type>)
pub fn set_move_col(&mut self, col: Option<upos_type>)
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.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn set_clipboard(&mut self, clip: Option<impl Clipboard + 'static>)
pub fn set_clipboard(&mut self, clip: Option<impl Clipboard + 'static>)
Clipboard used. Default is to use the global_clipboard().
Sourcepub fn clipboard(&self) -> Option<&dyn Clipboard>
pub fn clipboard(&self) -> Option<&dyn Clipboard>
Clipboard used. Default is to use the global_clipboard().
Sourcepub fn copy_to_clip(&mut self) -> bool
pub fn copy_to_clip(&mut self) -> bool
Copy to internal buffer
Sourcepub fn cut_to_clip(&mut self) -> bool
pub fn cut_to_clip(&mut self) -> bool
Cut to internal buffer
Sourcepub fn paste_from_clip(&mut self) -> bool
pub fn paste_from_clip(&mut self) -> bool
Paste from internal buffer.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn set_undo_buffer(&mut self, undo: Option<impl UndoBuffer + 'static>)
pub fn set_undo_buffer(&mut self, undo: Option<impl UndoBuffer + 'static>)
Set undo buffer.
Sourcepub fn undo_buffer(&self) -> Option<&dyn UndoBuffer>
pub fn undo_buffer(&self) -> Option<&dyn UndoBuffer>
Undo
Sourcepub fn undo_buffer_mut(&mut self) -> Option<&mut dyn UndoBuffer>
pub fn undo_buffer_mut(&mut self) -> Option<&mut dyn UndoBuffer>
Undo
Sourcepub fn begin_undo_seq(&mut self)
pub fn begin_undo_seq(&mut self)
Begin a sequence of changes that should be undone in one go.
Sourcepub fn end_undo_seq(&mut self)
pub fn end_undo_seq(&mut self)
End a sequence of changes that should be undone in one go.
Sourcepub fn recent_replay_log(&mut self) -> Vec<UndoEntry>
pub fn recent_replay_log(&mut self) -> Vec<UndoEntry>
Get all recent replay recordings.
Sourcepub fn replay_log(&mut self, replay: &[UndoEntry])
pub fn replay_log(&mut self, replay: &[UndoEntry])
Apply the replay recording.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn set_styles(&mut self, styles: Vec<(Range<usize>, usize)>)
pub fn set_styles(&mut self, styles: Vec<(Range<usize>, usize)>)
Set and replace all styles.
The ranges are byte-ranges 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.
Sourcepub fn add_style(&mut self, range: Range<usize>, style: usize)
pub fn add_style(&mut self, range: Range<usize>, style: usize)
Add a style for a TextRange.
The style-idx refers to one of the styles set with the widget. Missing styles are just ignored.
Sourcepub fn add_range_style(
&mut self,
range: TextRange,
style: usize,
) -> Result<(), TextError>
pub fn add_range_style( &mut self, range: 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.
Sourcepub fn remove_style(&mut self, range: Range<usize>, style: usize)
pub fn remove_style(&mut self, range: Range<usize>, style: usize)
Remove the exact TextRange and style.
Sourcepub fn remove_range_style(
&mut self,
range: TextRange,
style: usize,
) -> Result<(), TextError>
pub fn remove_range_style( &mut self, range: TextRange, style: usize, ) -> Result<(), TextError>
Remove the exact TextRange and style.
Sourcepub fn styles_in(
&self,
range: Range<usize>,
buf: &mut Vec<(Range<usize>, usize)>,
)
pub fn styles_in( &self, range: Range<usize>, buf: &mut Vec<(Range<usize>, usize)>, )
Find all styles that touch the given range.
Sourcepub fn styles_at(&self, byte_pos: usize, buf: &mut Vec<(Range<usize>, usize)>)
pub fn styles_at(&self, byte_pos: usize, buf: &mut Vec<(Range<usize>, usize)>)
All styles active at the given position.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn set_offset(&mut self, offset: (usize, usize)) -> bool
pub fn set_offset(&mut self, offset: (usize, usize)) -> bool
Set the offset for scrolling.
Sourcepub fn cursor(&self) -> TextPosition
pub fn cursor(&self) -> TextPosition
Cursor position.
Sourcepub fn set_cursor(
&mut self,
cursor: impl Into<TextPosition>,
extend_selection: bool,
) -> bool
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.
Sourcepub fn anchor(&self) -> TextPosition
pub fn anchor(&self) -> TextPosition
Selection anchor.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Has a selection?
Sourcepub fn set_selection(
&mut self,
anchor: impl Into<TextPosition>,
cursor: impl Into<TextPosition>,
) -> bool
pub fn set_selection( &mut self, anchor: impl Into<TextPosition>, cursor: impl Into<TextPosition>, ) -> bool
Set the selection. Scrolls the cursor to a visible position.
Sourcepub fn select_all(&mut self) -> bool
pub fn select_all(&mut self) -> bool
Select all. Scrolls the cursor to a visible position.
Sourcepub fn selected_text(&self) -> Cow<'_, str>
pub fn selected_text(&self) -> Cow<'_, str>
Selection.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn str_slice_byte(&self, range: Range<usize>) -> Cow<'_, str>
pub fn str_slice_byte(&self, range: Range<usize>) -> Cow<'_, str>
Text slice as Cow<str>. Uses a byte range.
Sourcepub fn try_str_slice_byte(
&self,
range: Range<usize>,
) -> Result<Cow<'_, str>, TextError>
pub fn try_str_slice_byte( &self, range: Range<usize>, ) -> Result<Cow<'_, str>, TextError>
Text slice as Cow<str>. Uses a byte range.
Sourcepub fn try_str_slice(
&self,
range: impl Into<TextRange>,
) -> Result<Cow<'_, str>, TextError>
pub fn try_str_slice( &self, range: impl Into<TextRange>, ) -> Result<Cow<'_, str>, TextError>
Text slice as Cow<str>
Sourcepub fn line_width(&self, row: upos_type) -> upos_type
pub fn line_width(&self, row: upos_type) -> upos_type
Line width as grapheme count.
Sourcepub fn try_line_width(&self, row: upos_type) -> Result<upos_type, TextError>
pub fn try_line_width(&self, row: upos_type) -> Result<upos_type, TextError>
Line width as grapheme count.
Sourcepub fn line_at(&self, row: upos_type) -> Cow<'_, str>
pub fn line_at(&self, row: upos_type) -> Cow<'_, str>
Line as RopeSlice. This contains the \n at the end.
Sourcepub fn try_line_at(&self, row: upos_type) -> Result<Cow<'_, str>, TextError>
pub fn try_line_at(&self, row: upos_type) -> Result<Cow<'_, str>, TextError>
Line as RopeSlice. This contains the \n at the end.
Sourcepub fn lines_at(&self, row: upos_type) -> impl Iterator<Item = Cow<'_, str>>
pub fn lines_at(&self, row: upos_type) -> impl Iterator<Item = Cow<'_, str>>
Iterate over text-lines, starting at offset.
Sourcepub fn try_lines_at(
&self,
row: upos_type,
) -> Result<impl Iterator<Item = Cow<'_, str>>, TextError>
pub fn try_lines_at( &self, row: upos_type, ) -> Result<impl Iterator<Item = Cow<'_, str>>, TextError>
Iterate over text-lines, starting at offset.
Sourcepub fn glyphs(
&self,
rows: Range<upos_type>,
screen_offset: u16,
screen_width: u16,
) -> impl Iterator<Item = Glyph<'_>>
pub fn glyphs( &self, rows: Range<upos_type>, screen_offset: u16, screen_width: u16, ) -> impl Iterator<Item = Glyph<'_>>
Glyphs here a grapheme + display length.
Sourcepub fn try_glyphs(
&self,
rows: Range<upos_type>,
screen_offset: u16,
screen_width: u16,
) -> Result<impl Iterator<Item = Glyph<'_>>, TextError>
pub fn try_glyphs( &self, rows: Range<upos_type>, screen_offset: u16, screen_width: u16, ) -> Result<impl Iterator<Item = Glyph<'_>>, TextError>
Glyphs here a grapheme + display length.
Sourcepub fn line_graphemes(
&self,
row: upos_type,
) -> impl Iterator<Item = Grapheme<'_>>
pub fn line_graphemes( &self, row: upos_type, ) -> impl Iterator<Item = Grapheme<'_>>
Grapheme iterator for a given line. This contains the \n at the end.
Sourcepub fn try_line_graphemes(
&self,
row: upos_type,
) -> Result<impl Iterator<Item = Grapheme<'_>>, TextError>
pub fn try_line_graphemes( &self, row: upos_type, ) -> Result<impl Iterator<Item = Grapheme<'_>>, TextError>
Grapheme iterator for a given line. This contains the \n at the end.
Sourcepub fn text_graphemes(
&self,
pos: TextPosition,
) -> impl Cursor<Item = Grapheme<'_>>
pub fn text_graphemes( &self, pos: TextPosition, ) -> impl Cursor<Item = Grapheme<'_>>
Get a cursor over all the text with the current position set at pos.
Sourcepub fn try_text_graphemes(
&self,
pos: TextPosition,
) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
pub fn try_text_graphemes( &self, pos: TextPosition, ) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
Get a cursor over all the text with the current position set at pos.
Sourcepub fn graphemes(
&self,
range: TextRange,
pos: TextPosition,
) -> impl Cursor<Item = Grapheme<'_>>
pub fn graphemes( &self, range: TextRange, pos: TextPosition, ) -> impl Cursor<Item = Grapheme<'_>>
Get a cursor over the text-range the current position set at pos.
Sourcepub fn try_graphemes(
&self,
range: TextRange,
pos: TextPosition,
) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
pub fn try_graphemes( &self, range: TextRange, pos: TextPosition, ) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
Get a cursor over the text-range the current position set at pos.
Sourcepub fn byte_at(&self, pos: TextPosition) -> Range<usize>
pub fn byte_at(&self, pos: TextPosition) -> Range<usize>
Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.
Sourcepub fn try_byte_at(&self, pos: TextPosition) -> Result<Range<usize>, TextError>
pub fn try_byte_at(&self, pos: TextPosition) -> Result<Range<usize>, TextError>
Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.
Sourcepub fn try_bytes_at_range(
&self,
range: TextRange,
) -> Result<Range<usize>, TextError>
pub fn try_bytes_at_range( &self, range: TextRange, ) -> Result<Range<usize>, TextError>
Grapheme range to byte range.
Sourcepub fn bytes_at_range(&self, range: TextRange) -> Range<usize>
pub fn bytes_at_range(&self, range: TextRange) -> Range<usize>
Grapheme range to byte range.
Sourcepub fn byte_pos(&self, byte: usize) -> TextPosition
pub fn byte_pos(&self, byte: usize) -> TextPosition
Byte position to grapheme position. Returns the position that contains the given byte index.
Sourcepub fn try_byte_pos(&self, byte: usize) -> Result<TextPosition, TextError>
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.
Sourcepub fn byte_range(&self, bytes: Range<usize>) -> TextRange
pub fn byte_range(&self, bytes: Range<usize>) -> TextRange
Byte range to grapheme range.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn insert_char(&mut self, c: char) -> bool
pub fn insert_char(&mut self, c: char) -> bool
Insert a character at the cursor position. Removes the selection and inserts the char.
This insert makes no special actions when encountering a new-line or tab. Use insert_newline and insert_tab for this.
Sourcepub fn insert_tab(&mut self) -> bool
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.
Sourcepub fn insert_backtab(&mut self) -> bool
pub fn insert_backtab(&mut self) -> bool
Unindents the selected text by tab-width. If there is no selection this does nothing.
This can be deactivated with auto_indent=false.
Sourcepub fn insert_str(&mut self, t: impl AsRef<str>) -> bool
pub fn insert_str(&mut self, t: impl AsRef<str>) -> bool
Insert text at the cursor position. Removes the selection and inserts the text.
Sourcepub fn insert_newline(&mut self) -> bool
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.
Sourcepub fn delete_range(&mut self, range: impl Into<TextRange>) -> bool
pub fn delete_range(&mut self, range: impl Into<TextRange>) -> bool
Deletes the given range.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn duplicate_text(&mut self) -> bool
pub fn duplicate_text(&mut self) -> bool
Duplicates the selection or the current line. Returns true if there was any real change.
Sourcepub fn delete_line(&mut self) -> bool
pub fn delete_line(&mut self) -> bool
Deletes the current line. Returns true if there was any real change.
Sourcepub fn delete_next_char(&mut self) -> bool
pub fn delete_next_char(&mut self) -> bool
Deletes the next char or the current selection. Returns true if there was any real change.
Sourcepub fn delete_prev_char(&mut self) -> bool
pub fn delete_prev_char(&mut self) -> bool
Deletes the previous char or the selection. Returns true if there was any real change.
Sourcepub fn next_word_start(&self, pos: impl Into<TextPosition>) -> TextPosition
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.
Sourcepub fn try_next_word_start(
&self,
pos: impl Into<TextPosition>,
) -> Result<TextPosition, TextError>
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.
Sourcepub fn next_word_end(&self, pos: impl Into<TextPosition>) -> TextPosition
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.
Sourcepub fn try_next_word_end(
&self,
pos: impl Into<TextPosition>,
) -> Result<TextPosition, TextError>
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.
Sourcepub fn prev_word_start(&self, pos: impl Into<TextPosition>) -> TextPosition
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!
Sourcepub fn try_prev_word_start(
&self,
pos: impl Into<TextPosition>,
) -> Result<TextPosition, TextError>
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!
Sourcepub fn prev_word_end(&self, pos: impl Into<TextPosition>) -> TextPosition
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!
Sourcepub fn try_prev_word_end(
&self,
pos: impl Into<TextPosition>,
) -> Result<TextPosition, TextError>
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!
Sourcepub fn is_word_boundary(&self, pos: impl Into<TextPosition>) -> bool
pub fn is_word_boundary(&self, pos: impl Into<TextPosition>) -> bool
Is the position at a word boundary?
Sourcepub fn try_is_word_boundary(
&self,
pos: impl Into<TextPosition>,
) -> Result<bool, TextError>
pub fn try_is_word_boundary( &self, pos: impl Into<TextPosition>, ) -> Result<bool, TextError>
Is the position at a word boundary?
Sourcepub fn word_start(&self, pos: impl Into<TextPosition>) -> TextPosition
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.
Sourcepub fn try_word_start(
&self,
pos: impl Into<TextPosition>,
) -> Result<TextPosition, TextError>
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.
Sourcepub fn word_end(&self, pos: impl Into<TextPosition>) -> TextPosition
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.
Sourcepub fn try_word_end(
&self,
pos: impl Into<TextPosition>,
) -> Result<TextPosition, TextError>
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.
Sourcepub fn delete_next_word(&mut self) -> bool
pub fn delete_next_word(&mut self) -> bool
Delete the next word. This alternates deleting the whitespace between words and the words themselves.
Sourcepub fn delete_prev_word(&mut self) -> bool
pub fn delete_prev_word(&mut self) -> bool
Deletes the previous word. This alternates deleting the whitespace between words and the words themselves.
Sourcepub fn move_left(&mut self, n: upos_type, extend_selection: bool) -> bool
pub fn move_left(&mut self, n: upos_type, extend_selection: bool) -> bool
Move the cursor left. Scrolls the cursor to visible. Returns true if there was any real change.
Sourcepub fn move_right(&mut self, n: upos_type, extend_selection: bool) -> bool
pub fn move_right(&mut self, n: upos_type, extend_selection: bool) -> bool
Move the cursor right. Scrolls the cursor to visible. Returns true if there was any real change.
Sourcepub fn move_up(&mut self, n: upos_type, extend_selection: bool) -> bool
pub fn move_up(&mut self, n: upos_type, extend_selection: bool) -> bool
Move the cursor up. Scrolls the cursor to visible. Returns true if there was any real change.
Sourcepub fn move_down(&mut self, n: upos_type, extend_selection: bool) -> bool
pub fn move_down(&mut self, n: upos_type, extend_selection: bool) -> bool
Move the cursor down. Scrolls the cursor to visible. Returns true if there was any real change.
Sourcepub fn move_to_line_start(&mut self, extend_selection: bool) -> bool
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.
Sourcepub fn move_to_line_end(&mut self, extend_selection: bool) -> bool
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.
Sourcepub fn move_to_start(&mut self, extend_selection: bool) -> bool
pub fn move_to_start(&mut self, extend_selection: bool) -> bool
Move the cursor to the document start.
Sourcepub fn move_to_end(&mut self, extend_selection: bool) -> bool
pub fn move_to_end(&mut self, extend_selection: bool) -> bool
Move the cursor to the document end.
Sourcepub fn move_to_screen_start(&mut self, extend_selection: bool) -> bool
pub fn move_to_screen_start(&mut self, extend_selection: bool) -> bool
Move the cursor to the start of the visible area.
Sourcepub fn move_to_screen_end(&mut self, extend_selection: bool) -> bool
pub fn move_to_screen_end(&mut self, extend_selection: bool) -> bool
Move the cursor to the end of the visible area.
Sourcepub fn move_to_next_word(&mut self, extend_selection: bool) -> bool
pub fn move_to_next_word(&mut self, extend_selection: bool) -> bool
Move the cursor to the next word.
Sourcepub fn move_to_prev_word(&mut self, extend_selection: bool) -> bool
pub fn move_to_prev_word(&mut self, extend_selection: bool) -> bool
Move the cursor to the previous word.
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn screen_to_row(&self, scy: i16) -> upos_type
pub fn screen_to_row(&self, scy: i16) -> upos_type
Converts from a widget relative screen coordinate to a line. It limits its result to a valid row.
Sourcepub fn screen_to_col(&self, row: upos_type, scx: i16) -> upos_type
pub fn screen_to_col(&self, row: upos_type, scx: i16) -> upos_type
Converts from a widget relative screen coordinate to a grapheme index. It limits its result to a valid column.
- row is a row-index into the value, not a screen-row. It can be calculated with screen_to_row().
- x is the relative screen position.
Sourcepub fn try_screen_to_col(
&self,
row: upos_type,
scx: i16,
) -> Result<upos_type, TextError>
pub fn try_screen_to_col( &self, row: upos_type, scx: i16, ) -> Result<upos_type, TextError>
Converts from a widget relative screen coordinate to a grapheme index. It limits its result to a valid column.
- row is a row-index into the value, not a screen-row. It can be calculated with screen_to_row().
- x is the relative screen position.
Sourcepub fn row_to_screen(&self, pos: impl Into<TextPosition>) -> Option<u16>
pub fn row_to_screen(&self, pos: impl Into<TextPosition>) -> Option<u16>
Converts the row of the position to a screen position relative to the widget area.
Sourcepub fn col_to_screen(&self, pos: impl Into<TextPosition>) -> Option<u16>
pub fn col_to_screen(&self, pos: impl Into<TextPosition>) -> Option<u16>
Converts a grapheme based position to a screen position relative to the widget area.
Sourcepub fn try_col_to_screen(
&self,
pos: impl Into<TextPosition>,
) -> Result<Option<u16>, TextError>
pub fn try_col_to_screen( &self, pos: impl Into<TextPosition>, ) -> Result<Option<u16>, TextError>
Converts a grapheme based position to a screen position relative to the widget area.
Sourcepub fn set_screen_cursor(
&mut self,
cursor: (i16, i16),
extend_selection: bool,
) -> bool
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.
Sourcepub fn set_screen_cursor_words(
&mut self,
cursor: (i16, i16),
extend_selection: bool,
) -> bool
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
impl TextAreaState
Sourcepub fn vertical_max_offset(&self) -> usize
pub fn vertical_max_offset(&self) -> usize
Maximum offset that is accessible with scrolling.
This is shorter than the length of the content by whatever fills the last page. This is the base for the scrollbar content_length.
Sourcepub fn vertical_offset(&self) -> usize
pub fn vertical_offset(&self) -> usize
Current vertical offset.
Sourcepub fn vertical_page(&self) -> usize
pub fn vertical_page(&self) -> usize
Vertical page-size at the current offset.
Sourcepub fn vertical_scroll(&self) -> usize
pub fn vertical_scroll(&self) -> usize
Suggested scroll per scroll-event.
Sourcepub fn horizontal_max_offset(&self) -> usize
pub fn horizontal_max_offset(&self) -> usize
Maximum offset that is accessible with scrolling.
This is currently set to usize::MAX.
Sourcepub fn horizontal_offset(&self) -> usize
pub fn horizontal_offset(&self) -> usize
Current horizontal offset.
Sourcepub fn horizontal_page(&self) -> usize
pub fn horizontal_page(&self) -> usize
Horizontal page-size at the current offset.
Sourcepub fn horizontal_scroll(&self) -> usize
pub fn horizontal_scroll(&self) -> usize
Suggested scroll per scroll-event.
Sourcepub fn set_vertical_offset(&mut self, row_offset: usize) -> bool
pub fn set_vertical_offset(&mut self, row_offset: usize) -> bool
Change the vertical offset.
Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.
The widget returns true if the offset changed at all.
Sourcepub fn set_horizontal_offset(&mut self, col_offset: usize) -> bool
pub fn set_horizontal_offset(&mut self, col_offset: usize) -> bool
Change the horizontal offset.
Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.
The widget returns true if the offset changed at all.
Sourcepub fn scroll_to_row(&mut self, pos: usize) -> bool
pub fn scroll_to_row(&mut self, pos: usize) -> bool
Scroll to position.
Sourcepub fn scroll_to_col(&mut self, pos: usize) -> bool
pub fn scroll_to_col(&mut self, pos: usize) -> bool
Scroll to position.
Sourcepub fn scroll_down(&mut self, delta: usize) -> bool
pub fn scroll_down(&mut self, delta: usize) -> bool
Scrolling
Sourcepub fn scroll_left(&mut self, delta: usize) -> bool
pub fn scroll_left(&mut self, delta: usize) -> bool
Scrolling
Sourcepub fn scroll_right(&mut self, delta: usize) -> bool
pub fn scroll_right(&mut self, delta: usize) -> bool
Scrolling
Source§impl TextAreaState
impl TextAreaState
Sourcepub fn scroll_cursor_to_visible(&mut self)
pub fn scroll_cursor_to_visible(&mut self)
Scroll that the cursor is visible. All move-fn do this automatically.
Trait Implementations§
Source§impl Clone for TextAreaState
impl Clone for TextAreaState
Source§impl Debug for TextAreaState
impl Debug for TextAreaState
Source§impl Default for TextAreaState
impl Default for TextAreaState
Source§impl HandleEvent<Event, MouseOnly, TextOutcome> for TextAreaState
impl HandleEvent<Event, MouseOnly, TextOutcome> for TextAreaState
Source§impl HandleEvent<Event, ReadOnly, TextOutcome> for TextAreaState
impl HandleEvent<Event, ReadOnly, TextOutcome> for TextAreaState
Source§impl HandleEvent<Event, Regular, TextOutcome> for TextAreaState
impl HandleEvent<Event, Regular, TextOutcome> for TextAreaState
Source§impl HasFocus for TextAreaState
impl HasFocus for TextAreaState
Source§fn build(&self, builder: &mut FocusBuilder)
fn build(&self, builder: &mut FocusBuilder)
Source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
Source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Source§impl HasScreenCursor for TextAreaState
impl HasScreenCursor for TextAreaState
Source§impl RelocatableState for TextAreaState
impl RelocatableState for TextAreaState
Auto Trait Implementations§
impl !Freeze for TextAreaState
impl !RefUnwindSafe for TextAreaState
impl !Send for TextAreaState
impl !Sync for TextAreaState
impl Unpin for TextAreaState
impl !UnwindSafe for TextAreaState
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> 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