[][src]Struct termwiz::lineedit::LineEditor

pub struct LineEditor<T: Terminal> { /* fields omitted */ }

The LineEditor struct provides line editing facilities similar to those in the unix shell.

use termwiz::lineedit::{line_editor, NopLineEditorHost};

fn main() -> anyhow::Result<()> {
    let mut editor = line_editor()?;
    let mut host = NopLineEditorHost::default();

    let line = editor.read_line(&mut host)?;
    println!("read line: {:?}", line);

    Ok(())
}

Implementations

impl<T: Terminal> LineEditor<T>[src]

pub fn new(terminal: T) -> Self[src]

Create a new line editor. In most cases, you'll want to use the line_editor function, because it creates a Terminal instance with the recommended settings, but if you need to decompose that for some reason, this snippet shows the recommended way to create a line editor:

use termwiz::caps::{Capabilities, ProbeHints};
use termwiz::terminal::new_terminal;
use anyhow::Error;
// Disable mouse input in the line editor
let hints = ProbeHints::new_from_env()
    .mouse_reporting(Some(false));
let caps = Capabilities::new_with_hints(hints)?;
let terminal = new_terminal(caps)?;

pub fn set_prompt(&mut self, prompt: &str)[src]

pub fn read_line(
    &mut self,
    host: &mut dyn LineEditorHost
) -> Result<Option<String>>
[src]

Enter line editing mode. Control is not returned to the caller until a line has been accepted, or until an error is detected. Returns Ok(None) if the editor was cancelled eg: via CTRL-C.

Auto Trait Implementations

impl<T> RefUnwindSafe for LineEditor<T> where
    T: RefUnwindSafe

impl<T> Send for LineEditor<T> where
    T: Send

impl<T> Sync for LineEditor<T> where
    T: Sync

impl<T> Unpin for LineEditor<T> where
    T: Unpin

impl<T> UnwindSafe for LineEditor<T> where
    T: 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.