aboutsummaryrefslogtreecommitdiff
path: root/modules/TUI/windows.jai
diff options
context:
space:
mode:
authordam <dam@gudinoff>2024-05-05 02:34:33 +0100
committerdam <dam@gudinoff>2024-05-05 02:34:33 +0100
commit36af624cdd9cb54454587bfae21b30096986d22e (patch)
tree89fb9d3eb79ff68f047bd30dbcb680e6dce8abc3 /modules/TUI/windows.jai
parentcb6c3caaa285bc8bd12c356d57bbfad86d70c0eb (diff)
downloadtask-time-tracker-36af624cdd9cb54454587bfae21b30096986d22e.tar.zst
task-time-tracker-36af624cdd9cb54454587bfae21b30096986d22e.zip
WIP : Cleanup TUI module and improved assert/error messages.
Diffstat (limited to 'modules/TUI/windows.jai')
-rw-r--r--modules/TUI/windows.jai34
1 files changed, 17 insertions, 17 deletions
diff --git a/modules/TUI/windows.jai b/modules/TUI/windows.jai
index fb50e49..f8d8bc8 100644
--- a/modules/TUI/windows.jai
+++ b/modules/TUI/windows.jai
@@ -142,7 +142,7 @@ peek_input :: () -> INPUT_RECORD, success := true {
records_read: u32;
if PeekConsoleInputW(stdin, *record, 1, *records_read) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to peek input: code %, %", error_code, error_string);
+ log_tui_error("Failed to peek input: code %, %", error_code, error_string);
return record, false;
}
return record;
@@ -153,7 +153,7 @@ read_input :: () -> INPUT_RECORD, success := true {
records_read: u32;
if ReadConsoleInputW(stdin, *record, 1, *records_read) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to read input: code %, %", error_code, error_string);
+ log_tui_error("Failed to read input: code %, %", error_code, error_string);
return record, false;
}
return record;
@@ -163,7 +163,7 @@ count_input :: () -> u32, success := true {
count: u32;
if GetNumberOfConsoleInputEvents(stdin, *count) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to count input: code %, %", error_code, error_string);
+ log_tui_error("Failed to count input: code %, %", error_code, error_string);
return 0, false;
}
return count;
@@ -171,7 +171,7 @@ count_input :: () -> u32, success := true {
////////////////////////////////////////////////////////////////////////////////
-#scope_export
+#scope_module
OS_prepare_terminal :: () -> success := true {
@@ -179,12 +179,12 @@ OS_prepare_terminal :: () -> success := true {
stdin = GetStdHandle(STD_INPUT_HANDLE);
if stdin == INVALID_HANDLE_VALUE {
error_code, error_string := get_error_value_and_string();
- log_error("Invalid input handler: code %, %", error_code, error_string);
+ log_tui_error("Invalid input handler: code %, %", error_code, error_string);
return false;
}
if xx GetConsoleMode(stdin, *initial_stdin_mode) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to get input mode: code %, %", error_code, error_string);
+ log_tui_error("Failed to get input mode: code %, %", error_code, error_string);
return false;
}
raw_stdin_mode = (cast(Console_Input_Mode) initial_stdin_mode);
@@ -193,7 +193,7 @@ OS_prepare_terminal :: () -> success := true {
if xx SetConsoleMode(stdin, xx raw_stdin_mode) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to set input mode: code %, %", error_code, error_string);
+ log_tui_error("Failed to set input mode: code %, %", error_code, error_string);
return false;
}
@@ -201,12 +201,12 @@ OS_prepare_terminal :: () -> success := true {
stdout = GetStdHandle(STD_OUTPUT_HANDLE);
if stdout == INVALID_HANDLE_VALUE {
error_code, error_string := get_error_value_and_string();
- log_error("Invalid output handler: code %, %", error_code, error_string);
+ log_tui_error("Invalid output handler: code %, %", error_code, error_string);
return false;
}
if xx GetConsoleMode(stdout, *initial_stdout_mode) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to get output mode: code %, %", error_code, error_string);
+ log_tui_error("Failed to get output mode: code %, %", error_code, error_string);
return false;
}
raw_stdout_mode = (cast(Console_Output_Mode) initial_stdout_mode);
@@ -214,7 +214,7 @@ OS_prepare_terminal :: () -> success := true {
if xx SetConsoleMode(stdout, xx raw_stdout_mode) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to set output mode: code %, %", error_code, error_string);
+ log_tui_error("Failed to set output mode: code %, %", error_code, error_string);
return false;
}
@@ -231,12 +231,12 @@ OS_prepare_terminal :: () -> success := true {
OS_reset_terminal :: () -> success := true {
if xx SetConsoleMode(stdin, initial_stdin_mode) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to reset input mode: code %, %", error_code, error_string);
+ log_tui_error("Failed to reset input mode: code %, %", error_code, error_string);
return false;
}
if xx SetConsoleMode(stdout, initial_stdout_mode) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to reset output mode: code %, %", error_code, error_string);
+ log_tui_error("Failed to reset output mode: code %, %", error_code, error_string);
return false;
}
return;
@@ -247,7 +247,7 @@ OS_flush_input :: () {
// Attempting to empty the input queue all at once can destroy state in the queue in an unexpected manner.
if FlushConsoleInputBuffer(stdin) == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to flush input: code %, %", error_code, error_string);
+ log_tui_error("Failed to flush input: code %, %", error_code, error_string);
}
}
@@ -255,7 +255,7 @@ OS_read_input :: (buffer: *u8, bytes_to_read: s64) -> bytes_read: s64, success :
S32_MAX :: 0x7fff_ffff;
if (bytes_to_read > S32_MAX) {
- log_error("The Windows API only allows to read up to 2^32 bytes from the standard input. Clamping input argument.");
+ log_tui_error("The Windows API only allows to read up to 2^32 bytes from the standard input. Clamping input argument.");
bytes_to_read = S32_MAX;
}
@@ -288,14 +288,14 @@ OS_read_input :: (buffer: *u8, bytes_to_read: s64) -> bytes_read: s64, success :
success = ReadConsoleW(stdin, widechar_view.data, chars_to_read, *widechar_view.count, null);
if success == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to read console: code %, %", error_code, error_string);
+ log_tui_error("Failed to read console: code %, %", error_code, error_string);
return 0, false;
}
result:, success = wide_to_utf8_new(widechar_view.data, xx widechar_view.count);
if success == false {
error_code, error_string := get_error_value_and_string();
- log_error("Failed to convert from wide to utf8: code %, %", error_code, error_string);
+ log_tui_error("Failed to convert from wide to UTF8: code %, %", error_code, error_string);
return 0, false;
}
@@ -338,7 +338,7 @@ OS_wait_for_input :: (timeout_milliseconds: s32 = -1) -> is_input_available: boo
if wait_result == WAIT_FAILED {
error_code, error_string := get_error_value_and_string();
- log_error("Error while waiting for input: code %, %", error_code, error_string);
+ log_tui_error("Error while waiting for input: code %, %", error_code, error_string);
return false, false;
}