Struct rustyline::Editor[][src]

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

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>(&mut self, path: &P) -> Result<()>[src]

Save the history in the specified file.

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

Append new entries 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<E: Into<Event>, R: Into<EventHandler>>(
    &mut self,
    key_seq: E,
    handler: R
) -> Option<EventHandler>
[src]

Bind a sequence to a command.

pub fn unbind_sequence<E: Into<Event>>(
    &mut self,
    key_seq: E
) -> Option<EventHandler>
[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]

fn config_mut(&mut self) -> &mut Config[src]

Config accessor.

fn set_max_history_size(&mut self, max_size: usize)[src]

Set the maximum length for the history.

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

Tell if lines which match the previous history entry are saved or not in the history list. Read more

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

Tell if lines which begin with a space character are saved or not in the history list. Read more

fn set_color_mode(&mut self, color_mode: ColorMode)[src]

Forces colorization on or off. Read more

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_bell_style(&mut self, bell_style: BellStyle)[src]

Set bell style: beep, flash or nothing.

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

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

Check if cursor position is at leftmost before displaying prompt. Read more

fn set_indent_size(&mut self, size: usize)[src]

Indentation size for indent/dedent commands Read more

fn enable_bracketed_paste(&mut self, enabled: bool)[src]

Enable or disable bracketed paste on unix platform Read more

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

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> AsAny for T where
    T: Any
[src]

pub fn as_any(&self) -> &(dyn Any + 'static)[src]

pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)[src]

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.