aboutsummaryrefslogtreecommitdiff
path: root/modules/TUI/module.jai
diff options
context:
space:
mode:
authordam <dam@gudinoff>2024-04-30 00:05:26 +0100
committerdam <dam@gudinoff>2024-04-30 00:05:26 +0100
commitd7c2c312fe2ac08cadc3534a0a35357ef50cca20 (patch)
treecfaa0289011dfe5e33e55e78c5fffa4e4ea0663e /modules/TUI/module.jai
parent1f2afe4db186342bda551e96bcd1d9b029d7c5ba (diff)
downloadtask-time-tracker-d7c2c312fe2ac08cadc3534a0a35357ef50cca20.tar.zst
task-time-tracker-d7c2c312fe2ac08cadc3534a0a35357ef50cca20.zip
WIP : Add logger and cleanup TUI module.
Diffstat (limited to 'modules/TUI/module.jai')
-rw-r--r--modules/TUI/module.jai38
1 files changed, 25 insertions, 13 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai
index 5fd29f6..121aa42 100644
--- a/modules/TUI/module.jai
+++ b/modules/TUI/module.jai
@@ -2,6 +2,9 @@
#scope_file
+// - fix/implement/finish `TODO` on `TUI\module` (use some sort of buffet to reduce io/print calls)
+// - fix/implement/finish `TODO` on `TUI\module` (use `dirty_bit_flag` to only update ehat has been changed)
+
#if OS == {
case .LINUX;
#load "unix.jai";
@@ -525,16 +528,17 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key {
return result, key;
}
-start :: () {
+start :: () -> success := true #must {
if active == true return;
- // TODO Should start() call flush_input internally?
-
- setup_key_map(); // TODO This is being called multiple times... please fix me!
-
input_string.data = input_buffer.data;
input_string.count = 0;
input_override = xx Keys.None;
+
+ previous_logger = context.logger;
+ context.logger = module_logger;
+
+ setup_key_map();
write_strings(
Commands.HideCursor,
@@ -542,26 +546,34 @@ start :: () {
Commands.AlternateScreenBuffer,
Commands.EncodingUTF8,
Commands.CursorNormalMode,
- Commands.KeypadNumMode);
-
- previous_logger = context.logger;
- context.logger = module_logger;
+ Commands.KeypadNumMode
+ );
- OS_prepare_terminal();
+ if !OS_prepare_terminal() then return false;
active = true;
+
+ return;
}
-stop :: () {
+stop :: () -> success := true #must {
if active == false return;
+
active = false;
clear_style();
- OS_reset_terminal();
+
+ if !OS_reset_terminal() then return false;
context.logger = previous_logger;
- write_strings(Commands.MainScreenBuffer, Commands.RestoreCursorPosition, Commands.ShowCursor);
+ write_strings(
+ Commands.MainScreenBuffer,
+ Commands.RestoreCursorPosition,
+ Commands.ShowCursor
+ );
+
+ return;
}
flush_input :: () {