@@ -76,8 +76,6 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
7676 }
7777 else if (ffStrEqualsIgnCase (key , "brightColor" ))
7878 options -> brightColor = yyjson_get_bool (val );
79- else if (ffStrEqualsIgnCase (key , "binaryPrefix" ))
80- return "`display.binaryPrefix` has been renamed to `display.size.binaryPrefix`. Sorry for another break change." ;
8179 else if (ffStrEqualsIgnCase (key , "duration" ))
8280 {
8381 if (!yyjson_is_obj (val ))
@@ -265,38 +263,95 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
265263 {
266264 if (yyjson_is_obj (val ))
267265 {
268- const char * charElapsed = yyjson_get_str (yyjson_obj_get (val , "charElapsed" ));
269- if (charElapsed )
270- ffStrbufSetS (& options -> barCharElapsed , charElapsed );
271-
272- const char * charTotal = yyjson_get_str (yyjson_obj_get (val , "charTotal" ));
273- if (charTotal )
274- ffStrbufSetS (& options -> barCharTotal , charTotal );
275-
276- yyjson_val * borderLeft = yyjson_obj_get (val , "borderLeft" );
277- if (borderLeft )
278- ffStrbufSetS (& options -> barBorderLeft , yyjson_get_str (borderLeft ));
266+ yyjson_val * char_ = yyjson_obj_get (val , "char" );
267+ if (char_ )
268+ {
269+ if (!yyjson_is_obj (char_ )) return "display.bar.char must be an object" ;
279270
280- yyjson_val * borderRight = yyjson_obj_get (val , "borderRight" );
281- if (borderRight )
282- ffStrbufSetS (& options -> barBorderRight , yyjson_get_str ( borderRight ) );
271+ const char * charElapsed = yyjson_get_str ( yyjson_obj_get (char_ , "elapsed" ) );
272+ if (charElapsed )
273+ ffStrbufSetS (& options -> barCharElapsed , charElapsed );
283274
284- yyjson_val * borderLeftElapsed = yyjson_obj_get (val , "borderLeftElapsed" );
285- if (borderLeftElapsed )
286- ffStrbufSetS (& options -> barBorderLeftElapsed , yyjson_get_str (borderLeftElapsed ));
275+ const char * charTotal = yyjson_get_str (yyjson_obj_get (char_ , "total" ));
276+ if (charTotal )
277+ ffStrbufSetS (& options -> barCharTotal , charTotal );
278+ }
279+ else
280+ {
281+ const char * charElapsed = yyjson_get_str (yyjson_obj_get (val , "charElapsed" ));
282+ if (charElapsed )
283+ return "display.bar.charElapsed has been renamed to display.bar.char.elapsed." ;
287284
288- yyjson_val * borderRightElapsed = yyjson_obj_get (val , "borderRightElapsed" );
289- if (borderRightElapsed )
290- ffStrbufSetS (& options -> barBorderRightElapsed , yyjson_get_str (borderRightElapsed ));
285+ const char * charTotal = yyjson_get_str (yyjson_obj_get (val , "charTotal" ));
286+ if (charTotal )
287+ return "display.bar.charTotal has been renamed to display.bar.char.total." ;
288+ }
291289
292- yyjson_val * colorElapsed = yyjson_obj_get (val , "colorElapsed" );
293- if (colorElapsed ) ffOptionParseColor (yyjson_get_str (colorElapsed ), & options -> barColorElapsed );
290+ yyjson_val * border = yyjson_obj_get (val , "border" );
291+ if (border )
292+ {
293+ if (yyjson_is_null (border ))
294+ {
295+ ffStrbufClear (& options -> barBorderLeft );
296+ ffStrbufClear (& options -> barBorderRight );
297+ ffStrbufClear (& options -> barBorderLeftElapsed );
298+ ffStrbufClear (& options -> barBorderRightElapsed );
299+ }
300+ else
301+ {
302+ if (!yyjson_is_obj (border )) return "display.bar.border must be an object" ;
303+
304+ yyjson_val * borderLeft = yyjson_obj_get (border , "left" );
305+ if (borderLeft )
306+ ffStrbufSetS (& options -> barBorderLeft , yyjson_get_str (borderLeft ));
307+
308+ yyjson_val * borderRight = yyjson_obj_get (border , "right" );
309+ if (borderRight )
310+ ffStrbufSetS (& options -> barBorderRight , yyjson_get_str (borderRight ));
311+
312+ yyjson_val * borderLeftElapsed = yyjson_obj_get (border , "leftElapsed" );
313+ if (borderLeftElapsed )
314+ ffStrbufSetS (& options -> barBorderLeftElapsed , yyjson_get_str (borderLeftElapsed ));
315+
316+ yyjson_val * borderRightElapsed = yyjson_obj_get (border , "rightElapsed" );
317+ if (borderRightElapsed )
318+ ffStrbufSetS (& options -> barBorderRightElapsed , yyjson_get_str (borderRightElapsed ));
319+ }
320+ }
321+ else
322+ {
323+ yyjson_val * borderLeft = yyjson_obj_get (val , "borderLeft" );
324+ if (borderLeft )
325+ return "display.bar.borderLeft has been renamed to display.bar.border.left." ;
294326
295- yyjson_val * colorTotal = yyjson_obj_get (val , "colorTotal" );
296- if (colorTotal ) ffOptionParseColor (yyjson_get_str (colorTotal ), & options -> barColorTotal );
327+ yyjson_val * borderRight = yyjson_obj_get (val , "borderRight" );
328+ if (borderRight )
329+ return "display.bar.borderRight has been renamed to display.bar.border.right." ;
330+ }
297331
298- yyjson_val * colorBorder = yyjson_obj_get (val , "colorBorder" );
299- if (colorBorder ) ffOptionParseColor (yyjson_get_str (colorBorder ), & options -> barColorBorder );
332+ yyjson_val * color = yyjson_obj_get (val , "color" );
333+ if (color )
334+ {
335+ if (yyjson_is_null (color ))
336+ {
337+ ffStrbufClear (& options -> barColorElapsed );
338+ ffStrbufClear (& options -> barColorTotal );
339+ ffStrbufClear (& options -> barColorBorder );
340+ }
341+ else
342+ {
343+ if (!yyjson_is_obj (color )) return "display.bar.color must be an object" ;
344+
345+ yyjson_val * colorElapsed = yyjson_obj_get (color , "elapsed" );
346+ if (colorElapsed ) ffOptionParseColor (yyjson_get_str (colorElapsed ), & options -> barColorElapsed );
347+
348+ yyjson_val * colorTotal = yyjson_obj_get (color , "total" );
349+ if (colorTotal ) ffOptionParseColor (yyjson_get_str (colorTotal ), & options -> barColorTotal );
350+
351+ yyjson_val * colorBorder = yyjson_obj_get (color , "border" );
352+ if (colorBorder ) ffOptionParseColor (yyjson_get_str (colorBorder ), & options -> barColorBorder );
353+ }
354+ }
300355
301356 yyjson_val * width = yyjson_obj_get (val , "width" );
302357 if (width )
@@ -720,7 +775,7 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
720775 ffStrbufInitStatic (& options -> barBorderRight , " ]" );
721776 ffStrbufInit (& options -> barBorderLeftElapsed );
722777 ffStrbufInit (& options -> barBorderRightElapsed );
723- ffStrbufInit (& options -> barColorElapsed );
778+ ffStrbufInitStatic (& options -> barColorElapsed , "auto" );
724779 ffStrbufInitStatic (& options -> barColorTotal , instance .state .terminalLightTheme ? FF_COLOR_FG_WHITE : FF_COLOR_FG_LIGHT_WHITE );
725780 ffStrbufInitStatic (& options -> barColorBorder , instance .state .terminalLightTheme ? FF_COLOR_FG_WHITE : FF_COLOR_FG_LIGHT_WHITE );
726781 options -> barWidth = 10 ;
0 commit comments