aboutsummaryrefslogtreecommitdiff
path: root/TUI/unix.jai
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-12-08 03:08:31 +0000
committerdam <dam@gudinoff>2023-12-08 03:08:31 +0000
commitc61e13ae21cbac7b6642d2d813245c7fc0575834 (patch)
treed978514d403f8de762b37bc566385168c9b460a0 /TUI/unix.jai
parent53f82bca92edbe4a8883c713c30d5ac81897a43f (diff)
downloadtask-time-tracker-c61e13ae21cbac7b6642d2d813245c7fc0575834.tar.zst
task-time-tracker-c61e13ae21cbac7b6642d2d813245c7fc0575834.zip
Made get_terminal_size and get_cursor_position more robust.
Diffstat (limited to 'TUI/unix.jai')
-rw-r--r--TUI/unix.jai8
1 files changed, 8 insertions, 0 deletions
diff --git a/TUI/unix.jai b/TUI/unix.jai
index fb79f86..73a763a 100644
--- a/TUI/unix.jai
+++ b/TUI/unix.jai
@@ -25,6 +25,9 @@
// https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/tcgetattr.c.html
tcgetattr :: (fd: s32, termios_p: *Terminal_IO_Mode) -> s32 #foreign libc;
+ // https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/tcflush.c.html
+ tcflush :: (fd: s32, queue_selector: s32) -> s32 #foreign libc;
+
// Information for the termios.h enums is platform dependent and was retrieved from:
// https://elixir.bootlin.com/glibc/latest/source/sysdeps/unix/sysv/linux/bits/termios.h
@@ -169,6 +172,11 @@ restore_resize_handler :: () {
#scope_export
+OS_flush_input :: inline () {
+ TCIFLUSH :: 0; // TODO Is this always zero in all systems?
+ tcflush(STDIN_FILENO, TCIFLUSH);
+}
+
OS_prepare_terminal :: () {
tcgetattr(STDIN_FILENO, *initial_tio_mode); // TODO Log on error.
raw_tio_mode = initial_tio_mode;