Struct liner::Editor
[−]
[src]
pub struct Editor<'a, W: Write> { // some fields omitted }
Methods
impl<'a, W: Write> Editor<'a, W>[src]
fn new(out: W, prompt: String, context: &'a mut Context) -> Result<Self>
fn get_words_and_cursor_position(&self) -> (Vec<(usize, usize)>, CursorPosition)
fn set_prompt(&mut self, prompt: String)
fn context(&mut self) -> &mut Context
fn cursor(&self) -> usize
fn handle_key(&mut self, key: Key, handler: &mut EventHandler<W>) -> Result<bool>
fn undo(&mut self) -> Result<bool>
Attempts to undo an action on the current buffer.
Returns Ok(true) if an action was undone.
Returns Ok(false) if there was no action to undo.
fn redo(&mut self) -> Result<bool>
fn revert(&mut self) -> Result<bool>
fn delete_word_before_cursor(&mut self, ignore_space_before_cursor: bool) -> Result<()>
Deletes the word preceding the cursor.
If ignore_space_before_cursor is true and there is space directly before the cursor,
this method ignores that space until it finds a word.
If ignore_space_before_cursor is false and there is space directly before the cursor,
nothing is deleted.
fn clear(&mut self) -> Result<()>
Clears the screen then prints the prompt and current buffer.
fn move_up(&mut self) -> Result<()>
Move up (backwards) in history.
fn move_down(&mut self) -> Result<()>
Move down (forwards) in history, or to the new buffer if we reach the end of history.
fn move_to_start_of_history(&mut self) -> Result<()>
Moves to the start of history (ie. the earliest history entry).
fn move_to_end_of_history(&mut self) -> Result<()>
Moves to the end of history (ie. the new buffer).
fn insert_str_after_cursor(&mut self, s: &str) -> Result<()>
Inserts a string directly after the cursor, moving the cursor to the right.
Note: it is more efficient to call insert_chars_after_cursor() directly.
fn insert_after_cursor(&mut self, c: char) -> Result<()>
Inserts a character directly after the cursor, moving the cursor to the right.
fn insert_chars_after_cursor(&mut self, cs: &[char]) -> Result<()>
Inserts characters directly after the cursor, moving the cursor to the right.
fn delete_before_cursor(&mut self) -> Result<()>
Deletes the character directly before the cursor, moving the cursor to the left. If the cursor is at the start of the line, nothing happens.
fn delete_after_cursor(&mut self) -> Result<()>
Deletes the character directly after the cursor. The cursor does not move. If the cursor is at the end of the line, nothing happens.
fn delete_all_before_cursor(&mut self) -> Result<()>
Deletes every character preceding the cursor until the beginning of the line.
fn delete_all_after_cursor(&mut self) -> Result<()>
Deletes every character after the cursor until the end of the line.
fn move_cursor_left(&mut self, count: usize) -> Result<()>
Moves the cursor to the left by count characters.
The cursor will not go past the start of the buffer.
fn move_cursor_right(&mut self, count: usize) -> Result<()>
Moves the cursor to the right by count characters.
The cursor will not go past the end of the buffer.
fn move_cursor_to(&mut self, pos: usize) -> Result<()>
Moves the cursor to pos. If pos is past the end of the buffer, it will be clamped.
fn move_cursor_to_start_of_line(&mut self) -> Result<()>
Moves the cursor to the start of the line.
fn move_cursor_to_end_of_line(&mut self) -> Result<()>
Moves the cursor to the end of the line.
fn current_buffer(&self) -> &Buffer
Returns a reference to the current buffer being edited. This may be the new buffer or a buffer from history.
fn print_current_buffer(&mut self, move_cursor_to_end_of_line: bool) -> Result<()>
Deletes the displayed prompt and buffer, replacing them with the current prompt and buffer