2019-04-21 06:14:20 +03:00
|
|
|
use termwiz::caps::Capabilities;
|
|
|
|
use termwiz::input::{InputEvent, KeyCode, KeyEvent, Modifiers};
|
2019-04-28 19:31:35 +03:00
|
|
|
use termwiz::terminal::{new_terminal, Terminal};
|
2021-01-08 11:21:54 +03:00
|
|
|
use termwiz::Error;
|
2019-04-21 06:14:20 +03:00
|
|
|
|
|
|
|
const CTRL_C: KeyEvent = KeyEvent {
|
2022-09-22 06:25:17 +03:00
|
|
|
key: KeyCode::Char('c'),
|
2019-04-21 06:14:20 +03:00
|
|
|
modifiers: Modifiers::CTRL,
|
|
|
|
};
|
|
|
|
|
|
|
|
fn main() -> Result<(), Error> {
|
|
|
|
let caps = Capabilities::new_from_env()?;
|
|
|
|
let mut terminal = new_terminal(caps)?;
|
|
|
|
terminal.set_raw_mode()?;
|
|
|
|
|
2019-04-28 19:31:35 +03:00
|
|
|
while let Some(event) = terminal.poll_input(None)? {
|
2019-04-21 06:14:20 +03:00
|
|
|
print!("{:?}\r\n", event);
|
|
|
|
if event == InputEvent::Key(CTRL_C) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|