[][src]Struct rustyline::Editor

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

Line editor

Methods

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.

Important traits for Iter<'a, H>
pub fn iter<'a>(&'a mut self, prompt: &'a str) -> Iter<H>[src]

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]

fn set_completion_type(&mut self, completion_type: CompletionType)[src]

Set completion_type.

fn set_completion_prompt_limit(&mut self, completion_prompt_limit: usize)[src]

The number of possible completions that determines when the user is asked whether the list of possibilities should be displayed. Read more

fn set_keyseq_timeout(&mut self, keyseq_timeout_ms: i32)[src]

Timeout for ambiguous key sequences in milliseconds.

fn set_edit_mode(&mut self, edit_mode: EditMode)[src]

Choose between Emacs or Vi mode.

fn set_auto_add_history(&mut self, yes: bool)[src]

Tell if lines are automatically added to the history. Read more

fn set_output_stream(&mut self, stream: OutputStreamType)[src]

Whether to use stdout or stderr Read more

fn set_tab_stop(&mut self, tab_stop: usize)[src]

Horizontal space taken by a tab. Read more

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

Auto Trait Implementations

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

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

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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