@@ -221,6 +221,23 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
221221 else
222222 return "display.bar must be an object" ;
223223 }
224+ else if (ffStrEqualsIgnCase (key , "fraction" ))
225+ {
226+ if (yyjson_is_obj (val ))
227+ {
228+ yyjson_val * ndigits = yyjson_obj_get (val , "ndigits" );
229+ if (ndigits )
230+ {
231+ if (yyjson_is_null (ndigits ))
232+ options -> fractionNdigits = -1 ;
233+ else if (!yyjson_is_int (ndigits ))
234+ return "display.fraction.ndigits must be an integer" ;
235+ options -> fractionNdigits = (int8_t ) yyjson_get_int (ndigits );
236+ }
237+ }
238+ else
239+ return "display.fraction must be an object" ;
240+ }
224241 else if (ffStrEqualsIgnCase (key , "noBuffer" ))
225242 options -> noBuffer = yyjson_get_bool (val );
226243 else if (ffStrEqualsIgnCase (key , "keyWidth" ))
@@ -462,6 +479,8 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
462479 else
463480 return false;
464481 }
482+ else if (ffStrEqualsIgnCase (key , "-- fraction - ndigits "))
483+ options -> fractionNdigits = (int8_t ) ffOptionParseInt32 (key , value );
465484 else if (ffStrEqualsIgnCase (key , "-- no - buffer "))
466485 options -> noBuffer = ffOptionParseBoolean (value );
467486 else if (ffStrStartsWithIgnCase (key , "-- bar - "))
@@ -539,6 +558,7 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
539558 ffStrbufInitStatic (& options -> percentColorYellow , instance .state .terminalLightTheme ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_LIGHT_YELLOW );
540559 ffStrbufInitStatic (& options -> percentColorRed , instance .state .terminalLightTheme ? FF_COLOR_FG_RED : FF_COLOR_FG_LIGHT_RED );
541560 options -> freqNdigits = 2 ;
561+ options -> fractionNdigits = -1 ;
542562
543563 ffListInit (& options -> constants , sizeof (FFstrbuf ));
544564}
0 commit comments