[][src]Struct rustyline::Editor

pub struct Editor<H: Helper> { /* fields omitted */ }

Line editor

Implementations

impl<H: Helper> Editor<H>[src]

pub fn new() -> Self[src]

Create an editor with the default configuration

pub fn with_config(config: Config) -> Self[src]

Create an editor with a specific configuration.

pub fn readline(&mut self, prompt: &str) -> Result<String>[src]

This method will read a line from STDIN and will display a prompt.

It uses terminal-style interaction if stdin is connected to a terminal. Otherwise (e.g., if stdin is a pipe or the terminal is not supported), it uses file-style interaction.

pub fn readline_with_initial(
    &mut self,
    prompt: &str,
    initial: (&str, &str)
) -> Result<String>
[src]

This function behaves in the exact same manner as 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.

pub fn load_history<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<()>[src]

Load the history from the specified file.

pub fn save_history<P: AsRef<Path> + ?Sized>(&self, path: &P) -> Result<()>[src]

Save the history in the specified file.

pub fn add_history_entry<S: AsRef<str> + Into<String>>(
    &mut self,
    line: S
) -> bool
[src]

Add a new entry in the history.

pub fn clear_history(&mut self)[src]

Clear history.

pub fn history_mut(&mut self) -> &mut History[src]

Return a mutable reference to the history object.

pub fn history(&self) -> &History[src]

Return an immutable reference to the history object.

pub fn set_helper(&mut self, helper: Option<H>)[src]

Register a callback function to be called for tab-completion or to show hints to the user at the right of the prompt.

pub fn helper_mut(&mut self) -> Option<&mut H>[src]

Return a mutable reference to the helper.

pub fn helper(&self) -> Option<&H>[src]

Return an immutable reference to the helper.

pub fn bind_sequence(&mut self, key_seq: KeyPress, cmd: Cmd) -> Option<Cmd>[src]

Bind a sequence to a command.

pub fn unbind_sequence(&mut self, key_seq: KeyPress) -> Option<Cmd>[src]

Remove a binding for the given sequence.

pub fn iter<'a>(
    &'a mut self,
    prompt: &'a str
) -> impl Iterator<Item = Result<String>> + 'a
[src]

Returns an iterator over edited lines

let mut rl = rustyline::Editor::<()>::new();
for readline in rl.iter("> ") {
    match readline {
        Ok(line) => {
            println!("Line: {}", line);
        }
        Err(err) => {
            println!("Error: {:?}", err);
            break;
        }
    }
}

pub fn dimensions(&mut self) -> Option<(usize, usize)>[src]

If output stream is a tty, this function returns its width and height as a number of characters.

Trait Implementations

impl<H: Helper> Configurer for Editor<H>[src]

impl<H: Helper> Debug for Editor<H>[src]

Auto Trait Implementations

impl<H> RefUnwindSafe for Editor<H> where
    H: RefUnwindSafe

impl<H> Send for Editor<H> where
    H: Send

impl<H> Sync for Editor<H> where
    H: Sync

impl<H> Unpin for Editor<H> where
    H: Unpin

impl<H> UnwindSafe for Editor<H> where
    H: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.