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 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 style = struct {
border: bool,
};
export def DEFAULT_STYLE: style = style {
border = false,
};
export type widget = struct {
out: io::file,
print: *printfn,
resize: *resizefn,
pos: coords,
sz: widgetsize,
style: style,
};
def gotoroot: str = "\x1B[1;1H";
export fn print(out: io::file, s: str, pos: coords) void = {
fmt::fprintf(out, "\x1B[{};{}H", pos.0, pos.1)!;
fmt::fprint(out, s)!;
};
|