mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Display: add option --color-separator
This commit is contained in:
@@ -387,6 +387,10 @@
|
||||
"output": {
|
||||
"description": "Set the color of the module output",
|
||||
"$ref": "#/$defs/colors"
|
||||
},
|
||||
"separator": {
|
||||
"description": "Set the color of the key-value separator",
|
||||
"$ref": "#/$defs/colors"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
"type": "small"
|
||||
},
|
||||
"display": {
|
||||
"separator": "\u001b[31m-> "
|
||||
"separator": "-> ",
|
||||
"color": {
|
||||
"separator": "red"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
"type": "none"
|
||||
},
|
||||
"display": {
|
||||
"separator": "\u001b[1m-> "
|
||||
"separator": "-> ",
|
||||
"color": {
|
||||
"separator": "1"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
|
||||
@@ -43,10 +43,16 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
}
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
ffPrintColor(&instance.config.display.colorSeparator);
|
||||
}
|
||||
|
||||
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
|
||||
|
||||
if(!instance.config.display.pipe && instance.config.display.colorSeparator.length)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
|
||||
if (!(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
{
|
||||
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.display.keyWidth;
|
||||
|
||||
@@ -51,6 +51,9 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
|
||||
const char* colorOutput = yyjson_get_str(yyjson_obj_get(val, "output"));
|
||||
if (colorOutput)
|
||||
ffOptionParseColor(colorOutput, &options->colorOutput);
|
||||
const char* colorSeparator = yyjson_get_str(yyjson_obj_get(val, "separator"));
|
||||
if (colorSeparator)
|
||||
ffOptionParseColor(colorSeparator, &options->colorSeparator);
|
||||
}
|
||||
else
|
||||
return "display.color must be either a string or an object";
|
||||
@@ -252,6 +255,11 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
|
||||
optionCheckString(key, value, &options->colorOutput);
|
||||
ffOptionParseColor(value, &options->colorOutput);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subkey, "separator"))
|
||||
{
|
||||
optionCheckString(key, value, &options->colorSeparator);
|
||||
ffOptionParseColor(value, &options->colorSeparator);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -355,6 +363,7 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
|
||||
ffStrbufInit(&options->colorKeys);
|
||||
ffStrbufInit(&options->colorTitle);
|
||||
ffStrbufInit(&options->colorOutput);
|
||||
ffStrbufInit(&options->colorSeparator);
|
||||
options->brightColor = true;
|
||||
ffStrbufInitStatic(&options->keyValueSeparator, ": ");
|
||||
|
||||
@@ -399,6 +408,7 @@ void ffOptionsDestroyDisplay(FFOptionsDisplay* options)
|
||||
ffStrbufDestroy(&options->colorKeys);
|
||||
ffStrbufDestroy(&options->colorTitle);
|
||||
ffStrbufDestroy(&options->colorOutput);
|
||||
ffStrbufDestroy(&options->colorSeparator);
|
||||
ffStrbufDestroy(&options->keyValueSeparator);
|
||||
ffStrbufDestroy(&options->barCharElapsed);
|
||||
ffStrbufDestroy(&options->barCharTotal);
|
||||
@@ -435,6 +445,10 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do
|
||||
yyjson_mut_obj_add_strbuf(doc, color, "keys", &options->colorKeys);
|
||||
if (!ffStrbufEqual(&options->colorTitle, &defaultOptions.colorTitle))
|
||||
yyjson_mut_obj_add_strbuf(doc, color, "title", &options->colorTitle);
|
||||
if (!ffStrbufEqual(&options->colorOutput, &defaultOptions.colorOutput))
|
||||
yyjson_mut_obj_add_strbuf(doc, color, "output", &options->colorOutput);
|
||||
if (!ffStrbufEqual(&options->colorSeparator, &defaultOptions.colorSeparator))
|
||||
yyjson_mut_obj_add_strbuf(doc, color, "separator", &options->colorSeparator);
|
||||
if (yyjson_mut_obj_size(color) > 0)
|
||||
{
|
||||
if (yyjson_mut_obj_size(color) == 2 && ffStrbufEqual(&options->colorKeys, &options->colorTitle))
|
||||
|
||||
@@ -22,6 +22,7 @@ typedef struct FFOptionsDisplay
|
||||
FFstrbuf colorKeys;
|
||||
FFstrbuf colorTitle;
|
||||
FFstrbuf colorOutput;
|
||||
FFstrbuf colorSeparator;
|
||||
|
||||
bool brightColor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user