aboutsummaryrefslogtreecommitdiff
path: root/demo/size/size.ha
blob: 55b6a3cb134f72c79b22ec8101242c1d438d7ae8 (plain)
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
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;
};

Generated with cgit - Back to sebastiano.tronto.net