Fix color codes

This commit is contained in:
Krzosa Karol
2023-04-14 21:13:30 +02:00
parent 44b0bededa
commit 542f2e0297
5 changed files with 5 additions and 4 deletions

View File

@@ -16,7 +16,6 @@ static void core_init_compiler(Core_Ctx *ctx, Allocator *allocator) {
ctx->emit_type_info = true; ctx->emit_type_info = true;
ctx->emit_line_directives = false; ctx->emit_line_directives = false;
ctx->debugger_break_on_compiler_error = true; ctx->debugger_break_on_compiler_error = true;
ctx->color_codes_enabled = true;
ctx->same_scope_token = {SAME_SCOPE}; ctx->same_scope_token = {SAME_SCOPE};
arena_init(&ctx->perm_push_only, "Perm Push Only"_s); arena_init(&ctx->perm_push_only, "Perm Push Only"_s);

View File

@@ -71,7 +71,6 @@ struct Core_Ctx {
F64 start; F64 start;
} time; } time;
bool color_codes_enabled;
bool debugger_break_on_compiler_error; bool debugger_break_on_compiler_error;
// Codegen stage mostly // Codegen stage mostly

View File

@@ -82,7 +82,7 @@ static void compiler_error(Token *token1, Token *token2, const char *str, ...) {
STRING_FMT(pctx->perm, str, string); STRING_FMT(pctx->perm, str, string);
Core_Message *msg = core_add_message(CORE_ERROR, string, token1, token2); Core_Message *msg = core_add_message(CORE_ERROR, string, token1, token2);
if (pctx->debugger_break_on_compiler_error) { if (pctx->debugger_break_on_compiler_error) {
String str = core_stringify_message(pctx, pctx->perm, msg, pctx->color_codes_enabled); String str = core_stringify_message(pctx, pctx->perm, msg, GLOBAL_EnabledConsoleColors);
printf("%s", str.str); // @! How to get rid of printf ? printf("%s", str.str); // @! How to get rid of printf ?
fflush(stdout); fflush(stdout);
Breakpoint; Breakpoint;
@@ -94,7 +94,7 @@ compiler_error(Token *token, const char *str, ...) {
STRING_FMT(pctx->perm, str, string); STRING_FMT(pctx->perm, str, string);
Core_Message *msg = core_add_message(CORE_ERROR, string, token); Core_Message *msg = core_add_message(CORE_ERROR, string, token);
if (pctx->debugger_break_on_compiler_error) { if (pctx->debugger_break_on_compiler_error) {
String str = core_stringify_message(pctx, pctx->perm, msg, pctx->color_codes_enabled); String str = core_stringify_message(pctx, pctx->perm, msg, GLOBAL_EnabledConsoleColors);
printf("%s", str.str); // @! How to get rid of printf ? printf("%s", str.str); // @! How to get rid of printf ?
fflush(stdout); fflush(stdout);
Breakpoint; Breakpoint;

1
info.bat Normal file
View File

@@ -0,0 +1 @@
cloc *.hpp *.cpp *.py *.h

View File

@@ -215,6 +215,7 @@ os_list_dir(Arena *scratch, Allocator *a, String dir, U32 flags = LIST_NO_FLAGS)
return result; return result;
} }
bool GLOBAL_EnabledConsoleColors;
bool os_enable_console_colors() { bool os_enable_console_colors() {
// Set output mode to handle virtual terminal sequences // Set output mode to handle virtual terminal sequences
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -223,6 +224,7 @@ bool os_enable_console_colors() {
if (GetConsoleMode(hOut, &dwMode)) { if (GetConsoleMode(hOut, &dwMode)) {
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (SetConsoleMode(hOut, dwMode)) { if (SetConsoleMode(hOut, dwMode)) {
GLOBAL_EnabledConsoleColors = true;
return true; return true;
} }
else { else {