mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Fastfetch: support --module-ouput-color (WIP)
This commit is contained in:
@@ -22,6 +22,11 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs*
|
||||
ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "outputColor"))
|
||||
{
|
||||
ffOptionParseColor(yyjson_get_str(val), &moduleArgs->outputColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "keyColor"))
|
||||
{
|
||||
ffOptionParseColor(yyjson_get_str(val), &moduleArgs->keyColor);
|
||||
|
||||
@@ -39,6 +39,16 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const
|
||||
ffOptionParseString(argumentKey, value, &result->outputFormat);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "output-color"))
|
||||
{
|
||||
if(value == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error: usage: %s <str>\n", argumentKey);
|
||||
exit(477);
|
||||
}
|
||||
ffOptionParseColor(value, &result->outputColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "key-color"))
|
||||
{
|
||||
if(value == NULL)
|
||||
@@ -180,6 +190,7 @@ void ffOptionInitModuleArg(FFModuleArgs* args)
|
||||
ffStrbufInit(&args->key);
|
||||
ffStrbufInit(&args->keyColor);
|
||||
ffStrbufInit(&args->outputFormat);
|
||||
ffStrbufInit(&args->outputColor);
|
||||
args->keyWidth = 0;
|
||||
}
|
||||
|
||||
@@ -188,4 +199,5 @@ void ffOptionDestroyModuleArg(FFModuleArgs* args)
|
||||
ffStrbufDestroy(&args->key);
|
||||
ffStrbufDestroy(&args->keyColor);
|
||||
ffStrbufDestroy(&args->outputFormat);
|
||||
ffStrbufDestroy(&args->outputColor);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,13 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
|
||||
if (moduleArgs->outputColor.length)
|
||||
ffPrintColor(&moduleArgs->outputColor);
|
||||
else if (instance.config.display.colorOutput.length)
|
||||
ffPrintColor(&instance.config.display.colorOutput);
|
||||
}
|
||||
|
||||
if (!instance.config.display.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
{
|
||||
|
||||
@@ -48,6 +48,9 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
|
||||
const char* colorTitle = yyjson_get_str(yyjson_obj_get(val, "title"));
|
||||
if (colorTitle)
|
||||
ffOptionParseColor(colorTitle, &options->colorTitle);
|
||||
const char* colorOutput = yyjson_get_str(yyjson_obj_get(val, "output"));
|
||||
if (colorOutput)
|
||||
ffOptionParseColor(colorOutput, &options->colorOutput);
|
||||
}
|
||||
else
|
||||
return "display.color must be either a string or an object";
|
||||
@@ -244,6 +247,11 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
|
||||
optionCheckString(key, value, &options->colorTitle);
|
||||
ffOptionParseColor(value, &options->colorTitle);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subkey, "output"))
|
||||
{
|
||||
optionCheckString(key, value, &options->colorOutput);
|
||||
ffOptionParseColor(value, &options->colorOutput);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -346,6 +354,7 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
|
||||
{
|
||||
ffStrbufInit(&options->colorKeys);
|
||||
ffStrbufInit(&options->colorTitle);
|
||||
ffStrbufInit(&options->colorOutput);
|
||||
options->brightColor = true;
|
||||
ffStrbufInitStatic(&options->keyValueSeparator, ": ");
|
||||
|
||||
@@ -389,6 +398,7 @@ void ffOptionsDestroyDisplay(FFOptionsDisplay* options)
|
||||
{
|
||||
ffStrbufDestroy(&options->colorKeys);
|
||||
ffStrbufDestroy(&options->colorTitle);
|
||||
ffStrbufDestroy(&options->colorOutput);
|
||||
ffStrbufDestroy(&options->keyValueSeparator);
|
||||
ffStrbufDestroy(&options->barCharElapsed);
|
||||
ffStrbufDestroy(&options->barCharTotal);
|
||||
|
||||
@@ -21,6 +21,7 @@ typedef struct FFOptionsDisplay
|
||||
//If one of those is empty, ffLogoPrint will set them
|
||||
FFstrbuf colorKeys;
|
||||
FFstrbuf colorTitle;
|
||||
FFstrbuf colorOutput;
|
||||
|
||||
bool brightColor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user