1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-28 09:12:19 +03:00
wezterm/termwiz/examples/line_editor.rs

21 lines
597 B
Rust
Raw Normal View History

use failure::{err_msg, Fallible};
use termwiz::caps::{Capabilities, ProbeHintsBuilder};
2019-05-27 07:10:37 +03:00
use termwiz::lineedit::LineEditor;
use termwiz::terminal::new_terminal;
fn main() -> Fallible<()> {
// Disable mouse input in the line editor
let hints = ProbeHintsBuilder::new_from_env()
.mouse_reporting(Some(false))
.build()
.map_err(err_msg)?;
let caps = Capabilities::new_with_hints(hints)?;
2019-05-27 07:10:37 +03:00
let terminal = new_terminal(caps)?;
let mut editor = LineEditor::new(terminal);
let line = editor.read_line()?;
println!("read line: {}", line);
Ok(())
}