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
+13 -6
View File
@@ -76,17 +76,24 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
else
{
FF_STRBUF_AUTO_DESTROY avgNum = ffStrbufCreate();
ffPercentAppendNum(&avgNum, avgValue, options->percent, false, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffPercentAppendNum(&avgNum, avgValue, options->percent, false, &options->moduleArgs);
FF_STRBUF_AUTO_DESTROY avgBar = ffStrbufCreate();
ffPercentAppendBar(&avgBar, avgValue, options->percent, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
ffPercentAppendBar(&avgBar, avgValue, options->percent, &options->moduleArgs);
FF_STRBUF_AUTO_DESTROY minNum = ffStrbufCreate();
ffPercentAppendNum(&minNum, minValue, options->percent, false, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffPercentAppendNum(&minNum, minValue, options->percent, false, &options->moduleArgs);
FF_STRBUF_AUTO_DESTROY minBar = ffStrbufCreate();
ffPercentAppendBar(&minBar, minValue, options->percent, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
ffPercentAppendBar(&minBar, minValue, options->percent, &options->moduleArgs);
FF_STRBUF_AUTO_DESTROY maxNum = ffStrbufCreate();
ffPercentAppendNum(&maxNum, maxValue, options->percent, false, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffPercentAppendNum(&maxNum, maxValue, options->percent, false, &options->moduleArgs);
FF_STRBUF_AUTO_DESTROY maxBar = ffStrbufCreate();
ffPercentAppendBar(&maxBar, maxValue, options->percent, &options->moduleArgs);
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
ffPercentAppendBar(&maxBar, maxValue, options->percent, &options->moduleArgs);
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){
FF_FORMAT_ARG(avgNum, "avg"),
FF_FORMAT_ARG(maxNum, "max"),