From c61e13ae21cbac7b6642d2d813245c7fc0575834 Mon Sep 17 00:00:00 2001 From: dam Date: Fri, 8 Dec 2023 03:08:31 +0000 Subject: Made get_terminal_size and get_cursor_position more robust. --- TUI/unix.jai | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'TUI/unix.jai') 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; -- cgit v1.2.3