diff options
| author | Julian Hurst <ark@mansus.space> | 2025-03-12 22:36:13 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2025-03-12 22:36:13 +0100 |
| commit | e074c936bb99ccfce311445f4dbf42ba964b44a4 (patch) | |
| tree | a2ca68130a4a6a532df3f7362d3cad0574d50259 /tui/tui.ha | |
| parent | 6bab265109546396730d84a4189610eca094c62a (diff) | |
| download | hare-tui-e074c936bb99ccfce311445f4dbf42ba964b44a4.tar.gz | |
Implement global state and clear scheduling
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)!; +}; |
