aboutsummaryrefslogtreecommitdiffstats
path: root/examples/raw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/raw.rs')
-rw-r--r--examples/raw.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/raw.rs b/examples/raw.rs
new file mode 100644
index 0000000..5890a99
--- /dev/null
+++ b/examples/raw.rs
@@ -0,0 +1,20 @@
+use std::io::Read;
+
+fn main() {
+ let _screen = crossterm::RawScreen::into_raw_mode().unwrap();
+ loop {
+ let stdin = std::io::stdin();
+ let mut stdin = stdin.lock();
+ let mut buf = [0; 1];
+ let n = stdin.read(&mut buf).unwrap();
+ if n > 0 {
+ eprint!("got {}\r\n", buf[0]);
+ if buf[0] == 4 {
+ break;
+ }
+ } else {
+ eprint!("got no bytes\r\n");
+ break;
+ }
+ }
+}