diff options
author | Mole Shang <[email protected]> | 2023-08-08 12:16:59 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2023-08-08 12:22:00 +0800 |
commit | bbf7aed9ac484d7955b4d1888c9b2f93ffd44ba3 (patch) | |
tree | 944b132b070eaca3c5ef3a664d61b70d931a4271 /src/ui.c | |
parent | f0121e1596dc5490b58b6dad1bfb8f3b83d19b94 (diff) | |
download | hinata-bbf7aed9ac484d7955b4d1888c9b2f93ffd44ba3.tar.gz hinata-bbf7aed9ac484d7955b4d1888c9b2f93ffd44ba3.tar.bz2 hinata-bbf7aed9ac484d7955b4d1888c9b2f93ffd44ba3.zip |
ui: match size measures with corresponding units
Calculate the size in UI to align with suitable units.
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 |