init - implement raw mode

This commit is contained in:
Crispy 2023-03-19 00:10:08 +01:00
commit 6ffb32c543
7 changed files with 210 additions and 0 deletions

23
examples/print.rs Normal file
View file

@ -0,0 +1,23 @@
use ants::{event::Events, raw_mode};
use std::{
io::{stdin, Read},
time::{Duration, SystemTime},
};
fn main() {
raw_mode::enter().unwrap();
let start_time = SystemTime::now();
let mut buf = Vec::new();
while start_time.elapsed().unwrap() < Duration::from_secs(5) {
let mut b = [0u8];
if let Ok(_n) = stdin().read(&mut b) {
if b[0] != 0 {
buf.push(b[0]);
print!("[{}]:{}\n\r", b[0], String::from_utf8_lossy(&buf));
}
}
}
raw_mode::exit().unwrap();
}