diff options
Diffstat (limited to 'libui/libui.ha')
| -rw-r--r-- | libui/libui.ha | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libui/libui.ha b/libui/libui.ha index 7e40a9d..b0d0ea3 100644 --- a/libui/libui.ha +++ b/libui/libui.ha @@ -37,11 +37,21 @@ export fn init() ttyui = { tty::makeraw(&term)!; tty::noecho(&term)!; - return ttyui { + let ui = ttyui { term = term, f = f, listeners = [], }; + hidecursor(ui); + return ui; +}; + +export fn hidecursor(ui: ttyui) void = { + print(ui, "\x1B[?25l"); +}; + +export fn showcursor(ui: ttyui) void = { + print(ui, "\x1B[?25h"); }; // Returns the window size for the given ttyui. @@ -51,6 +61,7 @@ export fn getwinsize(ui: ttyui) (tty::ttysize | tty::error) = { // Suspend the UI. To restore it, use [[resume]]. export fn suspend(ui: *ttyui) void = { + showcursor(*ui); tty::termios_restore(&ui.term); }; @@ -58,11 +69,13 @@ export fn suspend(ui: *ttyui) void = { export fn resume(ui: *ttyui) void = { tty::makeraw(&ui.term)!; tty::noecho(&ui.term)!; + hidecursor(*ui); }; // Restores the UI state and closes and frees the resources associated with the // given ttyui. export fn finish(ui: *ttyui) void = { + showcursor(*ui); tty::termios_restore(&ui.term); io::close(ui.f)!; free(ui.listeners); |
