minicrossterm/examples/Crossterm 0.3.1/input/keyboard/input.rs

25 lines
539 B
Rust
Raw Normal View History

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