2020-12-16 22:15:29 +00:00
|
|
|
//! Input
|
|
|
|
//!
|
|
|
|
//! https://github.com/dankamongmen/notcurses/blob/master/USAGE.md#input
|
|
|
|
//!
|
|
|
|
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
|
2020-12-25 18:35:21 +00:00
|
|
|
fn main() -> NcResult<()> {
|
2020-12-16 22:15:29 +00:00
|
|
|
let nc = Notcurses::with_flags(
|
|
|
|
NCOPTION_SUPPRESS_BANNERS
|
|
|
|
| NCOPTION_NO_WINCH_SIGHANDLER
|
|
|
|
| NCOPTION_NO_QUIT_SIGHANDLERS
|
2020-12-25 18:35:21 +00:00
|
|
|
)?;
|
2020-12-16 22:15:29 +00:00
|
|
|
|
|
|
|
// doesn't seem to be necessary:
|
|
|
|
// let ready = unsafe { notcurses_inputready_fd(nc) };
|
|
|
|
// println!("{}", ready);
|
|
|
|
|
|
|
|
println!("Exit with F1\n");
|
|
|
|
|
2020-12-30 23:11:49 +00:00
|
|
|
let mut input = NcInput::new();
|
2020-12-16 22:15:29 +00:00
|
|
|
|
|
|
|
loop {
|
|
|
|
let key = notcurses_getc_nblock(nc, &mut input);
|
|
|
|
|
|
|
|
if key as i32 != -1 {
|
|
|
|
println!("'{0}' ({1:x})\n{2:?}", key, key as u32, input);
|
|
|
|
}
|
|
|
|
|
2020-12-26 04:14:27 +00:00
|
|
|
rsleep![nc, 0, 10];
|
2020-12-16 22:15:29 +00:00
|
|
|
|
|
|
|
match key {
|
|
|
|
NCKEY_F01 => break,
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("\nExiting...");
|
|
|
|
|
2020-12-26 04:14:27 +00:00
|
|
|
rsleep![nc, 1, 500];
|
2020-12-25 18:35:21 +00:00
|
|
|
nc.stop()?;
|
|
|
|
Ok(())
|
2020-12-16 22:15:29 +00:00
|
|
|
}
|