diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-03-08 01:36:14 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-03-08 01:47:05 -0500 |
commit | a686b1797cc9f0359da51e7e62c485c83d2e12f5 (patch) | |
tree | d0ec21de9e7a1fcfb2c61a656024e3af36c27474 | |
parent | df9656340acdcfc543d231712732a597b6ee9953 (diff) | |
download | textmode-a686b1797cc9f0359da51e7e62c485c83d2e12f5.tar.gz textmode-a686b1797cc9f0359da51e7e62c485c83d2e12f5.zip |
add input tester
-rw-r--r-- | examples/input.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/input.rs b/examples/input.rs new file mode 100644 index 0000000..e63787b --- /dev/null +++ b/examples/input.rs @@ -0,0 +1,27 @@ +fn main() { + let (mut input, _raw) = textmode::blocking::Input::new(); + for arg in std::env::args().skip(1) { + match arg.as_str() { + "--disable-utf8" => input.parse_utf8(false), + "--disable-ctrl" => input.parse_ctrl(false), + "--disable-meta" => input.parse_meta(false), + "--disable-special-keys" => input.parse_special_keys(false), + "--disable-single" => input.parse_single(false), + _ => panic!("unknown arg {}", arg), + } + } + + loop { + let key = input.read_key().unwrap(); + if let Some(key) = key { + print!("{:?}: ", key); + let bytes = key.into_bytes(); + print!("{:?}\r\n", bytes); + if bytes.contains(&3) { + break; + } + } else { + break; + } + } +} |