23 lines
480 B
Rust
23 lines
480 B
Rust
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();
|
|
}
|