Percent: tidy

This commit is contained in:
李通洲
2024-02-26 10:23:00 +08:00
parent 42b756e703
commit 1c87693867
2 changed files with 14 additions and 3 deletions
+3 -3
View File
@@ -89,9 +89,9 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config
if (colored && !options->pipe)
{
const char* colorGreen = instance.config.display.percentColorGreen.chars;
const char* colorYellow = instance.config.display.percentColorYellow.chars;
const char* colorRed = instance.config.display.percentColorRed.chars;
const char* colorGreen = options->percentColorGreen.chars;
const char* colorYellow = options->percentColorYellow.chars;
const char* colorRed = options->percentColorRed.chars;
if(percent != percent)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_BLACK "m");
+11
View File
@@ -452,6 +452,17 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do
yyjson_mut_obj_add_uint(doc, percent, "type", options->percentType);
if (options->percentNdigits != defaultOptions.percentNdigits)
yyjson_mut_obj_add_uint(doc, percent, "ndigits", options->percentNdigits);
{
yyjson_mut_val* color = yyjson_mut_obj(doc);
if (!ffStrbufEqual(&options->percentColorGreen, &defaultOptions.percentColorGreen))
yyjson_mut_obj_add_strbuf(doc, color, "green", &options->percentColorGreen);
if (!ffStrbufEqual(&options->percentColorYellow, &defaultOptions.percentColorYellow))
yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->percentColorYellow);
if (!ffStrbufEqual(&options->percentColorRed, &defaultOptions.percentColorRed))
yyjson_mut_obj_add_strbuf(doc, color, "red", &options->percentColorRed);
if (yyjson_mut_obj_size(color) > 0)
yyjson_mut_obj_add_val(doc, percent, "color", color);
}
if (yyjson_mut_obj_size(percent) > 0)
yyjson_mut_obj_add_val(doc, obj, "percent", percent);
}