Percentage: simplify usage of ffAppendPercentBar

This commit is contained in:
李通洲
2024-01-20 13:27:55 +08:00
parent bd71aa931f
commit da5c44b3d0
8 changed files with 41 additions and 44 deletions
+2 -7
View File
@@ -24,12 +24,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
{
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
if(result->capacity <= 20)
ffAppendPercentBar(&str, result->capacity, 100, 100, 0);
else if(result->capacity <= 50)
ffAppendPercentBar(&str, result->capacity, 100, 0, 100);
else
ffAppendPercentBar(&str, result->capacity, 0, 100, 100);
ffAppendPercentBar(&str, result->capacity, 50, 20);
}
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
@@ -37,7 +32,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
if(str.length > 0)
ffStrbufAppendC(&str, ' ');
ffAppendPercentNum(&str, result->capacity, 51, 21, str.length > 0);
ffAppendPercentNum(&str, result->capacity, 50, 20, str.length > 0);
}
}
+2 -2
View File
@@ -52,7 +52,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
ffAppendPercentBar(&str, percent, 0, 100, 100);
ffAppendPercentBar(&str, percent, 100, 100);
}
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
@@ -60,7 +60,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
if(str.length > 0)
ffStrbufAppendC(&str, ' ');
ffAppendPercentNum(&str, percent, 10, 10, str.length > 0);
ffAppendPercentNum(&str, percent, 100, 100, str.length > 0);
}
ffStrbufPutTo(&str, stdout);
+1 -1
View File
@@ -52,7 +52,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
if (!options->separate)
{
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
ffAppendPercentBar(&str, avgValue, 0, 50, 80);
ffAppendPercentBar(&str, avgValue, 50, 80);
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
{
if(str.length > 0)
+1 -1
View File
@@ -59,7 +59,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
{
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
ffAppendPercentBar(&str, bytesPercentage, 0, 50, 80);
ffAppendPercentBar(&str, bytesPercentage, 50, 80);
ffStrbufAppendC(&str, ' ');
}
+1 -1
View File
@@ -40,7 +40,7 @@ void ffPrintMemory(FFMemoryOptions* options)
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
ffAppendPercentBar(&str, percentage, 0, 50, 80);
ffAppendPercentBar(&str, percentage, 50, 80);
ffStrbufAppendC(&str, ' ');
}
+2 -2
View File
@@ -37,7 +37,7 @@ void ffPrintSwap(FFSwapOptions* options)
{
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
ffAppendPercentBar(&str, 0, 0, 50, 80);
ffAppendPercentBar(&str, 0, 50, 80);
ffStrbufAppendC(&str, ' ');
}
if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
@@ -47,7 +47,7 @@ void ffPrintSwap(FFSwapOptions* options)
{
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
ffAppendPercentBar(&str, percentage, 0, 50, 80);
ffAppendPercentBar(&str, percentage, 50, 80);
ffStrbufAppendC(&str, ' ');
}