blob: db56d20b692f956fbad382b8c313b19909dd3222 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use textmode::Textmode as _;
#[cfg(feature = "async")]
#[tokio::main]
async fn main() -> textmode::Result<()> {
let mut input = textmode::Input::new().await?;
let mut tm = textmode::Output::new().await?;
tm.move_to(5, 5);
tm.write_str("foo");
input.read_key().await?;
tm.refresh().await?;
input.read_key().await?;
tm.move_to(8, 8);
tm.set_fgcolor(textmode::color::GREEN);
tm.write_str("bar");
tm.move_relative(3, 0);
tm.set_fgcolor(textmode::Color::Default);
tm.write_str("baz");
input.read_key().await?;
tm.refresh().await?;
input.read_key().await?;
Ok(())
}
#[cfg(not(feature = "async"))]
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");
input.read_key().unwrap();
tm.refresh().unwrap();
input.read_key().unwrap();
tm.move_to(8, 8);
tm.set_fgcolor(textmode::color::GREEN);
tm.write_str("bar");
tm.move_relative(3, 0);
tm.set_fgcolor(textmode::Color::Default);
tm.write_str("baz");
input.read_key().unwrap();
tm.refresh().unwrap();
input.read_key().unwrap();
}
|