use fmt; use io; use unix::tty; export type tui = struct { out: io::file, clear: bool, }; export fn init() (tui | tty::error) = { const f = tty::open()?; doclear(f); return tui { out = f, clear = false, }; }; 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)!; };