summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorZuBsPaCe <kurt.rudin@gmx.net>2015-11-19 14:31:01 +0100
committerZuBsPaCe <kurt.rudin@gmx.net>2015-11-19 15:19:22 +0100
commit42beb83178f923f8dcaeb30ab8592c8540435c3c (patch)
tree8ecee466f4338f790d89c31ec286d49062e7b499 /platform/windows
parenta89c86193161797c59165799232b6aeba6076760 (diff)
Set console background color on windows in SetConsoleTextAttribute, otherwise text background will be black, which looks strange if the terminal color is not black.
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/os_windows.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index d919485e7a..e25afb75d6 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -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
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;
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;
}
+ basecol |= current_bg;
+
if (p_rationale && p_rationale[0]) {
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;
}
- SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
+ SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY);
print(" %s\n", p_rationale);
SetConsoleTextAttribute(hCon, basecol);
print("At: ");
- SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
+ SetConsoleTextAttribute(hCon, current_fg | current_bg);
print(" %s:%i\n", p_file, p_line);
} 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;
}
- SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
+ SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY);
print(" %s\n", p_code);
SetConsoleTextAttribute(hCon, basecol);
print("At: ");
- SetConsoleTextAttribute(hCon, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
+ SetConsoleTextAttribute(hCon, current_fg | current_bg);
print(" %s:%i\n", p_file, p_line);
}