aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/async.rs16
-rw-r--r--examples/basic.rs9
2 files changed, 15 insertions, 10 deletions
diff --git a/examples/async.rs b/examples/async.rs
index 5102aba..e8c88ba 100644
--- a/examples/async.rs
+++ b/examples/async.rs
@@ -1,11 +1,14 @@
use textmode::Textmode as _;
-async fn run(tm: &mut textmode::Output) -> textmode::Result<()> {
+async fn run(
+ tm: &mut textmode::Output,
+ input: &mut textmode::Input,
+) -> textmode::Result<()> {
tm.move_to(5, 5);
tm.write_str("foo");
- smol::Timer::after(std::time::Duration::from_secs(2)).await;
+ input.read_key().await?;
tm.refresh().await?;
- smol::Timer::after(std::time::Duration::from_secs(2)).await;
+ input.read_key().await?;
tm.move_to(8, 8);
tm.set_fgcolor(textmode::color::GREEN);
@@ -13,16 +16,17 @@ async fn run(tm: &mut textmode::Output) -> textmode::Result<()> {
tm.move_to(11, 11);
tm.set_fgcolor(vt100::Color::Default);
tm.write_str("baz");
- smol::Timer::after(std::time::Duration::from_secs(2)).await;
+ input.read_key().await?;
tm.refresh().await?;
- smol::Timer::after(std::time::Duration::from_secs(2)).await;
+ input.read_key().await?;
Ok(())
}
fn main() {
smol::block_on(async {
let mut tm = textmode::Output::new().await.unwrap();
- let e = run(&mut tm).await;
+ let mut input = textmode::Input::new().await.unwrap();
+ let e = run(&mut tm, &mut input).await;
e.unwrap();
});
}
diff --git a/examples/basic.rs b/examples/basic.rs
index fb13d89..18d86a9 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -2,12 +2,13 @@ use textmode::Textmode as _;
fn main() {
let mut tm = textmode::blocking::Output::new().unwrap();
+ let mut input = textmode::blocking::Input::new().unwrap();
tm.move_to(5, 5);
tm.write_str("foo");
- std::thread::sleep(std::time::Duration::from_secs(2));
+ input.read_key().unwrap();
tm.refresh().unwrap();
- std::thread::sleep(std::time::Duration::from_secs(2));
+ input.read_key().unwrap();
tm.move_to(8, 8);
tm.set_fgcolor(textmode::color::GREEN);
@@ -15,7 +16,7 @@ fn main() {
tm.move_to(11, 11);
tm.set_fgcolor(vt100::Color::Default);
tm.write_str("baz");
- std::thread::sleep(std::time::Duration::from_secs(2));
+ input.read_key().unwrap();
tm.refresh().unwrap();
- std::thread::sleep(std::time::Duration::from_secs(2));
+ input.read_key().unwrap();
}