aboutsummaryrefslogtreecommitdiffstats
path: root/examples/async.rs
blob: 5102abad1bef006bd9892a4696a3fd2c2619f9f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use textmode::Textmode as _;

async fn run(tm: &mut textmode::Output) -> textmode::Result<()> {
    tm.move_to(5, 5);
    tm.write_str("foo");
    smol::Timer::after(std::time::Duration::from_secs(2)).await;
    tm.refresh().await?;
    smol::Timer::after(std::time::Duration::from_secs(2)).await;

    tm.move_to(8, 8);
    tm.set_fgcolor(textmode::color::GREEN);
    tm.write_str("bar");
    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;
    tm.refresh().await?;
    smol::Timer::after(std::time::Duration::from_secs(2)).await;
    Ok(())
}

fn main() {
    smol::block_on(async {
        let mut tm = textmode::Output::new().await.unwrap();
        let e = run(&mut tm).await;
        e.unwrap();
    });
}