mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
Fix bug in Windows where specifying a style while using a terminal that supports color does not enable the color support, so colors do not show correctly
This commit is contained in:
@@ -166,16 +166,21 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style, struct colors* cs) {
|
|||||||
}
|
}
|
||||||
art->ascii_chars[1] = '#';
|
art->ascii_chars[1] = '#';
|
||||||
|
|
||||||
if(style == STYLE_EMPTY) {
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE std_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE std_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
DWORD console_mode;
|
DWORD console_mode;
|
||||||
|
|
||||||
// Attempt to enable the VT100-processing flag
|
// Attempt to enable the VT100-processing flag
|
||||||
GetConsoleMode(std_handle, &console_mode);
|
GetConsoleMode(std_handle, &console_mode);
|
||||||
SetConsoleMode(std_handle, console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
SetConsoleMode(std_handle, console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||||
// Get the console mode flag again, to see if it successfully enabled it
|
// Get the console mode flag again, to see if it successfully enabled it
|
||||||
GetConsoleMode(std_handle, &console_mode);
|
GetConsoleMode(std_handle, &console_mode);
|
||||||
// Enable fancy mode if VT100-processing is enabled
|
#endif
|
||||||
|
|
||||||
|
if(style == STYLE_EMPTY) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Use fancy style if VT100-processing is enabled,
|
||||||
|
// or legacy style in other case
|
||||||
art->style = (console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) ? STYLE_FANCY : STYLE_LEGACY;
|
art->style = (console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) ? STYLE_FANCY : STYLE_LEGACY;
|
||||||
#else
|
#else
|
||||||
art->style = STYLE_FANCY;
|
art->style = STYLE_FANCY;
|
||||||
|
|||||||
Reference in New Issue
Block a user