Struct liner::Editor
[−]
[src]
pub struct Editor<'a, W: Write> { pub no_eol: bool, // some fields omitted }
The core line editor. Displays and provides editing for history and the new buffer.
Fields
no_eol: bool
Methods
impl<'a, W: Write> Editor<'a, W>
[src]
fn new<P: Into<String>>(
out: W,
prompt: P,
context: &'a mut Context
) -> Result<Self>
[src]
out: W,
prompt: P,
context: &'a mut Context
) -> Result<Self>
fn new_with_init_buffer<P: Into<String>, B: Into<Buffer>>(
out: W,
prompt: P,
context: &'a mut Context,
buffer: B
) -> Result<Self>
[src]
out: W,
prompt: P,
context: &'a mut Context,
buffer: B
) -> Result<Self>
fn current_history_location(&self) -> Option<usize>
[src]
None if we're on the new buffer, else the index of history
fn get_words_and_cursor_position(&self) -> (Vec<(usize, usize)>, CursorPosition)
[src]
fn set_prompt(&mut self, prompt: String)
[src]
fn context(&mut self) -> &mut Context
[src]
fn cursor(&self) -> usize
[src]
fn handle_newline(&mut self) -> Result<bool>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn undo(&mut self) -> Result<bool>
[src]
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>
[src]
fn revert(&mut self) -> Result<bool>
[src]
fn skip_completions_hint(&mut self)
[src]
fn complete(&mut self, handler: &mut EventHandler<W>) -> Result<()>
[src]
fn delete_word_before_cursor(
&mut self,
ignore_space_before_cursor: bool
) -> Result<()>
[src]
&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<()>
[src]
Clears the screen then prints the prompt and current buffer.
fn move_up(&mut self) -> Result<()>
[src]
Move up (backwards) in history.
fn move_down(&mut self) -> Result<()>
[src]
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<()>
[src]
Moves to the start of history (ie. the earliest history entry).
fn move_to_end_of_history(&mut self) -> Result<()>
[src]
Moves to the end of history (ie. the new buffer).
fn insert_str_after_cursor(&mut self, s: &str) -> Result<()>
[src]
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<()>
[src]
Inserts a character directly after the cursor, moving the cursor to the right.
fn insert_chars_after_cursor(&mut self, cs: &[char]) -> Result<()>
[src]
Inserts characters directly after the cursor, moving the cursor to the right.
fn delete_before_cursor(&mut self) -> Result<()>
[src]
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<()>
[src]
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<()>
[src]
Deletes every character preceding the cursor until the beginning of the line.
fn delete_all_after_cursor(&mut self) -> Result<()>
[src]
Deletes every character after the cursor until the end of the line.
fn delete_until(&mut self, position: usize) -> Result<()>
[src]
Deletes every character from the cursor until the given position.
fn delete_until_inclusive(&mut self, position: usize) -> Result<()>
[src]
Deletes every character from the cursor until the given position, inclusive.
fn move_cursor_left(&mut self, count: usize) -> Result<()>
[src]
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<()>
[src]
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<()>
[src]
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<()>
[src]
Moves the cursor to the start of the line.
fn move_cursor_to_end_of_line(&mut self) -> Result<()>
[src]
Moves the cursor to the end of the line.
fn cursor_is_at_end_of_line(&self) -> bool
[src]
fn current_buffer(&self) -> &Buffer
[src]
Returns a reference to the current buffer being edited. This may be the new buffer or a buffer from history.
fn current_buffer_mut(&mut self) -> &mut Buffer
[src]
Returns a mutable reference to the current buffer being edited. This may be the new buffer or a buffer from history.
fn accept_autosuggestion(&mut self) -> Result<()>
[src]
Accept autosuggestion and copy its content into current buffer
fn current_autosuggestion(&self) -> Option<&Buffer>
[src]
fn is_currently_showing_autosuggestion(&self) -> bool
[src]
fn display(&mut self) -> Result<()>
[src]
Deletes the displayed prompt and buffer, replacing them with the current prompt and buffer