minicrossterm/crossterm_input/examples/input.rs

30 lines
552 B
Rust
Raw Normal View History

extern crate crossterm_input;
use self::crossterm_input::input;
2018-07-22 22:55:14 +10:00
pub fn read_char() {
let input = input();
2018-07-22 22:55:14 +10:00
match input.read_char() {
Ok(s) => println!("char typed: {}", s),
Err(e) => println!("char error : {}", e),
}
}
2018-07-22 22:55:14 +10:00
pub fn read_line() {
let input = input();
2018-07-22 22:55:14 +10:00
match input.read_line() {
Ok(s) => println!("string typed: {}", s),
2018-07-22 22:55:14 +10:00
Err(e) => println!("error: {}", e),
}
2018-07-22 22:55:14 +10:00
}
fn main() {
// un-comment below and run with
// `cargo run --example input`:
read_char();
read_line();
}