TextEditor

Trait TextEditor 

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

Show 37 methods // Required methods fn set(&mut self, text: &str); fn lines(&self) -> Self::LinesIterator<'_>; fn insert_char(&mut self, char: char, char_idx: usize) -> usize; fn insert(&mut self, text: &str, char_idx: usize) -> usize; fn remove(&mut self, range: Range<usize>) -> 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 len_utf16_cu(&self) -> usize; fn selection(&self) -> &TextSelection; fn selection_mut(&mut self) -> &mut TextSelection; fn has_any_selection(&self) -> bool; fn get_selection(&self) -> Option<(usize, usize)>; fn get_visible_selection( &self, editor_line: EditorLine, ) -> Option<(usize, usize)>; fn clear_selection(&mut self); fn set_selection(&mut self, selected: (usize, usize)); fn get_selected_text(&self) -> Option<String>; fn undo(&mut self) -> Option<TextSelection>; fn redo(&mut self) -> Option<TextSelection>; fn editor_history(&mut self) -> &mut EditorHistory; fn get_selection_range(&self) -> Option<(usize, usize)>; fn get_indentation(&self) -> u8; // Provided methods fn cursor_row(&self) -> usize { ... } fn 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 move_cursor_to(&mut self, pos: usize) { ... } fn measure_selection( &self, to: usize, line_index: EditorLine, ) -> TextSelection { ... } fn process_key( &mut self, key: &Key, modifiers: &Modifiers, allow_tabs: bool, allow_changes: bool, allow_clipboard: bool, ) -> TextEvent { ... } fn find_word_boundaries(&self, pos: usize) -> (usize, usize) { ... }
}
Expand description

Common trait for editable texts

Required Associated Types§

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

Required Methods§

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

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

Iterator over all the lines in the text.

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

Insert a character in the text in the given position.

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

Insert a string in the text in the given position.

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

Remove a part of the text.

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

Get line from the given char

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

Get the first char from the given line

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<'_>>

Get a line from the text

fn len_lines(&self) -> usize

Total of lines

fn len_chars(&self) -> usize

Total of chars

fn len_utf16_cu(&self) -> usize

Total of utf16 code units

fn selection(&self) -> &TextSelection

Get a readable text selection

fn selection_mut(&mut self) -> &mut TextSelection

Get a mutable reference to text selection

fn has_any_selection(&self) -> bool

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

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

fn clear_selection(&mut self)

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

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

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

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

fn editor_history(&mut self) -> &mut EditorHistory

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

fn get_indentation(&self) -> u8

Provided Methods§

fn cursor_row(&self) -> usize

Get the cursor row

fn cursor_col(&self) -> usize

Get the cursor column

fn cursor_down(&mut self) -> bool

Move the cursor 1 line down

fn cursor_up(&mut self) -> bool

Move the cursor 1 line up

fn cursor_right(&mut self) -> bool

Move the cursor 1 char to the right

fn cursor_left(&mut self) -> bool

Move the cursor 1 char to the left

fn cursor_pos(&self) -> usize

Get the cursor position

fn move_cursor_to(&mut self, pos: usize)

Move the cursor position

fn measure_selection(&self, to: usize, line_index: EditorLine) -> TextSelection

fn process_key( &mut self, key: &Key, modifiers: &Modifiers, allow_tabs: bool, allow_changes: bool, allow_clipboard: bool, ) -> TextEvent

fn find_word_boundaries(&self, pos: usize) -> (usize, usize)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§