diff options
Diffstat (limited to 'demo/size')
| -rw-r--r-- | demo/size/size.ha | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/demo/size/size.ha b/demo/size/size.ha new file mode 100644 index 0000000..55b6a3c --- /dev/null +++ b/demo/size/size.ha | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | use fmt; | ||
| 2 | use tb = termbox2; | ||
| 3 | |||
| 4 | export fn main() void = { | ||
| 5 | let e = tb::init(); | ||
| 6 | if (e is tb::err) | ||
| 7 | fmt::fatalf(tb::strerror(e as tb::err)); | ||
| 8 | defer tb::shutdown()!; | ||
| 9 | |||
| 10 | let w = tb::width()!; | ||
| 11 | let h = tb::height()!; | ||
| 12 | tb::print(0, 0, tb::COLOR.GREEN, tb::COLOR.BLACK, | ||
| 13 | "Terminal width: {}", w)!; | ||
| 14 | tb::print(0, 1, tb::COLOR.GREEN, tb::COLOR.BLACK, | ||
| 15 | "Terminal height: {}", h)!; | ||
| 16 | tb::print(0, 2, tb::COLOR.WHITE, tb::COLOR.BLACK, | ||
| 17 | "Press any key to exit")!; | ||
| 18 | for (true) { | ||
| 19 | let e = tb::present(); | ||
| 20 | if (e is tb::err) | ||
| 21 | fmt::fatalf(tb::strerror(e as tb::err)); | ||
| 22 | match (tb::poll_event()) { | ||
| 23 | case let e: tb::err => { | ||
| 24 | if (e == tb::ERR.NO_EVENT) | ||
| 25 | continue | ||
| 26 | else | ||
| 27 | tb::print(0, 4, tb::COLOR.WHITE, tb::COLOR.BLACK, | ||
| 28 | "Unexpected error {}!", tb::strerror(e))!; | ||
| 29 | }; | ||
| 30 | case tb::key_event => break; | ||
| 31 | case (tb::mouse_event | tb::resize_event) => continue; | ||
| 32 | }; | ||
| 33 | }; | ||
| 34 | return; | ||
| 35 | }; | ||
