2018-07-21 02:00:46 +10:00
|
|
|
extern crate crossterm;
|
|
|
|
|
2019-01-28 07:16:14 +11:00
|
|
|
use self::crossterm::{KeyEvent, TerminalInput, input, Screen};
|
2018-07-21 02:00:46 +10:00
|
|
|
|
2018-07-22 22:55:14 +10:00
|
|
|
pub fn read_char() {
|
2018-11-15 02:53:27 +11:00
|
|
|
let input = input();
|
2018-07-21 02:00:46 +10:00
|
|
|
|
2018-07-22 22:55:14 +10:00
|
|
|
match input.read_char() {
|
2018-08-12 01:58:15 +10:00
|
|
|
Ok(s) => println!("char typed: {}", s),
|
|
|
|
Err(e) => println!("char error : {}", e),
|
2018-07-21 02:00:46 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-22 22:55:14 +10:00
|
|
|
pub fn read_line() {
|
2018-11-15 02:53:27 +11:00
|
|
|
let input = input();
|
2018-07-21 02:00:46 +10:00
|
|
|
|
2018-07-22 22:55:14 +10:00
|
|
|
match input.read_line() {
|
2018-07-21 02:00:46 +10:00
|
|
|
Ok(s) => println!("string typed: {}", s),
|
2018-07-22 22:55:14 +10:00
|
|
|
Err(e) => println!("error: {}", e),
|
2018-07-21 02:00:46 +10:00
|
|
|
}
|
2018-07-22 22:55:14 +10:00
|
|
|
}
|
2018-11-22 08:57:39 +11:00
|
|
|
|
|
|
|
pub fn pause_terminal() {
|
|
|
|
println!("Press 'x' to quit...");
|
2019-01-28 07:16:14 +11:00
|
|
|
let screen = Screen::new(true);
|
|
|
|
let terminal_input = TerminalInput::from_output(&screen.stdout);
|
|
|
|
terminal_input.wait_until(KeyEvent::OnKeyPress(b'x'));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main(){
|
|
|
|
pause_terminal();
|
2018-11-22 08:57:39 +11:00
|
|
|
}
|