mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Global: add option --percent-ndigits
This commit is contained in:
+10
-1
@@ -343,6 +343,8 @@
|
||||
"sizeNdigits": {
|
||||
"type": "integer",
|
||||
"title": "Set the number of digits to keep after the decimal point when formatting sizes",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"default": 2
|
||||
},
|
||||
"sizeMaxPrefix": {
|
||||
@@ -388,9 +390,16 @@
|
||||
"type": "number",
|
||||
"title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"maximum": 255,
|
||||
"default": 1
|
||||
},
|
||||
"percentNdigits": {
|
||||
"type": "number",
|
||||
"title": "Set the number of digits to keep after the decimal point when formatting percentage numbers",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"default": 0
|
||||
},
|
||||
"noBuffer": {
|
||||
"type": "boolean",
|
||||
"title": "Whether to disable the stdout application buffer",
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_RED "m");
|
||||
}
|
||||
}
|
||||
ffStrbufAppendF(buffer, "%u%%", (unsigned) (percent + 0.5));
|
||||
ffStrbufAppendF(buffer, "%.*f%%", instance.config.percentNdigits, percent);
|
||||
|
||||
if (colored && !instance.config.pipe)
|
||||
{
|
||||
|
||||
@@ -74,6 +74,7 @@ static void defaultConfig(void)
|
||||
instance.config.barWidth = 10;
|
||||
instance.config.barBorder = true;
|
||||
instance.config.percentType = 1;
|
||||
instance.config.percentNdigits = 0;
|
||||
|
||||
ffInitBatteryOptions(&instance.config.battery);
|
||||
ffInitBiosOptions(&instance.config.bios);
|
||||
|
||||
@@ -325,7 +325,9 @@ const char* ffParseDisplayJsonConfig(void)
|
||||
config->temperatureUnit = (FFTemperatureUnit) value;
|
||||
}
|
||||
else if (ffStrEqualsIgnCase(key, "percentType"))
|
||||
config->percentType = (uint32_t) yyjson_get_uint(val);
|
||||
config->percentType = (uint8_t) yyjson_get_uint(val);
|
||||
else if (ffStrEqualsIgnCase(key, "percentNdigits"))
|
||||
config->percentNdigits = (uint8_t) yyjson_get_uint(val);
|
||||
else if (ffStrEqualsIgnCase(key, "bar"))
|
||||
{
|
||||
if (yyjson_is_obj(val))
|
||||
|
||||
+3
-1
@@ -1053,7 +1053,9 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
});
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "--percent-type"))
|
||||
instance.config.percentType = ffOptionParseUInt32(key, value);
|
||||
instance.config.percentType = (uint8_t) ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--percent-ndigits"))
|
||||
instance.config.percentNdigits = (uint8_t) ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--no-buffer"))
|
||||
instance.config.noBuffer = ffOptionParseBoolean(value);
|
||||
else if(ffStrStartsWithIgnCase(key, "--bar"))
|
||||
|
||||
+2
-1
@@ -61,7 +61,8 @@ typedef struct FFconfig
|
||||
FFstrbuf barCharTotal;
|
||||
uint8_t barWidth;
|
||||
bool barBorder;
|
||||
uint32_t percentType;
|
||||
uint8_t percentType;
|
||||
uint8_t percentNdigits;
|
||||
bool pipe; //disables logo and all escape sequences
|
||||
bool multithreading;
|
||||
bool stat;
|
||||
|
||||
Reference in New Issue
Block a user