[−][src]Struct termwiz::lineedit::LineEditor
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]
&mut self,
host: &mut dyn LineEditorHost
) -> Result<Option<String>>
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,
T: RefUnwindSafe,
impl<T> Send for LineEditor<T> where
T: Send,
T: Send,
impl<T> Sync for LineEditor<T> where
T: Sync,
T: Sync,
impl<T> Unpin for LineEditor<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for LineEditor<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,