From 2e31cbeb70d93bb0f5512064f181990db189d1f6 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 4 Oct 2026 20:02:15 +0200 Subject: Initial commit --- demo/size/size.ha | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 demo/size/size.ha (limited to 'demo/size') 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 @@ +use fmt; +use tb = termbox2; + +export fn main() void = { + let e = tb::init(); + if (e is tb::err) + fmt::fatalf(tb::strerror(e as tb::err)); + defer tb::shutdown()!; + + let w = tb::width()!; + let h = tb::height()!; + tb::print(0, 0, tb::COLOR.GREEN, tb::COLOR.BLACK, + "Terminal width: {}", w)!; + tb::print(0, 1, tb::COLOR.GREEN, tb::COLOR.BLACK, + "Terminal height: {}", h)!; + tb::print(0, 2, tb::COLOR.WHITE, tb::COLOR.BLACK, + "Press any key to exit")!; + for (true) { + let e = tb::present(); + if (e is tb::err) + fmt::fatalf(tb::strerror(e as tb::err)); + match (tb::poll_event()) { + case let e: tb::err => { + if (e == tb::ERR.NO_EVENT) + continue + else + tb::print(0, 4, tb::COLOR.WHITE, tb::COLOR.BLACK, + "Unexpected error {}!", tb::strerror(e))!; + }; + case tb::key_event => break; + case (tb::mouse_event | tb::resize_event) => continue; + }; + }; + return; +}; -- cgit v1.3