b717d306c3
When you want to work with the 'alternate screen' you can call the following functions: terminal::from_screen etc. Which will give you an instance to the back of the module you are calling it in. So instead of: let color = color(Screen::default()); let cursor = cursor(Screen::default()); let input = input(Screen::default()); let terminal = terminal(Screen::default()); You can do: let color = color(); let cursor = cursor(); let input = input(); let terminal = terminal();
23 lines
453 B
Rust
23 lines
453 B
Rust
extern crate crossterm;
|
|
|
|
use self::crossterm::input::input;
|
|
use self::crossterm::Screen;
|
|
|
|
pub fn read_char() {
|
|
let input = input();
|
|
|
|
match input.read_char() {
|
|
Ok(s) => println!("char typed: {}", s),
|
|
Err(e) => println!("char error : {}", e),
|
|
}
|
|
}
|
|
|
|
pub fn read_line() {
|
|
let input = input();
|
|
|
|
match input.read_line() {
|
|
Ok(s) => println!("string typed: {}", s),
|
|
Err(e) => println!("error: {}", e),
|
|
}
|
|
}
|