TextBuffer

Trait TextBuffer 

Source
pub trait TextBuffer {
    // Required methods
    fn line_count(&self) -> usize;
    fn get_line(&self, line_idx: usize) -> Option<String>;
    fn all_lines(&self) -> Vec<String>;
    fn insert_at(&mut self, row: usize, col: usize, text: &str);
    fn delete_at(&mut self, row: usize, col: usize);
    fn backspace_at(&mut self, row: usize, col: usize);

    // Provided method
    fn line_len(&self, line_idx: usize) -> usize { ... }
}
Expand description

A minimal text buffer trait that supports the features we have so far

Required Methods§

Source

fn line_count(&self) -> usize

Get the total number of lines in the buffer

Source

fn get_line(&self, line_idx: usize) -> Option<String>

Get a specific line by index (0-based)

Source

fn all_lines(&self) -> Vec<String>

Get all lines (for now, while we’re simple)

Source

fn insert_at(&mut self, row: usize, col: usize, text: &str)

Insert text at a specific position (row, col)

Source

fn delete_at(&mut self, row: usize, col: usize)

Delete a character at a specific position (row, col)

Source

fn backspace_at(&mut self, row: usize, col: usize)

Delete backwards from a specific position (row, col)

Provided Methods§

Source

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

Get the length of a specific line in characters

Implementors§