From 16a706d3c5c50b28ffa5706e4f707f38cb60d2dd Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Wed, 7 Sep 2022 19:50:10 +0200 Subject: [PATCH] Seperate color config of title and keys --- src/common/init.c | 4 +- src/common/printing.c | 2 +- src/data/config_user.txt | 13 +++- src/data/help.txt | 4 +- src/fastfetch.c | 9 ++- src/fastfetch.h | 5 +- src/logo/builtin.c | 134 +++++++++++++++++++++++++++++++++++++-- src/logo/logo.c | 19 +++--- src/logo/logo.h | 2 + src/modules/title.c | 2 +- 10 files changed, 172 insertions(+), 22 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index f304ac429..1ce13deea 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -138,7 +138,9 @@ static void defaultConfig(FFinstance* instance) instance->config.logo.paddingRight = 4; instance->config.logo.printRemaining = true; - ffStrbufInit(&instance->config.mainColor); + ffStrbufInit(&instance->config.colorKeys); + ffStrbufInit(&instance->config.colorTitle); + ffStrbufInit(&instance->config.separator); ffStrbufAppendS(&instance->config.separator, ": "); diff --git a/src/common/printing.c b/src/common/printing.c index 552328d53..a6911db15 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -12,7 +12,7 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod if(!instance->config.pipe) { fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintColor(&instance->config.mainColor); + ffPrintColor(&instance->config.colorKeys); } //NULL check is required for modules with custom keys, e.g. disk with the folder path diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 5ef991765..a5bc431aa 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -113,12 +113,19 @@ # Default is true. #--logo-print-remaining true -# Color option: +# Color keys option: # Sets the color of the keys. # Must be linux console color codes or the name of a color. -# Default is the primary color of the logo. +# Default is the key color of the logo. # Use "fastfetch --help color" to learn more and see examples. -#--color magenta +#--color-keys magenta + +# Color title option: +# Sets the color of the title. +# Must be linux console color codes or the name of a color. +# Default is the title color of the logo. +# Use "fastfetch --help color" to learn more and see examples. +#--color-title magenta # Binary prefix option: # Sets the binary prefix to use. diff --git a/src/data/help.txt b/src/data/help.txt index 471c4d705..a9734ee94 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -40,7 +40,9 @@ Logo options: Display options: -s,--structure : sets the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available. - -c,--color : sets the color of the keys. Must be a linux console color code or the name of a color (+) + --color-keys : sers the color of the keys + --color-title : sets the color of the title + -c,--color : sets the color of both the keys and the title --separator : sets the separator between key and value. Default is a colon with a space --set : hard set the value of a key --set-keyless : hard set the value of a key, but don't print the key or the separator diff --git a/src/fastfetch.c b/src/fastfetch.c index c08330fe0..81206c294 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -929,8 +929,15 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseString(key, value, &data->structure); else if(strcasecmp(key, "--separator") == 0) optionParseString(key, value, &instance->config.separator); + else if(strcasecmp(key, "--color-keys") == 0) + optionParseColor(key, value, &instance->config.colorKeys); + else if(strcasecmp(key, "--color-title") == 0) + optionParseColor(key, value, &instance->config.colorTitle); else if(strcasecmp(key, "-c") == 0 || strcasecmp(key, "--color") == 0) - optionParseColor(key, value, &instance->config.mainColor); + { + optionParseColor(key, value, &instance->config.colorKeys); + ffStrbufSet(&instance->config.colorTitle, &instance->config.colorKeys); + } else if(strcasecmp(key, "--set") == 0) optionParseCustomValue(data, key, value, true); else if(strcasecmp(key, "--set-keyless") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index e67804e86..e37a4187a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -74,7 +74,10 @@ typedef struct FFconfig bool printRemaining; } logo; - FFstrbuf mainColor; //If this is empty, ffLogoPrint will set it to the main color of the logo + //If one of those is empty, ffLogoPrint will set them + FFstrbuf colorKeys; + FFstrbuf colorTitle; + FFstrbuf separator; bool showErrors; diff --git a/src/logo/builtin.c b/src/logo/builtin.c index bdc4ef7d6..32ac46f70 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -4,6 +4,8 @@ #define FF_LOGO_NAMES(...) static const char* names[] = (const char*[]) { __VA_ARGS__, NULL }; logo.names = names; #define FF_LOGO_LINES(x) logo.data = x; #define FF_LOGO_COLORS(...) static const char* colors[] = (const char*[]) { __VA_ARGS__, NULL }; logo.builtinColors = colors; +#define FF_LOGO_COLOR_KEYS(x) logo.colorKeys = x; +#define FF_LOGO_COLOR_TITLE(x) logo.colorTitle = x; #define FF_LOGO_RETURN return &logo; const FFlogo* ffLogoBuiltinGetUnknown() @@ -31,6 +33,8 @@ const FFlogo* ffLogoBuiltinGetUnknown() " \"\"" ) FF_LOGO_COLORS("") + FF_LOGO_COLOR_KEYS("") + FF_LOGO_COLOR_TITLE("") FF_LOGO_RETURN } @@ -40,6 +44,8 @@ static const FFlogo* getLogoNone() FF_LOGO_NAMES("none", "empty") FF_LOGO_LINES("") FF_LOGO_COLORS("") + FF_LOGO_COLOR_KEYS("") + FF_LOGO_COLOR_TITLE("") FF_LOGO_RETURN } @@ -76,6 +82,8 @@ static const FFlogo* getLogoAlmaLinux() "1;32", // light green "36" // cyan ) + FF_LOGO_COLOR_KEYS("1;33"); //yellow + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -108,6 +116,8 @@ static const FFlogo* getLogoAlpine() FF_LOGO_COLORS( "34" //blue ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -126,6 +136,8 @@ static const FFlogo* getLogoAlpineSmall() FF_LOGO_COLORS( "34" //blue ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -157,6 +169,8 @@ static const FFlogo* getLogoAndroid() "32", //green "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -175,6 +189,8 @@ static const FFlogo* getLogoAndroidSmall() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -206,6 +222,8 @@ static const FFlogo* getLogoArch() FF_LOGO_COLORS( "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -225,6 +243,8 @@ static const FFlogo* getLogoArchSmall() FF_LOGO_COLORS( "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -257,6 +277,8 @@ static const FFlogo* getLogoArtix() FF_LOGO_COLORS( "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -276,6 +298,8 @@ static const FFlogo* getLogoArtixSmall() FF_LOGO_COLORS( "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -309,6 +333,8 @@ static const FFlogo* getLogoArcoLinux() "34", //blue "32" //green ) + FF_LOGO_COLOR_KEYS("34"); //green + FF_LOGO_COLOR_TITLE("34"); //green FF_LOGO_RETURN } @@ -339,6 +365,8 @@ static const FFlogo* getLogoBedrock() "90", //grey "37" //white ) + FF_LOGO_COLOR_KEYS("90"); //grey + FF_LOGO_COLOR_TITLE("37"); //white FF_LOGO_RETURN } @@ -375,6 +403,8 @@ static const FFlogo* getLogoCachyOS() "32", //green "30" //black ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -395,6 +425,8 @@ static const FFlogo* getLogoCachyOSSmall() FF_LOGO_COLORS( "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -424,6 +456,8 @@ static const FFlogo* getLogoCelOS() "35", //magenta "30" //black ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -459,6 +493,8 @@ static const FFlogo* getLogoCentOS() "35", //magenta "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("33"); //yellow FF_LOGO_RETURN } @@ -481,6 +517,8 @@ static const FFlogo* getLogoCentOSSmall() "34", //blue "35" //magenta ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("33"); //yellow FF_LOGO_RETURN } @@ -511,6 +549,8 @@ static const FFlogo* getLogoDebian() "31", //red "37" //white ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -529,6 +569,8 @@ static const FFlogo* getLogoDebianSmall() FF_LOGO_COLORS( "31" //red ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -556,6 +598,8 @@ static const FFlogo* getLogoDevuan() FF_LOGO_COLORS( "35" //magenta ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("35"); //magenta FF_LOGO_RETURN } @@ -573,8 +617,10 @@ static const FFlogo* getLogoDevuanSmall() "#@@@#=:\n" ) FF_LOGO_COLORS( - "34" //blue + "35" //magenta ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("35"); //magenta FF_LOGO_RETURN } @@ -605,6 +651,8 @@ static const FFlogo* getLogoDeepin() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -634,6 +682,8 @@ static const FFlogo* getLogoEndeavour() "31", //red "34" //blue ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -666,6 +716,8 @@ static const FFlogo* getLogoFedora() "34", //blue "37" //white ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -687,6 +739,8 @@ static const FFlogo* getLogoFedoraSmall() FF_LOGO_COLORS( "34" //blue ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -717,6 +771,8 @@ static const FFlogo* getLogoFedoraOld() "34", //blue "37" //white ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -747,6 +803,8 @@ static const FFlogo* getLogoGaruda() FF_LOGO_COLORS( "31" //red ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -778,6 +836,8 @@ static const FFlogo* getLogoGentoo() "35", //magenta "37" //white ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("35"); //magenta FF_LOGO_RETURN } @@ -798,6 +858,8 @@ static const FFlogo* getLogoGentooSmall() "35", //magenta "37" //white ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("35"); //magenta FF_LOGO_RETURN } @@ -829,6 +891,8 @@ static const FFlogo* getLogoKDENeon() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -850,6 +914,8 @@ static const FFlogo* getLogoKISSLinux() "37", //white "34" //blue ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -883,6 +949,8 @@ static const FFlogo* getLogoKubuntu() "34", //blue "37" //white ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -909,6 +977,8 @@ static const FFlogo* getLogoLangitKetujuh() "34", //blue "37" //white ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -935,6 +1005,8 @@ static const FFlogo* getLogoLinux() "30", //black "33" //yellow ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("37"); //white FF_LOGO_RETURN } @@ -968,6 +1040,8 @@ static const FFlogo* getLogoMacOS() "35", //magenta "34" //blue ) + FF_LOGO_COLOR_KEYS("33"); //yellow + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -994,6 +1068,8 @@ static const FFlogo* getLogoManjaro() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1013,6 +1089,8 @@ static const FFlogo* getLogoManjaroSmall() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1045,6 +1123,8 @@ static const FFlogo* getLogoMint() "32", //green "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1065,6 +1145,8 @@ static const FFlogo* getLogoMintSmall() "32", //green "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1094,6 +1176,8 @@ static const FFlogo* getLogoMintOld() "32", //green "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1133,6 +1217,8 @@ static const FFlogo* getLogoMsys2() "37", //white "31" //red ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -1166,6 +1252,8 @@ static const FFlogo* getLogoNixOS() "34", //blue "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -1207,6 +1295,8 @@ static const FFlogo* getLogoNixOsOld() "34", //blue "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -1226,6 +1316,8 @@ static const FFlogo* getLogoNixOsSmall() FF_LOGO_COLORS( "34" //blue ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -1257,6 +1349,8 @@ static const FFlogo* getLogoOpenSuse() "32", //green "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1276,6 +1370,8 @@ static const FFlogo* getLogoOpenSuseSmall() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1284,7 +1380,7 @@ static const FFlogo* getLogoOpenSuseLeap() FF_LOGO_INIT FF_LOGO_NAMES("opensuse_leap", "open_suse_leap", "opensuse-leap", "open-suse-leap", "suse_leap", "suse-leap", "opensuseleap") FF_LOGO_LINES( - " $2.-++:.\n" + " .-++:.\n" " ./oooooo/-\n" " `:oooooooooooo:.\n" " -+oooooooooooooooo+-`\n" @@ -1302,9 +1398,10 @@ static const FFlogo* getLogoOpenSuseLeap() " `:/." ) FF_LOGO_COLORS( - "32", //green "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1313,7 +1410,7 @@ static const FFlogo* getLogoOpenSuseTumbleweed() FF_LOGO_INIT FF_LOGO_NAMES("opensuse_tumbleweed", "open_suse_tumbleweed", "opensuse-tumbleweed", "open-suse-tumbleweed", "suse_tumbleweed", "suse-tumbleweed", "opensusetumbleweed") FF_LOGO_LINES( - " $2......\n" + " ......\n" " .,cdxxxoc,. .:kKMMMNWMMMNk:.\n" " cKMMN0OOOKWMMXo. ; ;0MWk:. .:OMMk.\n" " ;WMK;. .lKMMNM, :NMK, .OMW;\n" @@ -1328,9 +1425,10 @@ static const FFlogo* getLogoOpenSuseTumbleweed() " ..... .:dOOXXKOxl," ) FF_LOGO_COLORS( - "32", //green "37" //white ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1364,6 +1462,8 @@ static const FFlogo* getLogoPop() "36", //cyan "37" //white ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -1384,6 +1484,8 @@ static const FFlogo* getLogoPopSmall() FF_LOGO_COLORS( "36" //cyan ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } @@ -1417,6 +1519,8 @@ static const FFlogo* getLogoReborn() "34", //blue "36" //cyan ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -1440,6 +1544,8 @@ static const FFlogo* getLogoRebornSmall() FF_LOGO_COLORS( "34" //blue ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -1470,6 +1576,8 @@ static const FFlogo* getLogoRedHatEnterpriseLinux() FF_LOGO_COLORS( "31" //red ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -1500,6 +1608,8 @@ static const FFlogo* getLogoRedstarOS() FF_LOGO_COLORS( "31" //red ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -1531,6 +1641,8 @@ static const FFlogo* getLogoRockyLinux() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1563,6 +1675,8 @@ static const FFlogo* getLogoRosaLinux() FF_LOGO_COLORS( "34" //blue ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } @@ -1596,6 +1710,8 @@ static const FFlogo* getLogoUbuntu() "31", //red "37" //white ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -1614,6 +1730,8 @@ static const FFlogo* getLogoUbuntuSmall() FF_LOGO_COLORS( "31" //red ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red FF_LOGO_RETURN } @@ -1645,6 +1763,8 @@ static const FFlogo* getLogoVoid() "32", //green "30" //black ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1664,6 +1784,8 @@ static const FFlogo* getLogoVoidSmall() FF_LOGO_COLORS( "32" //green ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("32"); //green FF_LOGO_RETURN } @@ -1693,6 +1815,8 @@ static const FFlogo* getLogoZorin() FF_LOGO_COLORS( "34" //blue ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } diff --git a/src/logo/logo.c b/src/logo/logo.c index 44000c500..e0ec11da8 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -150,10 +150,13 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac printf("\033[%uA", instance->state.logoHeight); } -static void logoApplyMainColor(FFinstance* instance, const FFlogo* logo) +static void logoApplyColors(FFinstance* instance, const FFlogo* logo) { - if(instance->config.mainColor.length == 0) - ffStrbufAppendS(&instance->config.mainColor, logo->builtinColors[0]); + if(instance->config.colorKeys.length == 0) + ffStrbufAppendS(&instance->config.colorKeys, logo->colorKeys); + + if(instance->config.colorTitle.length == 0) + ffStrbufAppendS(&instance->config.colorTitle, logo->colorTitle); } static bool logoHasName(const FFlogo* logo, const char* name) @@ -214,14 +217,14 @@ static const FFlogo* logoGetBuiltinDetected(FFinstance* instance) return ffLogoBuiltinGetUnknown(); } -static inline void logoApplyMainColorDetected(FFinstance* instance) +static inline void logoApplyColorsDetected(FFinstance* instance) { - logoApplyMainColor(instance, logoGetBuiltinDetected(instance)); + logoApplyColors(instance, logoGetBuiltinDetected(instance)); } static void logoPrintStruct(FFinstance* instance, const FFlogo* logo) { - logoApplyMainColor(instance, logo); + logoApplyColors(instance, logo); const char** colors = logo->builtinColors; for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) @@ -259,7 +262,7 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement) return false; } - logoApplyMainColorDetected(instance); + logoApplyColorsDetected(instance); ffLogoPrintChars(instance, content.chars, doColorReplacement); ffStrbufDestroy(&content); return true; @@ -270,7 +273,7 @@ static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logo) if(!ffLogoPrintImageIfExists(instance, logo)) return false; - logoApplyMainColorDetected(instance); + logoApplyColorsDetected(instance); return true; } diff --git a/src/logo/logo.h b/src/logo/logo.h index a84824ec0..4bdc6a54a 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -10,6 +10,8 @@ typedef struct FFlogo const char* data; const char** names; //Null terminated const char** builtinColors; //Null terminated + const char* colorKeys; + const char* colorTitle; } FFlogo; typedef const FFlogo*(*GetLogoMethod)(); diff --git a/src/modules/title.c b/src/modules/title.c index 1c78f3327..089b5105c 100644 --- a/src/modules/title.c +++ b/src/modules/title.c @@ -7,7 +7,7 @@ static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content) if(!instance->config.pipe) { fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintColor(&instance->config.mainColor); + ffPrintColor(&instance->config.colorTitle); } ffStrbufWriteTo(content, stdout);