diff options
Diffstat (limited to 'tui/tui.ha')
| -rw-r--r-- | tui/tui.ha | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -2,13 +2,30 @@ use fmt; use io; use unix::tty; -export fn init() (io::file | tty::error) = { +export type tui = struct { + out: io::file, + clear: bool, +}; + +export fn init() (tui | tty::error) = { const f = tty::open()?; - clear(f); - return f; + doclear(f); + return tui { + out = f, + clear = false, + }; }; -export fn clear(out: io::file) void = { +fn doclear(out: io::file) void = { fmt::fprint(out, "\x1B[2J\x1B[1;1H")!; }; + +export fn clear(state: *tui) void = { + state.clear = true; + //fmt::fprint(out, "\x1B[2J\x1B[1;1H")!; +}; + +export fn finish(state: *tui) void = { + io::close(state.out)!; +}; |
