2020-12-16 23:15:29 +01:00
|
|
|
//! Input
|
|
|
|
//!
|
|
|
|
//! https://github.com/dankamongmen/notcurses/blob/master/USAGE.md#input
|
|
|
|
//!
|
|
|
|
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
|
2020-12-25 19:35:21 +01:00
|
|
|
fn main() -> NcResult<()> {
|
2021-04-17 22:13:43 +02:00
|
|
|
let mut nc = Nc::with_flags(
|
2021-01-02 19:45:15 +01:00
|
|
|
NCOPTION_SUPPRESS_BANNERS | NCOPTION_NO_WINCH_SIGHANDLER | NCOPTION_NO_QUIT_SIGHANDLERS,
|
|
|
|
)?;
|
2020-12-16 23:15:29 +01:00
|
|
|
|
|
|
|
println!("Exit with F1\n");
|
|
|
|
|
2021-01-01 13:59:30 +01:00
|
|
|
let mut input = NcInput::new_empty();
|
2020-12-16 23:15:29 +01:00
|
|
|
|
|
|
|
loop {
|
2021-01-02 19:45:15 +01:00
|
|
|
let key = notcurses_getc_nblock(&mut nc, &mut input);
|
2020-12-16 23:15:29 +01:00
|
|
|
|
|
|
|
if key as i32 != -1 {
|
|
|
|
println!("'{0}' ({1:x})\n{2:?}", key, key as u32, input);
|
|
|
|
}
|
|
|
|
|
2021-01-02 19:45:15 +01:00
|
|
|
rsleep![&mut nc, 0, 10];
|
2020-12-16 23:15:29 +01:00
|
|
|
|
|
|
|
match key {
|
|
|
|
NCKEY_F01 => break,
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("\nExiting...");
|
|
|
|
|
2021-04-07 21:27:10 +02:00
|
|
|
rsleep![&mut nc, 1];
|
2020-12-25 19:35:21 +01:00
|
|
|
Ok(())
|
2020-12-16 23:15:29 +01:00
|
|
|
}
|