2018-07-21 02:00:46 +10:00
|
|
|
extern crate crossterm;
|
|
|
|
|
2018-07-30 05:30:09 +10:00
|
|
|
use self::crossterm::Crossterm;
|
2018-07-21 02:00:46 +10:00
|
|
|
|
2018-07-22 22:55:14 +10:00
|
|
|
pub fn read_char() {
|
2018-07-21 02:00:46 +10:00
|
|
|
let context = Context::new();
|
|
|
|
let input = input(&context);
|
|
|
|
|
2018-07-22 22:55:14 +10:00
|
|
|
match input.read_char() {
|
2018-07-21 02:00:46 +10:00
|
|
|
Ok(c) => println!("character pressed: {}", c),
|
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
|
|
|
pub fn read_line() {
|
2018-07-30 05:30:09 +10:00
|
|
|
let crossterm = Crossterm::new();
|
|
|
|
let input = crossterm.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
|
|
|
}
|