mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
[v0.99] Initial idea to allow printing non-fixed sized logos (each logo with a different w/h)
This commit is contained in:
@@ -4,6 +4,12 @@
|
|||||||
#define NUMBER_OF_LINES 19
|
#define NUMBER_OF_LINES 19
|
||||||
#define LINE_SIZE 62
|
#define LINE_SIZE 62
|
||||||
|
|
||||||
|
struct ascii_logo {
|
||||||
|
char* art;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
|
||||||
#define AMD_ASCII \
|
#define AMD_ASCII \
|
||||||
" \
|
" \
|
||||||
\
|
\
|
||||||
@@ -25,6 +31,8 @@
|
|||||||
\
|
\
|
||||||
"
|
"
|
||||||
|
|
||||||
|
// 1 2 3 4 5 6
|
||||||
|
//3456789012345678901234567890123456789012345678901234567890
|
||||||
#define INTEL_ASCII \
|
#define INTEL_ASCII \
|
||||||
" ################ \
|
" ################ \
|
||||||
####### ####### \
|
####### ####### \
|
||||||
@@ -215,18 +223,7 @@
|
|||||||
\
|
\
|
||||||
\
|
\
|
||||||
"
|
"
|
||||||
|
static struct ascii_logo logo_intel = { INTEL_ASCII, 62, 19 };
|
||||||
static const char* ASCII_ARRAY [] = {
|
static struct ascii_logo logo_amd = { AMD_ASCII, 62, 19 };
|
||||||
AMD_ASCII,
|
|
||||||
INTEL_ASCII,
|
|
||||||
ARM_ASCII,
|
|
||||||
SNAPDRAGON_ASCII,
|
|
||||||
MEDIATEK_ASCII,
|
|
||||||
EXYNOS_ASCII,
|
|
||||||
KIRIN_ASCII,
|
|
||||||
BROADCOM_ASCII,
|
|
||||||
IBM_ASCII,
|
|
||||||
UNKNOWN_ASCII
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ struct attribute {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ascii {
|
struct ascii {
|
||||||
char art[NUMBER_OF_LINES][LINE_SIZE+1];
|
struct ascii_logo* art;
|
||||||
char color1_ascii[100];
|
char color1_ascii[100];
|
||||||
char color2_ascii[100];
|
char color2_ascii[100];
|
||||||
char color1_text[100];
|
char color1_text[100];
|
||||||
@@ -166,8 +166,8 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct color** cs) {
|
|||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
if(art->vendor == CPU_VENDOR_INTEL) {
|
if(art->vendor == CPU_VENDOR_INTEL) {
|
||||||
COL_FANCY_1 = COLOR_BG_CYAN;
|
COL_FANCY_1 = COLOR_FG_CYAN;
|
||||||
COL_FANCY_2 = COLOR_BG_WHITE;
|
COL_FANCY_2 = COLOR_FG_WHITE;
|
||||||
COL_FANCY_3 = COLOR_FG_CYAN;
|
COL_FANCY_3 = COLOR_FG_CYAN;
|
||||||
COL_FANCY_4 = COLOR_FG_WHITE;
|
COL_FANCY_4 = COLOR_FG_WHITE;
|
||||||
art->ascii_chars[0] = '#';
|
art->ascii_chars[0] = '#';
|
||||||
@@ -278,8 +278,8 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct color** cs) {
|
|||||||
break;
|
break;
|
||||||
case STYLE_FANCY:
|
case STYLE_FANCY:
|
||||||
if(cs != NULL) {
|
if(cs != NULL) {
|
||||||
COL_FANCY_1 = rgb_to_ansi(cs[0], true, true);
|
COL_FANCY_1 = rgb_to_ansi(cs[0], false, true);
|
||||||
COL_FANCY_2 = rgb_to_ansi(cs[1], true, true);
|
COL_FANCY_2 = rgb_to_ansi(cs[1], false, true);
|
||||||
COL_FANCY_3 = rgb_to_ansi(cs[2], false, true);
|
COL_FANCY_3 = rgb_to_ansi(cs[2], false, true);
|
||||||
COL_FANCY_4 = rgb_to_ansi(cs[3], false, true);
|
COL_FANCY_4 = rgb_to_ansi(cs[3], false, true);
|
||||||
}
|
}
|
||||||
@@ -323,9 +323,9 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct color** cs) {
|
|||||||
char tmp[NUMBER_OF_LINES * LINE_SIZE + 1];
|
char tmp[NUMBER_OF_LINES * LINE_SIZE + 1];
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
if(art->vendor == CPU_VENDOR_INTEL)
|
if(art->vendor == CPU_VENDOR_INTEL)
|
||||||
strcpy(tmp, INTEL_ASCII);
|
art->art = &logo_intel;
|
||||||
else if(art->vendor == CPU_VENDOR_AMD)
|
else if(art->vendor == CPU_VENDOR_AMD)
|
||||||
strcpy(tmp, AMD_ASCII);
|
art->art = &logo_amd;
|
||||||
else
|
else
|
||||||
strcpy(tmp, UNKNOWN_ASCII);
|
strcpy(tmp, UNKNOWN_ASCII);
|
||||||
#elif ARCH_PPC
|
#elif ARCH_PPC
|
||||||
@@ -345,9 +345,6 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct color** cs) {
|
|||||||
strcpy(tmp, ARM_ASCII);
|
strcpy(tmp, ARM_ASCII);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(int i=0; i < NUMBER_OF_LINES; i++)
|
|
||||||
memcpy(art->art[i], tmp + i*LINE_SIZE, LINE_SIZE);
|
|
||||||
|
|
||||||
return art;
|
return art;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,39 +364,14 @@ uint32_t longest_attribute_length(struct ascii* art) {
|
|||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
void print_algorithm_intel(struct ascii* art, int n, bool* flag) {
|
void print_algorithm_intel(struct ascii* art, int n, bool* flag) {
|
||||||
for(int i=0; i < LINE_SIZE; i++) {
|
struct ascii_logo* logo = art->art;
|
||||||
if(*flag) {
|
|
||||||
if(art->art[n][i] == ' ') {
|
for(int i=0; i < logo->width; i++) {
|
||||||
*flag = false;
|
printf("%s%c%s", art->color1_ascii, logo->art[n * logo->width + i], art->reset);
|
||||||
printf("%s%c%s", art->color2_ascii, art->ascii_chars[1], art->reset);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(art->art[n][i] != ' ' && art->art[n][i] != '\0') {
|
|
||||||
*flag = true;
|
|
||||||
printf("%c",' ');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("%c",' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_algorithm_amd(struct ascii* art, int n, bool* flag) {
|
void print_algorithm_amd(struct ascii* art, int n, bool* flag) {
|
||||||
*flag = false; // dummy, just silence compiler error
|
|
||||||
|
|
||||||
for(int i=0; i < LINE_SIZE; i++) {
|
|
||||||
if(art->art[n][i] == '@')
|
|
||||||
printf("%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset);
|
|
||||||
else if(art->art[n][i] == '#')
|
|
||||||
printf("%s%c%s", art->color2_ascii, art->ascii_chars[1], art->reset);
|
|
||||||
else
|
|
||||||
printf("%c",art->art[n][i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii_x86(struct ascii* art, uint32_t la, void (*callback_print_algorithm)(struct ascii* art, int i, bool* flag)) {
|
void print_ascii_x86(struct ascii* art, uint32_t la, void (*callback_print_algorithm)(struct ascii* art, int i, bool* flag)) {
|
||||||
@@ -814,14 +786,7 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct color** cs) {
|
|||||||
|
|
||||||
bool print_cpufetch(struct cpuInfo* cpu, STYLE s, struct color** cs) {
|
bool print_cpufetch(struct cpuInfo* cpu, STYLE s, struct color** cs) {
|
||||||
// Sanity check of ASCII arts
|
// Sanity check of ASCII arts
|
||||||
int len = sizeof(ASCII_ARRAY) / sizeof(ASCII_ARRAY[0]);
|
// TODO with new logos
|
||||||
for(int i=0; i < len; i++) {
|
|
||||||
const char* ascii = ASCII_ARRAY[i];
|
|
||||||
if(strlen(ascii) != (NUMBER_OF_LINES * LINE_SIZE)) {
|
|
||||||
printBug("ASCII art %d is wrong! ASCII length: %d, expected length: %d", i, strlen(ascii), (NUMBER_OF_LINES * LINE_SIZE));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
return print_cpufetch_x86(cpu, s, cs);
|
return print_cpufetch_x86(cpu, s, cs);
|
||||||
|
|||||||
Reference in New Issue
Block a user