mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Global: support --bar-width
This commit is contained in:
@@ -26,11 +26,11 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
if(result->capacity <= 20)
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 10, 0);
|
||||
ffAppendPercentBar(&str, result->capacity, 100, 100, 0);
|
||||
else if(result->capacity <= 50)
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 0, 10);
|
||||
ffAppendPercentBar(&str, result->capacity, 100, 0, 100);
|
||||
else
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 0, 10, 10);
|
||||
ffAppendPercentBar(&str, result->capacity, 0, 100, 100);
|
||||
}
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -38,7 +38,7 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffAppendPercentNum(&str, (uint8_t) result->capacity, 51, 21, str.length > 0);
|
||||
ffAppendPercentNum(&str, result->capacity, 51, 21, str.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
|
||||
if (instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, (uint8_t) (item->value + 0.5), 0, 10, 10);
|
||||
ffAppendPercentBar(&str, item->value, 0, 100, 100);
|
||||
}
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -59,7 +59,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffAppendPercentNum(&str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0);
|
||||
ffAppendPercentNum(&str, item->value, 10, 10, str.length > 0);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
|
||||
@@ -25,12 +25,12 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffAppendPercentBar(&str, (uint8_t)percentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, percentage, 0, 50, 80);
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
ffAppendPercentNum(&str, percentage, 50, 80, str.length > 0);
|
||||
}
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(disk->bytesTotal, &totalPretty);
|
||||
|
||||
uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0;
|
||||
double bytesPercentage = disk->bytesTotal > 0 ? (double) disk->bytesUsed / (double) disk->bytesTotal * 100.0 : 0;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, bytesPercentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, bytesPercentage, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
ffAppendPercentNum(&str, (uint8_t) bytesPercentage, 50, 80, str.length > 0);
|
||||
ffAppendPercentNum(&str, bytesPercentage, 50, 80, str.length > 0);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&output, ", ");
|
||||
ffAppendPercentNum(&output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false);
|
||||
ffAppendPercentNum(&output, (double) gpu->dedicated.used / (double) gpu->dedicated.total * 100.0, 50, 80, false);
|
||||
}
|
||||
ffStrbufAppendC(&output, ')');
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesTotal, &totalPretty);
|
||||
|
||||
uint8_t percentage = storage.bytesTotal == 0
|
||||
double percentage = storage.bytesTotal == 0
|
||||
? 0
|
||||
: (uint8_t) (((long double) storage.bytesUsed / (long double) storage.bytesTotal) * 100.0);
|
||||
: (double) storage.bytesUsed / (double) storage.bytesTotal * 100.0;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, percentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, percentage, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
ffAppendPercentNum(&str, percentage, 50, 80, str.length > 0);
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
|
||||
@@ -25,9 +25,9 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesTotal, &totalPretty);
|
||||
|
||||
uint8_t percentage = storage.bytesTotal == 0
|
||||
double percentage = storage.bytesTotal == 0
|
||||
? 0
|
||||
: (uint8_t) (((long double) storage.bytesUsed / (long double) storage.bytesTotal) * 100.0);
|
||||
: (double) storage.bytesUsed / (double) storage.bytesTotal * 100.0;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, 0, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, 0, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
@@ -47,7 +47,7 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, percentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, percentage, 0, 50, 80);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
ffAppendPercentNum(&str, percentage, 50, 80, str.length > 0);
|
||||
}
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
|
||||
Reference in New Issue
Block a user