Skip to content

Commit 8f205b8

Browse files
committed
Percent: rename FFPercentConfig to FFColorRangeConfig
1 parent e046787 commit 8f205b8

File tree

23 files changed

+38
-37
lines changed

23 files changed

+38
-37
lines changed

src/common/parsing.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "fastfetch.h"
3+
#include "util/FFstrbuf.h"
44

55
#include <stdint.h>
66

@@ -11,6 +11,12 @@ typedef struct FFVersion
1111
uint32_t patch;
1212
} FFVersion;
1313

14+
typedef struct FFColorRangeConfig
15+
{
16+
uint8_t green;
17+
uint8_t yellow;
18+
} FFColorRangeConfig;
19+
1420
#define FF_VERSION_INIT ((FFVersion) {0})
1521

1622
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);

src/common/percent.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "util/textModifier.h"
77
#include "util/stringUtils.h"
88

9-
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config)
9+
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config)
1010
{
1111
uint8_t green = config.green, yellow = config.yellow;
1212
assert(green <= 100 && yellow <= 100);
@@ -75,7 +75,7 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config
7575
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
7676
}
7777

78-
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses)
78+
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses)
7979
{
8080
uint8_t green = config.green, yellow = config.yellow;
8181
assert(green <= 100 && yellow <= 100);
@@ -126,7 +126,7 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config
126126
ffStrbufAppendC(buffer, ')');
127127
}
128128

129-
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config)
129+
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config)
130130
{
131131
if (!ffStrStartsWithIgnCase(subkey, "percent-"))
132132
return false;
@@ -160,7 +160,7 @@ bool ffPercentParseCommandOptions(const char* key, const char* subkey, const cha
160160
return false;
161161
}
162162

163-
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config)
163+
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config)
164164
{
165165
if (!ffStrEqualsIgnCase(key, "percent"))
166166
return false;
@@ -198,7 +198,7 @@ bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfi
198198
return true;
199199
}
200200

201-
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config)
201+
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config)
202202
{
203203
if (config.green == defaultConfig.green && config.yellow == defaultConfig.yellow)
204204
return;

src/common/percent.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "util/FFstrbuf.h"
4+
#include "common/parsing.h"
45

56
enum
67
{
@@ -10,12 +11,6 @@ enum
1011
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
1112
};
1213

13-
typedef struct FFPercentConfig
14-
{
15-
uint8_t green;
16-
uint8_t yellow;
17-
} FFPercentConfig;
18-
1914
// if (green <= yellow)
2015
// [0, green]: print green
2116
// (green, yellow]: print yellow
@@ -26,12 +21,12 @@ typedef struct FFPercentConfig
2621
// [yellow, green): print yellow
2722
// [0, yellow): print red
2823

29-
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config);
30-
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses);
24+
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config);
25+
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses);
3126

3227
typedef struct yyjson_val yyjson_val;
3328
typedef struct yyjson_mut_doc yyjson_mut_doc;
3429
typedef struct yyjson_mut_val yyjson_mut_val;
35-
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config);
36-
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config);
37-
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config);
30+
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config);
31+
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config);
32+
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config);

src/modules/battery/battery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void ffInitBatteryOptions(FFBatteryOptions* options)
250250
);
251251
ffOptionInitModuleArg(&options->moduleArgs);
252252
options->temp = false;
253-
options->percent = (FFPercentConfig) { 50, 20 };
253+
options->percent = (FFColorRangeConfig) { 50, 20 };
254254

255255
#ifdef _WIN32
256256
options->useSetupApi = false;

src/modules/battery/option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ typedef struct FFBatteryOptions
1111
FFModuleArgs moduleArgs;
1212

1313
bool temp;
14-
FFPercentConfig percent;
14+
FFColorRangeConfig percent;
1515

1616
#ifdef _WIN32
1717
bool useSetupApi;

src/modules/bluetooth/bluetooth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void ffInitBluetoothOptions(FFBluetoothOptions* options)
198198
);
199199
ffOptionInitModuleArg(&options->moduleArgs);
200200
options->showDisconnected = false;
201-
options->percent = (FFPercentConfig) { 50, 20 };
201+
options->percent = (FFColorRangeConfig) { 50, 20 };
202202
}
203203

204204
void ffDestroyBluetoothOptions(FFBluetoothOptions* options)

src/modules/bluetooth/option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ typedef struct FFBluetoothOptions
1111
FFModuleArgs moduleArgs;
1212

1313
bool showDisconnected;
14-
FFPercentConfig percent;
14+
FFColorRangeConfig percent;
1515
} FFBluetoothOptions;

src/modules/brightness/brightness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void ffInitBrightnessOptions(FFBrightnessOptions* options)
205205
ffOptionInitModuleArg(&options->moduleArgs);
206206

207207
options->ddcciSleep = 10;
208-
options->percent = (FFPercentConfig) { 100, 100 };
208+
options->percent = (FFColorRangeConfig) { 100, 100 };
209209
}
210210

211211
void ffDestroyBrightnessOptions(FFBrightnessOptions* options)

src/modules/brightness/option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ typedef struct FFBrightnessOptions
1111
FFModuleArgs moduleArgs;
1212

1313
uint32_t ddcciSleep; // ms
14-
FFPercentConfig percent;
14+
FFColorRangeConfig percent;
1515
} FFBrightnessOptions;

src/modules/cpuusage/cpuusage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
190190
);
191191
ffOptionInitModuleArg(&options->moduleArgs);
192192
options->separate = false;
193-
options->percent = (FFPercentConfig) { 50, 80 };
193+
options->percent = (FFColorRangeConfig) { 50, 80 };
194194
}
195195

196196
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)

0 commit comments

Comments
 (0)