Struct Editor
struct Editor<H: Helper, I: History> { ... }
Line editor
Implementations
impl<H: Helper> Editor<H, crate::history::DefaultHistory>
fn new() -> Result<Self>Create an editor with the default configuration
fn with_config(config: Config) -> Result<Self>Create an editor with a specific configuration.
impl<H: Helper, I: History> Editor<H, I>
fn with_history(config: Config, history: I) -> Result<Self>Create an editor with a custom history impl.
fn readline(self: &mut Self, prompt: &str) -> Result<String>This method will read a line from STDIN and will display a
prompt.promptshould not be styled (in case the terminal doesn't support ANSI) directly: useHighlighter::highlight_promptinstead.It uses terminal-style interaction if
stdinis connected to a terminal. Otherwise (e.g., ifstdinis a pipe or the terminal is not supported), it uses file-style interaction.fn readline_with_initial(self: &mut Self, prompt: &str, initial: (&str, &str)) -> Result<String>This function behaves in the exact same manner as
Editor::readline, except that it pre-populates the input area.The text that resides in the input area is given as a 2-tuple. The string on the left of the tuple is what will appear to the left of the cursor and the string on the right is what will appear to the right of the cursor.
fn load_history<P: AsRef<Path> + ?Sized>(self: &mut Self, path: &P) -> Result<()>Load the history from the specified file.
fn save_history<P: AsRef<Path> + ?Sized>(self: &mut Self, path: &P) -> Result<()>Save the history in the specified file.
fn append_history<P: AsRef<Path> + ?Sized>(self: &mut Self, path: &P) -> Result<()>Append new entries in the specified file.
fn add_history_entry<S: AsRef<str> + Into<String>>(self: &mut Self, line: S) -> Result<bool>Add a new entry in the history.
fn clear_history(self: &mut Self) -> Result<()>Clear history.
fn history_mut(self: &mut Self) -> &mut IReturn a mutable reference to the history object.
fn history(self: &Self) -> &IReturn an immutable reference to the history object.
fn set_helper(self: &mut Self, helper: Option<H>)Register a callback function to be called for tab-completion or to show hints to the user at the right of the prompt.
fn helper_mut(self: &mut Self) -> Option<&mut H>Return a mutable reference to the helper.
fn helper(self: &Self) -> Option<&H>Return an immutable reference to the helper.
fn bind_sequence<E: Into<Event>, R: Into<EventHandler>>(self: &mut Self, key_seq: E, handler: R) -> Option<EventHandler>Bind a sequence to a command.
fn unbind_sequence<E: Into<Event>>(self: &mut Self, key_seq: E) -> Option<EventHandler>Remove a binding for the given sequence.
fn iter<'a>(self: &'a mut Self, prompt: &'a str) -> impl Iterator<Item = Result<String>> + 'aReturns an iterator over edited lines. Iterator ends at EOF.
let mut rl = new?; for readline in rl.iter # Ok::fn dimensions(self: &mut Self) -> Option<(u16, u16)>If output stream is a tty, this function returns its width and height as a number of characters.
fn clear_screen(self: &mut Self) -> Result<()>Clear the screen.
fn create_external_printer(self: &mut Self) -> Result<<PosixTerminal as Term>::ExternalPrinter>Create an external printer
fn set_cursor_visibility(self: &mut Self, visible: bool) -> Result<Option<<PosixTerminal as Term>::CursorGuard>>Change cursor visibility
impl<H, I> Freeze for Editor<H, I>
impl<H, I> RefUnwindSafe for Editor<H, I>
impl<H, I> Send for Editor<H, I>
impl<H, I> Sync for Editor<H, I>
impl<H, I> Unpin for Editor<H, I>
impl<H, I> UnwindSafe for Editor<H, I>
impl<H: Helper, I: History> Configurer for Editor<H, I>
fn config_mut(self: &mut Self) -> &mut Configfn set_max_history_size(self: &mut Self, max_size: usize) -> Result<()>fn set_history_ignore_dups(self: &mut Self, yes: bool) -> Result<()>fn set_history_ignore_space(self: &mut Self, yes: bool)
impl<H: Helper, I: History> Debug for Editor<H, I>
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl<T> Any for Editor<H, I>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Editor<H, I>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Editor<H, I>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Editor<H, I>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Editor<H, I>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Editor<H, I>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Editor<H, I>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>