Percentage: prepare to make threshold configurable

This commit is contained in:
李通洲
2024-01-20 14:10:13 +08:00
parent e7974a7cea
commit 62ca495155
22 changed files with 78 additions and 38 deletions
+4 -3
View File
@@ -40,7 +40,7 @@ void ffPrintMemory(FFMemoryOptions* options)
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
ffPercentAppendBar(&str, percentage, 50, 80);
ffPercentAppendBar(&str, percentage, options->percent);
ffStrbufAppendC(&str, ' ');
}
@@ -48,7 +48,7 @@ void ffPrintMemory(FFMemoryOptions* options)
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffPercentAppendNum(&str, percentage, 50, 80, str.length > 0);
ffPercentAppendNum(&str, percentage, options->percent, str.length > 0);
ffStrbufTrimRight(&str, ' ');
ffStrbufPutTo(&str, stdout);
@@ -57,7 +57,7 @@ void ffPrintMemory(FFMemoryOptions* options)
else
{
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
ffPercentAppendNum(&percentageStr, percentage, 50, 80, false);
ffPercentAppendNum(&percentageStr, percentage, options->percent, false);
ffPrintFormat(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
@@ -140,6 +140,7 @@ void ffInitMemoryOptions(FFMemoryOptions* options)
ffGenerateMemoryJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
options->percent = (FFPercentConfig) { 50, 80 };
}
void ffDestroyMemoryOptions(FFMemoryOptions* options)
+3
View File
@@ -3,9 +3,12 @@
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
#include "common/option.h"
#include "common/percent.h"
typedef struct FFMemoryOptions
{
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFPercentConfig percent;
} FFMemoryOptions;