diff --git a/examples/Crossterm 0.3.1/bin.rs b/examples/Crossterm 0.3.1/bin.rs index afeff6e..cf4caef 100644 --- a/examples/Crossterm 0.3.1/bin.rs +++ b/examples/Crossterm 0.3.1/bin.rs @@ -27,7 +27,7 @@ use crossterm::raw::IntoRawMode; use std::{thread, time}; fn main() { - async_input::read_async(); + async_input::read_async_until(); } use crossterm::raw::RawTerminal; diff --git a/examples/Crossterm 0.3.1/input/keyboard/async_input.rs b/examples/Crossterm 0.3.1/input/keyboard/async_input.rs index 24b44a0..fb2f881 100644 --- a/examples/Crossterm 0.3.1/input/keyboard/async_input.rs +++ b/examples/Crossterm 0.3.1/input/keyboard/async_input.rs @@ -13,12 +13,19 @@ use std::time::Duration; /// this will capture the input until the given key. pub fn read_async_until() { - let context = Context::new(); - let input = input(&context); + let crossterm = Crossterm::new(); + // init some modules we use for this demo + let input = crossterm.input(); + let terminal = crossterm.terminal(); + let mut cursor = crossterm.cursor(); + + let mut stdout = stdout().into_raw_mode(crossterm.context()).unwrap(); let mut stdin = input.read_until_async(b'\r').bytes(); for i in 0..100 { + terminal.clear(ClearType::All); + cursor.goto(1, 1); let a = stdin.next(); println!("pressed key: {:?}", a); @@ -33,7 +40,7 @@ pub fn read_async_until() { break; } - thread::sleep(time::Duration::from_millis(50)); + thread::sleep(time::Duration::from_millis(100)); } }