pub trait LineEditor {
// Required methods
fn handle_key(&mut self, key: Key, text: &str) -> EditResult;
fn cursor(&self) -> usize;
fn status(&self) -> &str;
fn selection(&self) -> Option<Range<usize>>;
fn reset(&mut self);
fn set_cursor(&mut self, pos: usize, text: &str);
}Expand description
The contract between a line editor and its host application.
Implementations handle key interpretation and cursor management, while the host owns the text buffer and handles rendering.
Required Methods§
Sourcefn handle_key(&mut self, key: Key, text: &str) -> EditResult
fn handle_key(&mut self, key: Key, text: &str) -> EditResult
Process a key event, returning edits to apply and any action requested.
The text parameter is the current content - the editor uses it to
calculate motions but never modifies it directly.
Sourcefn selection(&self) -> Option<Range<usize>>
fn selection(&self) -> Option<Range<usize>>
Selection range for highlighting, if in visual mode.
Sourcefn set_cursor(&mut self, pos: usize, text: &str)
fn set_cursor(&mut self, pos: usize, text: &str)
Set cursor position, clamped to valid bounds within text.