aboutsummaryrefslogtreecommitdiff
path: root/TUI
diff options
context:
space:
mode:
Diffstat (limited to 'TUI')
-rw-r--r--TUI/module.jai30
-rw-r--r--TUI/unix.jai4
2 files changed, 22 insertions, 12 deletions
diff --git a/TUI/module.jai b/TUI/module.jai
index f113c2a..6854d59 100644
--- a/TUI/module.jai
+++ b/TUI/module.jai
@@ -102,6 +102,7 @@ key_semaphore: Semaphore;
key_mutex: Mutex;
key_input := Keys.None;
key_resize := Keys.None;
+key_buffer: [64] Keys;
// Notes
// So, the semaphore usage should indicate the items on the key_queue.
@@ -111,8 +112,11 @@ dam :: (msg: string) {
print(msg, to_standard_error = true);
}
+
process_input :: (thread: *Thread) -> s64 {
- char: u8;
+ buffer: [64] u8;
+ input: string;
+ // char: u8;
dam(">START signal_input\n");
defer dam(">STOP signal_input\n");
while(true) {
@@ -123,17 +127,20 @@ process_input :: (thread: *Thread) -> s64 {
dam("!\n\r");
continue;
}
- dam("reading..");
- bytes_read := OS_read_input(*char, 1);
- dam("!\n\r");
- if bytes_read > 0 {
+ if input.count > 0 {
lock(*key_mutex);
- defer unlock(*key_mutex);
- key_input = xx char;
- dam("signaling..");
- dam("!\n\r");
+ key_input = xx input[0];
+ unlock(*key_mutex);
signal(*key_semaphore);
+
+ advance(*input);
+ continue;
}
+
+ // dam("reading..");
+ bytes_read := OS_read_input(buffer.data, buffer.count);
+ input.data = buffer.data;
+ input.count = bytes_read;
}
return 0;
}
@@ -213,9 +220,12 @@ stop :: () {
restore_handler(); // TODO Move to beter place.
+ print(">A<");
thread_deinit(*input_process_thread);
+ print(">B<");
destroy(*key_semaphore);
-
+
+ print(">C<");
OS_reset_terminal();
write_strings(Commands.EnterMainBuffer, Commands.RestoreCursorPosition, Commands.ShowCursor);
}
diff --git a/TUI/unix.jai b/TUI/unix.jai
index 523aeb5..1bfa400 100644
--- a/TUI/unix.jai
+++ b/TUI/unix.jai
@@ -135,8 +135,8 @@ OS_prepare_terminal :: () {
raw_tio_mode.c_lflag &= ~(.ECHO | .ECHONL | .ICANON | .ISIG | .IEXTEN);
raw_tio_mode.c_cflag &= ~(.CSIZE | .PARENB);
raw_tio_mode.c_cflag |= .CS8;
- raw_tio_mode.c_cc[Control_Chars.VMIN] = 1;
- raw_tio_mode.c_cc[Control_Chars.VTIME] = 0;
+ raw_tio_mode.c_cc[Control_Chars.VMIN] = 0;
+ raw_tio_mode.c_cc[Control_Chars.VTIME] = 1;
tcsetattr(STDIN_FILENO, 0, *raw_tio_mode); // TODO Log on error.
}