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§
Sourcefn line_count(&self) -> usize
fn line_count(&self) -> usize
Get the total number of lines in the buffer
Sourcefn insert_at(&mut self, row: usize, col: usize, text: &str)
fn insert_at(&mut self, row: usize, col: usize, text: &str)
Insert text at a specific position (row, col)
Sourcefn delete_at(&mut self, row: usize, col: usize)
fn delete_at(&mut self, row: usize, col: usize)
Delete a character at a specific position (row, col)
Sourcefn backspace_at(&mut self, row: usize, col: usize)
fn backspace_at(&mut self, row: usize, col: usize)
Delete backwards from a specific position (row, col)