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

Get the internal Buffer

Get the internal Buffer, mutably

Get the current cursor position

Get the current selection position

Shape lines until scroll, after adjusting scroll if the cursor moved

Copy selection

Delete selection, adjusting cursor and returning true if there was a selection

Perform an Action on the editor

Draw the editor

Implementors