Percent: rename FFPercentConfig to FFColorRangeConfig

This commit is contained in:
李通洲
2024-02-26 15:12:04 +08:00
parent e046787aec
commit 8f205b8c30
23 changed files with 38 additions and 37 deletions
+7 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#include "fastfetch.h"
#include "util/FFstrbuf.h"
#include <stdint.h>
@@ -11,6 +11,12 @@ typedef struct FFVersion
uint32_t patch;
} FFVersion;
typedef struct FFColorRangeConfig
{
uint8_t green;
uint8_t yellow;
} FFColorRangeConfig;
#define FF_VERSION_INIT ((FFVersion) {0})
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
+5 -5
View File
@@ -6,7 +6,7 @@
#include "util/textModifier.h"
#include "util/stringUtils.h"
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config)
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config)
{
uint8_t green = config.green, yellow = config.yellow;
assert(green <= 100 && yellow <= 100);
@@ -75,7 +75,7 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses)
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses)
{
uint8_t green = config.green, yellow = config.yellow;
assert(green <= 100 && yellow <= 100);
@@ -126,7 +126,7 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config
ffStrbufAppendC(buffer, ')');
}
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config)
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config)
{
if (!ffStrStartsWithIgnCase(subkey, "percent-"))
return false;
@@ -160,7 +160,7 @@ bool ffPercentParseCommandOptions(const char* key, const char* subkey, const cha
return false;
}
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config)
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config)
{
if (!ffStrEqualsIgnCase(key, "percent"))
return false;
@@ -198,7 +198,7 @@ bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfi
return true;
}
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config)
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config)
{
if (config.green == defaultConfig.green && config.yellow == defaultConfig.yellow)
return;
+6 -11
View File
@@ -1,6 +1,7 @@
#pragma once
#include "util/FFstrbuf.h"
#include "common/parsing.h"
enum
{
@@ -10,12 +11,6 @@ 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
@@ -26,12 +21,12 @@ typedef struct FFPercentConfig
// [yellow, green): print yellow
// [0, yellow): print red
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config);
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses);
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config);
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses);
typedef struct yyjson_val yyjson_val;
typedef struct yyjson_mut_doc yyjson_mut_doc;
typedef struct yyjson_mut_val yyjson_mut_val;
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config);
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config);
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config);
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config);
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config);
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config);
+1 -1
View File
@@ -250,7 +250,7 @@ void ffInitBatteryOptions(FFBatteryOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs);
options->temp = false;
options->percent = (FFPercentConfig) { 50, 20 };
options->percent = (FFColorRangeConfig) { 50, 20 };
#ifdef _WIN32
options->useSetupApi = false;
+1 -1
View File
@@ -11,7 +11,7 @@ typedef struct FFBatteryOptions
FFModuleArgs moduleArgs;
bool temp;
FFPercentConfig percent;
FFColorRangeConfig percent;
#ifdef _WIN32
bool useSetupApi;
+1 -1
View File
@@ -198,7 +198,7 @@ void ffInitBluetoothOptions(FFBluetoothOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs);
options->showDisconnected = false;
options->percent = (FFPercentConfig) { 50, 20 };
options->percent = (FFColorRangeConfig) { 50, 20 };
}
void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
+1 -1
View File
@@ -11,5 +11,5 @@ typedef struct FFBluetoothOptions
FFModuleArgs moduleArgs;
bool showDisconnected;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFBluetoothOptions;
+1 -1
View File
@@ -205,7 +205,7 @@ void ffInitBrightnessOptions(FFBrightnessOptions* options)
ffOptionInitModuleArg(&options->moduleArgs);
options->ddcciSleep = 10;
options->percent = (FFPercentConfig) { 100, 100 };
options->percent = (FFColorRangeConfig) { 100, 100 };
}
void ffDestroyBrightnessOptions(FFBrightnessOptions* options)
+1 -1
View File
@@ -11,5 +11,5 @@ typedef struct FFBrightnessOptions
FFModuleArgs moduleArgs;
uint32_t ddcciSleep; // ms
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFBrightnessOptions;
+1 -1
View File
@@ -190,7 +190,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs);
options->separate = false;
options->percent = (FFPercentConfig) { 50, 80 };
options->percent = (FFColorRangeConfig) { 50, 80 };
}
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)
+1 -1
View File
@@ -11,5 +11,5 @@ typedef struct FFCPUUsageOptions
FFModuleArgs moduleArgs;
bool separate;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFCPUUsageOptions;
+1 -1
View File
@@ -484,7 +484,7 @@ void ffInitDiskOptions(FFDiskOptions* options)
ffStrbufInit(&options->folders);
options->showTypes = FF_DISK_VOLUME_TYPE_REGULAR_BIT | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT | FF_DISK_VOLUME_TYPE_READONLY_BIT;
options->calcType = FF_DISK_CALC_TYPE_FREE;
options->percent = (FFPercentConfig) { 50, 80 };
options->percent = (FFColorRangeConfig) { 50, 80 };
}
void ffDestroyDiskOptions(FFDiskOptions* options)
+1 -1
View File
@@ -30,5 +30,5 @@ typedef struct FFDiskOptions
FFstrbuf folders;
FFDiskVolumeType showTypes;
FFDiskCalcType calcType;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFDiskOptions;
+1 -1
View File
@@ -162,7 +162,7 @@ void ffInitGamepadOptions(FFGamepadOptions* options)
ffGenerateGamepadJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
options->percent = (FFPercentConfig) { 50, 20 };
options->percent = (FFColorRangeConfig) { 50, 20 };
}
void ffDestroyGamepadOptions(FFGamepadOptions* options)
+1 -1
View File
@@ -9,5 +9,5 @@ typedef struct FFGamepadOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFGamepadOptions;
+1 -1
View File
@@ -373,7 +373,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
options->forceVulkan = false;
options->temp = false;
options->hideType = FF_GPU_TYPE_UNKNOWN;
options->percent = (FFPercentConfig) { 50, 80 };
options->percent = (FFColorRangeConfig) { 50, 80 };
}
void ffDestroyGPUOptions(FFGPUOptions* options)
+1 -1
View File
@@ -21,5 +21,5 @@ typedef struct FFGPUOptions
bool temp;
bool driverSpecific;
bool forceVulkan;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFGPUOptions;
+1 -1
View File
@@ -148,7 +148,7 @@ void ffInitMemoryOptions(FFMemoryOptions* options)
ffGenerateMemoryJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
options->percent = (FFPercentConfig) { 50, 80 };
options->percent = (FFColorRangeConfig) { 50, 80 };
}
void ffDestroyMemoryOptions(FFMemoryOptions* options)
+1 -1
View File
@@ -10,5 +10,5 @@ typedef struct FFMemoryOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFMemoryOptions;
+1 -1
View File
@@ -18,5 +18,5 @@ typedef struct FFSoundOptions
FFModuleArgs moduleArgs;
FFSoundType soundType;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFSoundOptions;
+1 -1
View File
@@ -255,7 +255,7 @@ void ffInitSoundOptions(FFSoundOptions* options)
ffOptionInitModuleArg(&options->moduleArgs);
options->soundType = FF_SOUND_TYPE_MAIN;
options->percent = (FFPercentConfig) { 80, 90 };
options->percent = (FFColorRangeConfig) { 80, 90 };
}
void ffDestroySoundOptions(FFSoundOptions* options)
+1 -1
View File
@@ -10,5 +10,5 @@ typedef struct FFSwapOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFPercentConfig percent;
FFColorRangeConfig percent;
} FFSwapOptions;
+1 -1
View File
@@ -157,7 +157,7 @@ void ffInitSwapOptions(FFSwapOptions* options)
ffGenerateSwapJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
options->percent = (FFPercentConfig) { 50, 80 };
options->percent = (FFColorRangeConfig) { 50, 80 };
}
void ffDestroySwapOptions(FFSwapOptions* options)