pub struct Editor<'a, W: Write> {
pub no_eol: bool,
/* private fields */
}
Expand description
The core line editor. Displays and provides editing for history and the new buffer.
Fields§
§no_eol: bool
Implementations§
source§impl<'a, W: Write> Editor<'a, W>
impl<'a, W: Write> Editor<'a, W>
pub fn new( out: W, prompt: Prompt, f: Option<ColorClosure>, context: &'a mut Context ) -> Result<Self>
pub fn new_with_init_buffer<B: Into<Buffer>>( out: W, prompt: Prompt, f: Option<ColorClosure>, context: &'a mut Context, buffer: B ) -> Result<Self>
sourcepub fn current_history_location(&self) -> Option<usize>
pub fn current_history_location(&self) -> Option<usize>
None if we’re on the new buffer, else the index of history
pub fn get_words_and_cursor_position( &self ) -> (Vec<(usize, usize)>, CursorPosition)
pub fn set_prompt(&mut self, prompt: Prompt)
pub fn context(&mut self) -> &mut Context
pub fn cursor(&self) -> usize
pub fn handle_newline(&mut self) -> Result<bool>
sourcepub fn search(&mut self, forward: bool) -> Result<()>
pub fn search(&mut self, forward: bool) -> Result<()>
Begin or continue a search through history. If forward is true then start at top (or current_history_loc if set). If started with forward true then incremental search goes forward (top to bottom) other wise reverse (bottom to top). It is valid to continue a search with forward changed (i.e. reverse search direction for one result).
pub fn flush(&mut self) -> Result<()>
sourcepub fn undo(&mut self) -> Result<bool>
pub 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.
pub fn redo(&mut self) -> Result<bool>
pub fn revert(&mut self) -> Result<bool>
pub fn skip_completions_hint(&mut self)
pub fn complete<T: Completer>(&mut self, handler: &mut T) -> Result<()>
sourcepub fn delete_word_before_cursor(
&mut self,
ignore_space_before_cursor: bool
) -> Result<()>
pub 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.
sourcepub fn clear(&mut self) -> Result<()>
pub fn clear(&mut self) -> Result<()>
Clears the screen then prints the prompt and current buffer.
sourcepub fn move_down(&mut self) -> Result<()>
pub fn move_down(&mut self) -> Result<()>
Move down (forwards) in history, or to the new buffer if we reach the end of history.
sourcepub fn move_to_start_of_history(&mut self) -> Result<()>
pub fn move_to_start_of_history(&mut self) -> Result<()>
Moves to the start of history (ie. the earliest history entry).
sourcepub fn move_to_end_of_history(&mut self) -> Result<()>
pub fn move_to_end_of_history(&mut self) -> Result<()>
Moves to the end of history (ie. the new buffer).
sourcepub fn insert_str_after_cursor(&mut self, s: &str) -> Result<()>
pub 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.
sourcepub fn insert_after_cursor(&mut self, c: char) -> Result<()>
pub fn insert_after_cursor(&mut self, c: char) -> Result<()>
Inserts a character directly after the cursor, moving the cursor to the right.
sourcepub fn insert_chars_after_cursor(&mut self, cs: &[char]) -> Result<()>
pub fn insert_chars_after_cursor(&mut self, cs: &[char]) -> Result<()>
Inserts characters directly after the cursor, moving the cursor to the right.
sourcepub fn delete_before_cursor(&mut self) -> Result<()>
pub 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.
sourcepub fn delete_after_cursor(&mut self) -> Result<()>
pub 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.
sourcepub fn delete_all_before_cursor(&mut self) -> Result<()>
pub fn delete_all_before_cursor(&mut self) -> Result<()>
Deletes every character preceding the cursor until the beginning of the line.
sourcepub fn delete_all_after_cursor(&mut self) -> Result<()>
pub fn delete_all_after_cursor(&mut self) -> Result<()>
Deletes every character after the cursor until the end of the line.
sourcepub fn delete_until(&mut self, position: usize) -> Result<()>
pub fn delete_until(&mut self, position: usize) -> Result<()>
Deletes every character from the cursor until the given position.
sourcepub fn delete_until_inclusive(&mut self, position: usize) -> Result<()>
pub fn delete_until_inclusive(&mut self, position: usize) -> Result<()>
Deletes every character from the cursor until the given position, inclusive.
sourcepub fn move_cursor_left(&mut self, count: usize) -> Result<()>
pub 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.
sourcepub fn move_cursor_right(&mut self, count: usize) -> Result<()>
pub 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.
sourcepub fn move_cursor_to(&mut self, pos: usize) -> Result<()>
pub 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.
sourcepub fn move_cursor_to_start_of_line(&mut self) -> Result<()>
pub fn move_cursor_to_start_of_line(&mut self) -> Result<()>
Moves the cursor to the start of the line.
sourcepub fn move_cursor_to_end_of_line(&mut self) -> Result<()>
pub fn move_cursor_to_end_of_line(&mut self) -> Result<()>
Moves the cursor to the end of the line.
pub fn cursor_is_at_end_of_line(&self) -> bool
sourcepub fn current_buffer(&self) -> &Buffer
pub 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.
sourcepub fn current_buffer_mut(&mut self) -> &mut Buffer
pub fn current_buffer_mut(&mut self) -> &mut Buffer
Returns a mutable reference to the current buffer being edited. This may be the new buffer or a buffer from history.
sourcepub fn accept_autosuggestion(&mut self) -> Result<()>
pub fn accept_autosuggestion(&mut self) -> Result<()>
Accept autosuggestion and copy its content into current buffer
pub fn is_currently_showing_autosuggestion(&self) -> bool
sourcepub fn display(&mut self) -> Result<()>
pub fn display(&mut self) -> Result<()>
Deletes the displayed prompt and buffer, replacing them with the current prompt and buffer
sourcepub fn set_vi_mode(&mut self, mode: ViPromptMode)
pub fn set_vi_mode(&mut self, mode: ViPromptMode)
Modifies the prompt to reflect the Vi mode.
This operation will be ignored if a static prompt is used, as mode changes will have no side effect.