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 -2
View File
@@ -3,8 +3,9 @@
#include "common/color.h"
#include "util/textModifier.h"
void ffPercentAppendBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow)
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config)
{
uint8_t green = config.green, yellow = config.yellow;
assert(green <= 100 && yellow <= 100);
const FFOptionsDisplay* options = &instance.config.display;
@@ -56,8 +57,9 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}
void ffPercentAppendNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, bool parentheses)
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses)
{
uint8_t green = config.green, yellow = config.yellow;
assert(green <= 100 && yellow <= 100);
const FFOptionsDisplay* options = &instance.config.display;
+9 -3
View File
@@ -1,6 +1,6 @@
#pragma once
#include "fastfetch.h"
#include "util/FFstrbuf.h"
enum
{
@@ -10,6 +10,12 @@ enum
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
};
typedef struct FFPercentConfig
{
uint8_t green;
uint8_t yellow;
} FFPercentConfig;
// if (green <= yellow)
// [0, green]: print green
// (green, yellow]: print yellow
@@ -20,5 +26,5 @@ enum
// [yellow, green): print yellow
// [0, yellow): print red
void ffPercentAppendBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow);
void ffPercentAppendNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, bool parentheses);
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config);
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses);