aboutsummaryrefslogtreecommitdiff
path: root/TUI/module.jai
diff options
context:
space:
mode:
Diffstat (limited to 'TUI/module.jai')
-rw-r--r--TUI/module.jai30
1 files changed, 20 insertions, 10 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);
}