mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Options (Display): split code
This commit is contained in:
@@ -16,13 +16,13 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
bool showStatus =
|
||||
!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) &&
|
||||
!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) &&
|
||||
result->status.length > 0 &&
|
||||
ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0;
|
||||
|
||||
if(result->capacity >= 0)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
if(result->capacity <= 20)
|
||||
ffAppendPercentBar(&str, result->capacity, 100, 100, 0);
|
||||
@@ -32,7 +32,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
ffAppendPercentBar(&str, result->capacity, 0, 100, 100);
|
||||
}
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
@@ -50,12 +50,12 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
|
||||
|
||||
if (instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, percent, 0, 100, 100);
|
||||
}
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
void ffPrintColors(FFColorsOptions* options)
|
||||
{
|
||||
if(instance.config.pipe)
|
||||
if(instance.config.display.pipe)
|
||||
return;
|
||||
|
||||
ffPrintLogoAndKey(FF_COLORS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
|
||||
@@ -47,9 +47,9 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
if (!options->separate)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffAppendPercentBar(&str, avgValue, 0, 50, 80);
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
@@ -15,7 +15,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
|
||||
if(options->moduleArgs.key.length == 0)
|
||||
{
|
||||
if(instance.config.pipe)
|
||||
if(instance.config.display.pipe)
|
||||
ffStrbufAppendF(&key, "%s (%s)", FF_DISK_MODULE_NAME, disk->mountpoint.chars);
|
||||
else
|
||||
{
|
||||
@@ -57,16 +57,16 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
|
||||
if(disk->bytesTotal > 0)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, bytesPercentage, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
ffAppendPercentNum(&str, bytesPercentage, 50, 80, str.length > 0);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
@@ -75,7 +75,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
else
|
||||
ffStrbufAppendS(&str, "Unknown ");
|
||||
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
{
|
||||
if(disk->filesystem.length)
|
||||
ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars);
|
||||
|
||||
@@ -38,16 +38,16 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, percentage, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(&str, percentage, 50, 80, str.length > 0);
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
|
||||
@@ -35,26 +35,26 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
if (storage.bytesTotal == 0)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, 0, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendS(&str, "Disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, percentage, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(&str, percentage, 50, 80, str.length > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,19 +8,19 @@
|
||||
|
||||
static void appendText(FFstrbuf* output, const FFstrbuf* text, const FFstrbuf* color)
|
||||
{
|
||||
if (!instance.config.pipe)
|
||||
if (!instance.config.display.pipe)
|
||||
{
|
||||
if (instance.config.brightColor)
|
||||
if (instance.config.display.brightColor)
|
||||
ffStrbufAppendS(output, FASTFETCH_TEXT_MODIFIER_BOLT);
|
||||
if (color->length > 0)
|
||||
ffStrbufAppendF(output, "\e[%sm", color->chars);
|
||||
else if (instance.config.colorTitle.length > 0)
|
||||
ffStrbufAppendF(output, "\e[%sm", instance.config.colorTitle.chars);
|
||||
else if (instance.config.display.colorTitle.length > 0)
|
||||
ffStrbufAppendF(output, "\e[%sm", instance.config.display.colorTitle.chars);
|
||||
}
|
||||
|
||||
ffStrbufAppend(output, text);
|
||||
|
||||
if(!instance.config.pipe)
|
||||
if(!instance.config.display.pipe)
|
||||
ffStrbufAppendS(output, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void ffPrintTitle(FFTitleOptions* options)
|
||||
appendText(&hostNameColored, &hostName, &options->colorHost);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY atColored = ffStrbufCreate();
|
||||
if (!instance.config.pipe && options->colorAt.length > 0)
|
||||
if (!instance.config.display.pipe && options->colorAt.length > 0)
|
||||
{
|
||||
ffStrbufAppendF(&atColored, "\e[%sm", options->colorAt.chars);
|
||||
ffStrbufAppendC(&atColored, '@');
|
||||
|
||||
Reference in New Issue
Block a user