aboutsummaryrefslogtreecommitdiff
path: root/demo/size/size.ha
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-10-04 20:02:15 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-10-04 20:02:15 +0200
commit2e31cbeb70d93bb0f5512064f181990db189d1f6 (patch)
tree049f137715b692bcac0fd402fcbf04ef703523f0 /demo/size/size.ha
downloadhare-termbox2-2e31cbeb70d93bb0f5512064f181990db189d1f6.tar.gz
hare-termbox2-2e31cbeb70d93bb0f5512064f181990db189d1f6.zip
Initial commit
Diffstat (limited to 'demo/size/size.ha')
-rw-r--r--demo/size/size.ha35
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 @@
1use fmt;
2use tb = termbox2;
3
4export 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};

Generated with cgit - Back to sebastiano.tronto.net