[][src]Struct liner::Context

pub struct Context {
    pub history: History,
    pub word_divider_fn: Box<dyn Fn(&Buffer) -> Vec<(usize, usize)>>,
    pub key_bindings: KeyBindings,
    pub buf: String,
}

Fields

history: Historyword_divider_fn: Box<dyn Fn(&Buffer) -> Vec<(usize, usize)>>key_bindings: KeyBindingsbuf: String

Methods

impl Context[src]

pub fn new() -> Self[src]

pub fn read_line<P: Into<String>, C: Completer>(
    &mut self,
    prompt: P,
    f: Option<ColorClosure>,
    handler: &mut C
) -> Result<String>
[src]

Creates an Editor and feeds it keypresses from stdin until the line is entered. The output is stdout. The returned line has the newline removed. Before returning, will revert all changes to the history buffers.

pub fn read_line_with_init_buffer<P: Into<String>, B: Into<Buffer>, C: Completer>(
    &mut self,
    prompt: P,
    handler: &mut C,
    f: Option<ColorClosure>,
    buffer: B
) -> Result<String>
[src]

Same as Context.read_line(), but passes the provided initial buffer to the editor.

use liner::{Context, Completer};

struct EmptyCompleter;

impl Completer for EmptyCompleter {
    fn completions(&mut self, _start: &str) -> Vec<String> {
        Vec::new()
    }
}

let mut context = Context::new();
let line =
    context.read_line_with_init_buffer("[prompt]$ ",
                                       &mut EmptyCompleter,
                                       Some(Box::new(|s| String::from(s))),
                                       "some initial buffer");

pub fn revert_all_history(&mut self)[src]

Trait Implementations

impl Default for Context[src]

Auto Trait Implementations

impl !Send for Context

impl !Sync for Context

impl Unpin for Context

impl !UnwindSafe for Context

impl !RefUnwindSafe for Context

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 = !

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]