Skip to content

Commit 1c87693

Browse files
committed
Percent: tidy
1 parent 42b756e commit 1c87693

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/common/percent.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config
8989

9090
if (colored && !options->pipe)
9191
{
92-
const char* colorGreen = instance.config.display.percentColorGreen.chars;
93-
const char* colorYellow = instance.config.display.percentColorYellow.chars;
94-
const char* colorRed = instance.config.display.percentColorRed.chars;
92+
const char* colorGreen = options->percentColorGreen.chars;
93+
const char* colorYellow = options->percentColorYellow.chars;
94+
const char* colorRed = options->percentColorRed.chars;
9595

9696
if(percent != percent)
9797
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_BLACK "m");

src/options/display.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,17 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do
452452
yyjson_mut_obj_add_uint(doc, percent, "type", options->percentType);
453453
if (options->percentNdigits != defaultOptions.percentNdigits)
454454
yyjson_mut_obj_add_uint(doc, percent, "ndigits", options->percentNdigits);
455+
{
456+
yyjson_mut_val* color = yyjson_mut_obj(doc);
457+
if (!ffStrbufEqual(&options->percentColorGreen, &defaultOptions.percentColorGreen))
458+
yyjson_mut_obj_add_strbuf(doc, color, "green", &options->percentColorGreen);
459+
if (!ffStrbufEqual(&options->percentColorYellow, &defaultOptions.percentColorYellow))
460+
yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->percentColorYellow);
461+
if (!ffStrbufEqual(&options->percentColorRed, &defaultOptions.percentColorRed))
462+
yyjson_mut_obj_add_strbuf(doc, color, "red", &options->percentColorRed);
463+
if (yyjson_mut_obj_size(color) > 0)
464+
yyjson_mut_obj_add_val(doc, percent, "color", color);
465+
}
455466
if (yyjson_mut_obj_size(percent) > 0)
456467
yyjson_mut_obj_add_val(doc, obj, "percent", percent);
457468
}

0 commit comments

Comments
 (0)