Skip to main content

Editor

Trait Editor 

Source
pub trait Editor {
    // Required methods
    fn content(&self) -> &str;
    fn cursor(&self) -> usize;
    fn set_cursor(&mut self, pos: usize);
    fn move_left(&mut self);
    fn move_right(&mut self);
    fn delete_char_forward(&mut self);
    fn insert_text(&mut self, text: &str);
    fn replace(&mut self, content: String, cursor: usize);

    // Provided method
    fn replace_range(&mut self, start: usize, end: usize, text: &str) { ... }
}
Expand description

Minimal text-editor surface required by the Vim engine.

Required Methods§

Source

fn content(&self) -> &str

Source

fn cursor(&self) -> usize

Source

fn set_cursor(&mut self, pos: usize)

Source

fn move_left(&mut self)

Source

fn move_right(&mut self)

Source

fn delete_char_forward(&mut self)

Source

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

Source

fn replace(&mut self, content: String, cursor: usize)

Provided Methods§

Source

fn replace_range(&mut self, start: usize, end: usize, text: &str)

Replace the byte range start..end with text in-place. Default implementation delegates to content().to_string() + replace().

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§