Percent: in custom format, only set num and bar string if enabled in percent config

Also fix `percentage-bar` printing in Brightness module
This commit is contained in:
李通洲
2024-11-14 15:33:43 +08:00
parent 6801fe3d9c
commit 782af250ff
12 changed files with 82 additions and 40 deletions
+6 -3
View File
@@ -29,6 +29,7 @@ void ffPrintMemory(FFMemoryOptions* options)
? 0
: (double) storage.bytesUsed / (double) storage.bytesTotal * 100.0;
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
@@ -37,7 +38,6 @@ void ffPrintMemory(FFMemoryOptions* options)
else
{
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
@@ -58,9 +58,12 @@ void ffPrintMemory(FFMemoryOptions* options)
else
{
FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate();
ffPercentAppendNum(&percentageNum, percentage, options->percent, false, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffPercentAppendNum(&percentageNum, percentage, options->percent, false, &options->moduleArgs);
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]){
FF_FORMAT_ARG(usedPretty, "used"),
FF_FORMAT_ARG(totalPretty, "total"),