From bbf7aed9ac484d7955b4d1888c9b2f93ffd44ba3 Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Tue, 8 Aug 2023 12:16:59 +0800 Subject: ui: match size measures with corresponding units Calculate the size in UI to align with suitable units. --- src/ui.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ui.c') diff --git a/src/ui.c b/src/ui.c index ff6f565..d140207 100644 --- a/src/ui.c +++ b/src/ui.c @@ -9,8 +9,8 @@ #include "constants.h" #include "logger.h" -#include "process_url.h" #include "ui.h" +#include "utils/size_info.h" static nk_size pct; static char *outPath; @@ -26,9 +26,11 @@ void load_ui(struct ui_struct *ui) { poll_status(ui->stat); if (ui->stat->total) { pct = (ui->stat->cur) * 100 / (ui->stat->total); - sprintf(status_string, - "%" CURL_FORMAT_CURL_OFF_T "/%" CURL_FORMAT_CURL_OFF_T ", %hhu%%", - ui->stat->cur, ui->stat->total, (unsigned char)pct); + size_info_t info_cur = num2sizeinfo((unsigned long)ui->stat->cur); + size_info_t info_total = num2sizeinfo((unsigned long)ui->stat->total); + sprintf(status_string, "%.2Lf%s/%.2Lf%s, %hhu%%", info_cur.n, + info_cur.unit_str, info_total.n, info_total.unit_str, + (unsigned char)pct); } if (ui->stat->is_done) { (ui->stat->total) = 0; // To prevent nuklear further updating status_string -- cgit v1.2.3