1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-27 15:37:29 +03:00
wezterm/termwiz/examples/key_tester.rs
Wez Furlong 5d360ae365 termwiz: Remove anyhow::Result from public API
It's been replaced with an opaque termwiz error type instead.

This is a bit of a more conservative approach than that in (refs: #407)
and has less of an impact on the surrounding code, which appeals to
me from a maintenance perspective.

refs: #406
refs: #407
2021-01-08 00:32:30 -08:00

25 lines
609 B
Rust

use termwiz::caps::Capabilities;
use termwiz::input::{InputEvent, KeyCode, KeyEvent, Modifiers};
use termwiz::terminal::{new_terminal, Terminal};
use termwiz::Error;
const CTRL_C: KeyEvent = KeyEvent {
key: KeyCode::Char('C'),
modifiers: Modifiers::CTRL,
};
fn main() -> Result<(), Error> {
let caps = Capabilities::new_from_env()?;
let mut terminal = new_terminal(caps)?;
terminal.set_raw_mode()?;
while let Some(event) = terminal.poll_input(None)? {
print!("{:?}\r\n", event);
if event == InputEvent::Key(CTRL_C) {
break;
}
}
Ok(())
}