You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
648 B
26 lines
648 B
pub mod reader;
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
use reader::ReaderState;
|
|
|
|
fn main() {
|
|
let state = Arc::new(Mutex::new(ReaderState::new("uwu> ")));
|
|
let state_r = state.clone();
|
|
assert!(state.lock().unwrap().init_tty().is_ok());
|
|
std::panic::set_hook(Box::new(move |_| {
|
|
let _ = state_r.lock().unwrap().restore_tty();
|
|
}));
|
|
loop {
|
|
let line = state.lock().unwrap().read_line();
|
|
match line {
|
|
Ok(s) => println!("{}", s),
|
|
Err(e) => {
|
|
eprintln!("\nError: {:?}", e);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
let _ = state.lock().unwrap().restore_tty();
|
|
}
|