Fastfetch: increase precision of --stat

This commit is contained in:
Carter Li
2024-08-12 11:03:52 +08:00
committed by 李通洲
parent 946eb0eacd
commit 0b85fc74eb
3 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -111,7 +111,7 @@ void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc)
uint32_t colonIndex = ffStrbufNextIndexC(&data->structure, startIndex, ':');
data->structure.chars[colonIndex] = '\0';
uint64_t ms = 0;
double ms = 0;
if(instance.config.display.stat)
ms = ffTimeGetTick();
@@ -124,12 +124,12 @@ void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc)
if (jsonDoc)
{
yyjson_mut_val* moduleJson = yyjson_mut_arr_get_last(jsonDoc->root);
yyjson_mut_obj_add_uint(jsonDoc, moduleJson, "stat", ms);
yyjson_mut_obj_add_real(jsonDoc, moduleJson, "stat", ms);
}
else
{
char str[32];
int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ms);
int len = snprintf(str, sizeof str, "%.3fms", ms);
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
}
}