mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
bcd09be7d3
In order to be consistent with the rest of the naming scheme, and in order to avoid conflicts with the higher level rust wrappers, which will be using `Notcurses` for the wrapper struct from now on. - also deprecate `NotcursesOptions` and rename it to `NcOptions`. - update examples, docs and readme.
38 lines
755 B
Rust
38 lines
755 B
Rust
//! Input
|
|
//!
|
|
//! https://github.com/dankamongmen/notcurses/blob/master/USAGE.md#input
|
|
//!
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
fn main() -> NcResult<()> {
|
|
let mut nc = Nc::with_flags(
|
|
NCOPTION_SUPPRESS_BANNERS | NCOPTION_NO_WINCH_SIGHANDLER | NCOPTION_NO_QUIT_SIGHANDLERS,
|
|
)?;
|
|
|
|
println!("Exit with F1\n");
|
|
|
|
let mut input = NcInput::new_empty();
|
|
|
|
loop {
|
|
let key = notcurses_getc_nblock(&mut nc, &mut input);
|
|
|
|
if key as i32 != -1 {
|
|
println!("'{0}' ({1:x})\n{2:?}", key, key as u32, input);
|
|
}
|
|
|
|
rsleep![&mut nc, 0, 10];
|
|
|
|
match key {
|
|
NCKEY_F01 => break,
|
|
_ => (),
|
|
}
|
|
}
|
|
|
|
println!("\nExiting...");
|
|
|
|
rsleep![&mut nc, 1];
|
|
nc.stop()?;
|
|
Ok(())
|
|
}
|