Struct rustyline::Editor

source ·
pub struct Editor<H: Helper> { /* private fields */ }
Expand description

Line editor

Implementations§

Create an editor with the default configuration

Create an editor with a specific configuration.

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.

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.

Load the history from the specified file.

Save the history in the specified file.

Append new entries in the specified file.

source

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

Add a new entry in the history.

Clear history.

Return a mutable reference to the history object.

Return an immutable reference to the history object.

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

Return a mutable reference to the helper.

Return an immutable reference to the helper.

Available on crate feature custom-bindings only.

Bind a sequence to a command.

Available on crate feature custom-bindings only.

Remove a binding for the given sequence.

Returns an iterator over edited lines. Iterator ends at EOF.

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

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

Create an external printer

Trait Implementations§

Config accessor.
Set the maximum length for the history.
Tell if lines which match the previous history entry are saved or not in the history list. Read more
Tell if lines which begin with a space character are saved or not in the history list. Read more
Forces colorization on or off. Read more
Set completion_type.
The number of possible completions that determines when the user is asked whether the list of possibilities should be displayed.
Timeout for ambiguous key sequences in milliseconds.
Choose between Emacs or Vi mode.
Tell if lines are automatically added to the history. Read more
Set bell style: beep, flash or nothing.
Whether to use stdio or not Read more
Horizontal space taken by a tab. Read more
Check if cursor position is at leftmost before displaying prompt. Read more
Indentation size for indent/dedent commands Read more
Enable or disable bracketed paste on unix platform Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.