mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
Merge remote-tracking branch 'Wunkolo/feat/windows-colors' into master
This commit is contained in:
@@ -9,7 +9,7 @@ cpufetch currently supports x86 CPUs (both Intel and AMD CPUs)
|
||||
| Platform | Intel | AMD | Notes |
|
||||
|:---------:|:-------------------------:|:------------------------:|:-----------------:|
|
||||
| Linux | :heavy_check_mark: | :heavy_check_mark: | Prefered platform |
|
||||
| Windows | :heavy_check_mark: | :heavy_check_mark: | Some information may be missing. <br> No colors and worse CPU art |
|
||||
| Windows | :heavy_check_mark: | :heavy_check_mark: | Some information may be missing. <br> Colors will be used if supported |
|
||||
| macOS | :heavy_exclamation_mark: | :heavy_exclamation_mark: | Untested |
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
#include "cpuid.h"
|
||||
#include "uarch.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#define COL_NONE ""
|
||||
#define COL_INTEL_FANCY_1 "\x1b[46;1m"
|
||||
#define COL_INTEL_FANCY_2 "\x1b[47;1m"
|
||||
@@ -161,9 +166,22 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style, struct colors* cs) {
|
||||
}
|
||||
art->ascii_chars[1] = '#';
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE std_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD console_mode;
|
||||
|
||||
// Attempt to enable the VT100-processing flag
|
||||
GetConsoleMode(std_handle, &console_mode);
|
||||
SetConsoleMode(std_handle, console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||
// Get the console mode flag again, to see if it successfully enabled it
|
||||
GetConsoleMode(std_handle, &console_mode);
|
||||
#endif
|
||||
|
||||
if(style == STYLE_EMPTY) {
|
||||
#ifdef _WIN32
|
||||
art->style = STYLE_LEGACY;
|
||||
// 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;
|
||||
#else
|
||||
art->style = STYLE_FANCY;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user