mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:24:58 +02:00
Custom: detect & convert color placeholders ({#xxx})
This commit is contained in:
@@ -57,7 +57,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
ffPrintColor(&instance.config.display.colorOutput);
|
||||
}
|
||||
|
||||
if (!instance.config.display.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
if (!(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
{
|
||||
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.display.keyWidth;
|
||||
if (keyWidth > 0)
|
||||
@@ -73,11 +73,8 @@ void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleAr
|
||||
else
|
||||
ffStrbufAppendS(&buffer, "unknown");
|
||||
|
||||
if(buffer.length > 0)
|
||||
{
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType);
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType);
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
|
||||
static void printError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, va_list arguments)
|
||||
|
||||
+15
-10
@@ -25,7 +25,7 @@ void ffPrintColors(FFColorsOptions* options)
|
||||
// 3%d: Set the foreground color
|
||||
for(uint8_t i = options->block.range[0]; i <= min(options->block.range[1], 7); i++)
|
||||
{
|
||||
if(!instance.config.display.pipe)
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendF(&result, "\e[3%dm", i);
|
||||
for (uint8_t j = 0; j < options->block.width; j++)
|
||||
ffStrbufAppendS(&result, "█");
|
||||
@@ -35,10 +35,10 @@ void ffPrintColors(FFColorsOptions* options)
|
||||
ffPrintLogoAndKey(FF_COLORS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
flag = true;
|
||||
|
||||
if(options->paddingLeft > 0)
|
||||
if (options->paddingLeft > 0)
|
||||
ffPrintCharTimes(' ', options->paddingLeft);
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendS(&result, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
ffStrbufPutTo(&result, stdout);
|
||||
ffStrbufClear(&result);
|
||||
@@ -59,15 +59,20 @@ void ffPrintColors(FFColorsOptions* options)
|
||||
const char* symbol;
|
||||
switch (options->symbol)
|
||||
{
|
||||
case FF_COLORS_SYMBOL_CIRCLE: symbol = "●"; break;
|
||||
case FF_COLORS_SYMBOL_DIAMOND: symbol = "◆"; break;
|
||||
case FF_COLORS_SYMBOL_TRIANGLE: symbol = "▲"; break;
|
||||
case FF_COLORS_SYMBOL_SQUARE: symbol = "■"; break;
|
||||
case FF_COLORS_SYMBOL_STAR: symbol = "★"; break;
|
||||
default: symbol = "███"; break;
|
||||
case FF_COLORS_SYMBOL_CIRCLE: symbol = "● "; break;
|
||||
case FF_COLORS_SYMBOL_DIAMOND: symbol = "◆ "; break;
|
||||
case FF_COLORS_SYMBOL_TRIANGLE: symbol = "▲ "; break;
|
||||
case FF_COLORS_SYMBOL_SQUARE: symbol = "■ "; break;
|
||||
case FF_COLORS_SYMBOL_STAR: symbol = "★ "; break;
|
||||
default: symbol = "███ "; break;
|
||||
}
|
||||
for (int i = 8; i >= 1; --i)
|
||||
ffStrbufAppendF(&result, "\e[3%dm%s ", i, symbol);
|
||||
{
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendF(&result, "\e[3%dm", i);
|
||||
ffStrbufAppendS(&result, symbol);
|
||||
}
|
||||
ffStrbufTrimRight(&result, ' ');
|
||||
}
|
||||
|
||||
if (result.length > 0)
|
||||
|
||||
@@ -6,10 +6,7 @@
|
||||
|
||||
void ffPrintCustom(FFCustomOptions* options)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&options->moduleArgs.outputFormat, stdout);
|
||||
if(!instance.config.display.pipe)
|
||||
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
ffPrintFormat(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, 0, ((FFformatarg[]) {}));
|
||||
}
|
||||
|
||||
bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value)
|
||||
|
||||
Reference in New Issue
Block a user