Trait cosmic_text::Edit
source · pub trait Edit<'a> {
fn buffer(&self) -> &Buffer<'a>;
fn buffer_mut(&mut self) -> &mut Buffer<'a>;
fn cursor(&self) -> Cursor;
fn select_opt(&self) -> Option<Cursor>;
fn shape_as_needed(&mut self);
fn copy_selection(&mut self) -> Option<String>;
fn delete_selection(&mut self) -> bool;
fn action(&mut self, action: Action);
fn draw<F>(&self, cache: &mut SwashCache<'_>, color: Color, f: F)
where
F: FnMut(i32, i32, u32, u32, Color);
}
Expand description
A trait to allow easy replacements of Editor
, like SyntaxEditor
Required Methods
sourcefn buffer_mut(&mut self) -> &mut Buffer<'a>
fn buffer_mut(&mut self) -> &mut Buffer<'a>
Get the internal Buffer
, mutably
sourcefn select_opt(&self) -> Option<Cursor>
fn select_opt(&self) -> Option<Cursor>
Get the current selection position
sourcefn shape_as_needed(&mut self)
fn shape_as_needed(&mut self)
Shape lines until scroll, after adjusting scroll if the cursor moved
sourcefn copy_selection(&mut self) -> Option<String>
fn copy_selection(&mut 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