summaryrefslogtreecommitdiff
path: root/tui/widget/widget.ha
blob: cb202be37a6c1495352e226f1c1ab9decf801ceb (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
use fmt;
use unix::tty;
use io;

export type coords = (u16, u16);

export type printfn = fn(w: *widget) void;
export type resizefn = fn(w: *widget, ttysize: tty::ttysize) void;

export type nosize = void;
export type widgetsize = (tty::ttysize | nosize);

export type widget = struct {
	out: io::file,
	print: *printfn,
	resize: *resizefn,
	pos: coords,
	sz: widgetsize,
};

def gotoroot: str = "\x1B[1;1f";

export fn print(out: io::file, s: str, pos: coords) void = {
	fmt::fprintf(out, "\x1B[{};{}H", pos.0, pos.1)!;
	fmt::fprint(out, s)!;
};