You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Set console background color on windows in SetConsoleTextAttribute, otherwise text background will be black, which looks strange if the terminal color is not black.
This commit is contained in:
@@ -1796,7 +1796,8 @@ void OS_Windows::print_error(const char* p_function, const char* p_file, int p_l
|
|||||||
CONSOLE_SCREEN_BUFFER_INFO sbi; //original
|
CONSOLE_SCREEN_BUFFER_INFO sbi; //original
|
||||||
GetConsoleScreenBufferInfo(hCon, &sbi);
|
GetConsoleScreenBufferInfo(hCon, &sbi);
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, sbi.wAttributes);
|
WORD current_fg = sbi.wAttributes & (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
|
||||||
|
WORD current_bg = sbi.wAttributes & (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
|
||||||
|
|
||||||
uint32_t basecol = 0;
|
uint32_t basecol = 0;
|
||||||
switch(p_type) {
|
switch(p_type) {
|
||||||
@@ -1805,6 +1806,8 @@ void OS_Windows::print_error(const char* p_function, const char* p_file, int p_l
|
|||||||
case ERR_SCRIPT: basecol = FOREGROUND_RED | FOREGROUND_BLUE; break;
|
case ERR_SCRIPT: basecol = FOREGROUND_RED | FOREGROUND_BLUE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
basecol |= current_bg;
|
||||||
|
|
||||||
if (p_rationale && p_rationale[0]) {
|
if (p_rationale && p_rationale[0]) {
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY);
|
SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY);
|
||||||
@@ -1814,13 +1817,13 @@ void OS_Windows::print_error(const char* p_function, const char* p_file, int p_l
|
|||||||
case ERR_SCRIPT: print("SCRIPT ERROR: "); break;
|
case ERR_SCRIPT: print("SCRIPT ERROR: "); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY);
|
||||||
print(" %s\n", p_rationale);
|
print(" %s\n", p_rationale);
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, basecol);
|
SetConsoleTextAttribute(hCon, basecol);
|
||||||
print("At: ");
|
print("At: ");
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
|
SetConsoleTextAttribute(hCon, current_fg | current_bg);
|
||||||
print(" %s:%i\n", p_file, p_line);
|
print(" %s:%i\n", p_file, p_line);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -1832,13 +1835,13 @@ void OS_Windows::print_error(const char* p_function, const char* p_file, int p_l
|
|||||||
case ERR_SCRIPT: print("SCRIPT ERROR: %s: ", p_function); break;
|
case ERR_SCRIPT: print("SCRIPT ERROR: %s: ", p_function); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY);
|
||||||
print(" %s\n", p_code);
|
print(" %s\n", p_code);
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, basecol);
|
SetConsoleTextAttribute(hCon, basecol);
|
||||||
print("At: ");
|
print("At: ");
|
||||||
|
|
||||||
SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
|
SetConsoleTextAttribute(hCon, current_fg | current_bg);
|
||||||
print(" %s:%i\n", p_file, p_line);
|
print(" %s:%i\n", p_file, p_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user