summaryrefslogtreecommitdiff
path: root/tui/widget/widget.ha
diff options
context:
space:
mode:
Diffstat (limited to 'tui/widget/widget.ha')
-rw-r--r--tui/widget/widget.ha26
1 files changed, 26 insertions, 0 deletions
diff --git a/tui/widget/widget.ha b/tui/widget/widget.ha
new file mode 100644
index 0000000..cb202be
--- /dev/null
+++ b/tui/widget/widget.ha
@@ -0,0 +1,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)!;
+};