File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 10
10
#include < windows.h>
11
11
#include < fcntl.h>
12
12
#include < io.h>
13
+ #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
14
+ #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
15
+ #endif
13
16
#else
14
17
#include < climits>
15
18
#include < sys/ioctl.h>
@@ -68,9 +71,10 @@ namespace console {
68
71
}
69
72
}
70
73
if (hConsole) {
71
- // Enable ANSI colors on Windows 10+
72
- if (advanced_display && !(dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)) {
73
- SetConsoleMode (hConsole, dwMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
74
+ // Check conditions combined to reduce nesting
75
+ if (advanced_display && !(dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) &&
76
+ !SetConsoleMode (hConsole, dwMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) {
77
+ advanced_display = false ;
74
78
}
75
79
// Set console output codepage to UTF8
76
80
SetConsoleOutputCP (CP_UTF8);
You can’t perform that action at this time.
0 commit comments