mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Global: add support for colored percentage numbers output
This commit is contained in:
@@ -36,7 +36,8 @@ static void printBattery(FFinstance* instance, BatteryResult* result, uint8_t in
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffStrbufAppendF(&str, str.length > 0 ? "(%u%%)" : "%u%%", (unsigned) result->capacity);
|
||||
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) result->capacity, 51, 21, str.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ void ffPrintCPUUsage(FFinstance* instance)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffStrbufAppendF(&str, "%.2lf%%", percentage);
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
}
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
ffStrbufDestroy(&str);
|
||||
|
||||
+2
-1
@@ -53,7 +53,8 @@ static void printDisk(FFinstance* instance, const FFDisk* disk)
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
ffStrbufAppendF(&str, str.length > 0 ? "(%u%%) " : "%u%% ", bytesPercentage);
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) bytesPercentage, 50, 80, str.length > 0);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -56,7 +56,7 @@ static void printMemory(FFinstance* instance, const char* name, const FFModuleAr
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffStrbufAppendF(&str, str.length > 0 ? "(%u%%)" : "%u%%", percentage);
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
|
||||
Reference in New Issue
Block a user