Trait freya::hooks::TextEditor

source ·
pub trait TextEditor {
    type LinesIterator<'a>: Iterator<Item = Line<'a>>
       where Self: 'a;

Show 40 methods // Required methods fn set(&mut self, text: &str); fn lines(&self) -> Self::LinesIterator<'_>; fn insert_char(&mut self, char: char, char_idx: usize); fn insert(&mut self, text: &str, char_idx: usize); fn remove(&mut self, range: Range<usize>); fn char_to_line(&self, char_idx: usize) -> usize; fn line_to_char(&self, line_idx: usize) -> usize; fn utf16_cu_to_char(&self, utf16_cu_idx: usize) -> usize; fn char_to_utf16_cu(&self, idx: usize) -> usize; fn line(&self, line_idx: usize) -> Option<Line<'_>>; fn len_lines(&self) -> usize; fn len_chars(&self) -> usize; fn cursor(&self) -> &TextCursor; fn cursor_mut(&mut self) -> &mut TextCursor; fn has_any_selection(&self) -> bool; fn get_selection(&self) -> Option<(usize, usize)>; fn get_visible_selection(&self, editor_id: usize) -> Option<(usize, usize)>; fn clear_selection(&mut self); fn set_selection(&mut self, selected: (usize, usize)); fn measure_new_selection( &self, from: usize, to: usize, editor_id: usize ) -> (usize, usize); fn measure_new_cursor(&self, to: usize, editor_id: usize) -> TextCursor; fn expand_selection_to_cursor(&mut self); fn get_clipboard(&mut self) -> &mut UseClipboard; fn get_selected_text(&self) -> Option<String>; fn undo(&mut self) -> Option<usize>; fn redo(&mut self) -> Option<usize>; fn get_selection_range(&self) -> Option<(usize, usize)>; fn get_identation(&self) -> u8; // Provided methods fn cursor_row(&self) -> usize { ... } fn cursor_col(&self) -> usize { ... } fn cursor_row_and_col(&self) -> (usize, usize) { ... } fn visible_cursor_col(&self) -> usize { ... } fn cursor_down(&mut self) -> bool { ... } fn cursor_up(&mut self) -> bool { ... } fn cursor_right(&mut self) -> bool { ... } fn cursor_left(&mut self) -> bool { ... } fn cursor_pos(&self) -> usize { ... } fn visible_cursor_pos(&self) -> usize { ... } fn set_cursor_pos(&mut self, pos: usize) { ... } fn process_key( &mut self, key: &Key, code: &Code, modifiers: &Modifiers ) -> TextEvent { ... }
}
Expand description

Common trait for editable texts

Required Associated Types§

source

type LinesIterator<'a>: Iterator<Item = Line<'a>> where Self: 'a

Required Methods§

source

fn set(&mut self, text: &str)

source

fn lines(&self) -> Self::LinesIterator<'_>

Iterator over all the lines in the text.

source

fn insert_char(&mut self, char: char, char_idx: usize)

Insert a character in the text in the given position.

source

fn insert(&mut self, text: &str, char_idx: usize)

Insert a string in the text in the given position.

source

fn remove(&mut self, range: Range<usize>)

Remove a part of the text.

source

fn char_to_line(&self, char_idx: usize) -> usize

Get line from the given char

source

fn line_to_char(&self, line_idx: usize) -> usize

Get the first char from the given line

source

fn utf16_cu_to_char(&self, utf16_cu_idx: usize) -> usize

source

fn char_to_utf16_cu(&self, idx: usize) -> usize

source

fn line(&self, line_idx: usize) -> Option<Line<'_>>

Get a line from the text

source

fn len_lines(&self) -> usize

Total of lines

source

fn len_chars(&self) -> usize

Total of chars

source

fn cursor(&self) -> &TextCursor

Get a readable cursor

source

fn cursor_mut(&mut self) -> &mut TextCursor

Get a mutable cursor

source

fn has_any_selection(&self) -> bool

source

fn get_selection(&self) -> Option<(usize, usize)>

source

fn get_visible_selection(&self, editor_id: usize) -> Option<(usize, usize)>

source

fn clear_selection(&mut self)

source

fn set_selection(&mut self, selected: (usize, usize))

source

fn measure_new_selection( &self, from: usize, to: usize, editor_id: usize ) -> (usize, usize)

source

fn measure_new_cursor(&self, to: usize, editor_id: usize) -> TextCursor

source

fn expand_selection_to_cursor(&mut self)

source

fn get_clipboard(&mut self) -> &mut UseClipboard

source

fn get_selected_text(&self) -> Option<String>

source

fn undo(&mut self) -> Option<usize>

source

fn redo(&mut self) -> Option<usize>

source

fn get_selection_range(&self) -> Option<(usize, usize)>

source

fn get_identation(&self) -> u8

Provided Methods§

source

fn cursor_row(&self) -> usize

Get the cursor row

source

fn cursor_col(&self) -> usize

Get the cursor column

source

fn cursor_row_and_col(&self) -> (usize, usize)

Get the cursor row and col

source

fn visible_cursor_col(&self) -> usize

Get the visible cursor position

source

fn cursor_down(&mut self) -> bool

Move the cursor 1 line down

source

fn cursor_up(&mut self) -> bool

Move the cursor 1 line up

source

fn cursor_right(&mut self) -> bool

Move the cursor 1 char to the right

source

fn cursor_left(&mut self) -> bool

Move the cursor 1 char to the left

source

fn cursor_pos(&self) -> usize

Get the cursor position

source

fn visible_cursor_pos(&self) -> usize

Get the cursor position

source

fn set_cursor_pos(&mut self, pos: usize)

Set the cursor position

source

fn process_key( &mut self, key: &Key, code: &Code, modifiers: &Modifiers ) -> TextEvent

Object Safety§

This trait is not object safe.

Implementors§