pub trait Edit<'buffer> {
Show 27 methods
// Required methods
fn buffer_ref(&self) -> &BufferRef<'buffer>;
fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>;
fn cursor(&self) -> Cursor;
fn set_cursor(&mut self, cursor: Cursor);
fn selection(&self) -> Selection;
fn set_selection(&mut self, selection: Selection);
fn auto_indent(&self) -> bool;
fn set_auto_indent(&mut self, auto_indent: bool);
fn tab_width(&self) -> u16;
fn set_tab_width(&mut self, font_system: &mut FontSystem, tab_width: u16);
fn shape_as_needed(&mut self, font_system: &mut FontSystem, prune: bool);
fn delete_range(&mut self, start: Cursor, end: Cursor);
fn insert_at(
&mut self,
cursor: Cursor,
data: &str,
attrs_list: Option<AttrsList>,
) -> Cursor;
fn copy_selection(&self) -> Option<String>;
fn delete_selection(&mut self) -> bool;
fn apply_change(&mut self, change: &Change) -> bool;
fn start_change(&mut self);
fn finish_change(&mut self) -> Option<Change>;
fn action(&mut self, font_system: &mut FontSystem, action: Action);
fn cursor_position(&self) -> Option<(i32, i32)>;
// Provided methods
fn borrow_with<'font_system>(
&'font_system mut self,
font_system: &'font_system mut FontSystem,
) -> BorrowedWithFontSystem<'font_system, Self>
where Self: Sized { ... }
fn with_buffer<F, T>(&self, f: F) -> T
where F: FnOnce(&Buffer) -> T { ... }
fn with_buffer_mut<F, T>(&mut self, f: F) -> T
where F: FnOnce(&mut Buffer) -> T { ... }
fn redraw(&self) -> bool { ... }
fn set_redraw(&mut self, redraw: bool) { ... }
fn selection_bounds(&self) -> Option<(Cursor, Cursor)> { ... }
fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>) { ... }
}
Expand description
A trait to allow easy replacements of Editor
, like SyntaxEditor
Required Methods§
sourcefn buffer_ref(&self) -> &BufferRef<'buffer>
fn buffer_ref(&self) -> &BufferRef<'buffer>
Get the internal BufferRef
sourcefn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
Get the internal BufferRef
sourcefn set_cursor(&mut self, cursor: Cursor)
fn set_cursor(&mut self, cursor: Cursor)
Set the current cursor
sourcefn set_selection(&mut self, selection: Selection)
fn set_selection(&mut self, selection: Selection)
Set the current selection position
sourcefn auto_indent(&self) -> bool
fn auto_indent(&self) -> bool
Get the current automatic indentation setting
sourcefn set_auto_indent(&mut self, auto_indent: bool)
fn set_auto_indent(&mut self, auto_indent: bool)
Enable or disable automatic indentation
sourcefn set_tab_width(&mut self, font_system: &mut FontSystem, tab_width: u16)
fn set_tab_width(&mut self, font_system: &mut FontSystem, tab_width: u16)
Set the current tab width. A tab_width
of 0 is not allowed, and will be ignored
sourcefn shape_as_needed(&mut self, font_system: &mut FontSystem, prune: bool)
fn shape_as_needed(&mut self, font_system: &mut FontSystem, prune: bool)
Shape lines until scroll, after adjusting scroll if the cursor moved
sourcefn delete_range(&mut self, start: Cursor, end: Cursor)
fn delete_range(&mut self, start: Cursor, end: Cursor)
Delete text starting at start Cursor and ending at end Cursor
sourcefn insert_at(
&mut self,
cursor: Cursor,
data: &str,
attrs_list: Option<AttrsList>,
) -> Cursor
fn insert_at( &mut self, cursor: Cursor, data: &str, attrs_list: Option<AttrsList>, ) -> Cursor
Insert text at specified cursor with specified attrs_list
sourcefn copy_selection(&self) -> Option<String>
fn copy_selection(&self) -> Option<String>
Copy selection
sourcefn delete_selection(&mut self) -> bool
fn delete_selection(&mut self) -> bool
Delete selection, adjusting cursor and returning true if there was a selection
sourcefn apply_change(&mut self, change: &Change) -> bool
fn apply_change(&mut self, change: &Change) -> bool
Apply a change
sourcefn start_change(&mut self)
fn start_change(&mut self)
Start collecting change
sourcefn finish_change(&mut self) -> Option<Change>
fn finish_change(&mut self) -> Option<Change>
Get completed change
sourcefn action(&mut self, font_system: &mut FontSystem, action: Action)
fn action(&mut self, font_system: &mut FontSystem, action: Action)
Perform an Action on the editor
sourcefn cursor_position(&self) -> Option<(i32, i32)>
fn cursor_position(&self) -> Option<(i32, i32)>
Get X and Y position of the top left corner of the cursor
Provided Methods§
sourcefn borrow_with<'font_system>(
&'font_system mut self,
font_system: &'font_system mut FontSystem,
) -> BorrowedWithFontSystem<'font_system, Self>where
Self: Sized,
fn borrow_with<'font_system>(
&'font_system mut self,
font_system: &'font_system mut FontSystem,
) -> BorrowedWithFontSystem<'font_system, Self>where
Self: Sized,
Mutably borrows self
together with an FontSystem
for more convenient methods
sourcefn with_buffer<F, T>(&self, f: F) -> T
fn with_buffer<F, T>(&self, f: F) -> T
Get the internal Buffer
sourcefn with_buffer_mut<F, T>(&mut self, f: F) -> T
fn with_buffer_mut<F, T>(&mut self, f: F) -> T
Get the internal Buffer
, mutably
sourcefn set_redraw(&mut self, redraw: bool)
fn set_redraw(&mut self, redraw: bool)
Set the Buffer
redraw flag
sourcefn selection_bounds(&self) -> Option<(Cursor, Cursor)>
fn selection_bounds(&self) -> Option<(Cursor, Cursor)>
Get the bounds of the current selection
sourcefn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>)
fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>)
Insert a string at the current cursor or replacing the current selection with the given attributes, or with the previous character’s attributes if None is given.