From 32c296c69cf9c263fcbe035004aa28c345b3b279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Thu, 6 Jun 2024 03:06:42 -0300 Subject: [PATCH] make progress display include a gauge (#81) * make progress display include a gauge * Update hdl_dump.c * Update hdl_dump.c * Update hdl_dump.c * Update hdl_dump.c --- hdl_dump.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hdl_dump.c b/hdl_dump.c index de43b25..060790b 100644 --- a/hdl_dump.c +++ b/hdl_dump.c @@ -1442,14 +1442,26 @@ handle_sigint(/*@unused@*/ int signo) static int progress_cb(progress_t *pgs, /*@unused@*/ void *data) { + int barWidth = 70, pos, i = 0; static time_t last_flush = 0; time_t now = time(NULL); - if (pgs->remaining != -1) + if (pgs->remaining != -1) { + fprintf(stdout, "["); + pos = barWidth * (pgs->pc_completed); + for (i = 0; i < barWidth; ++i) { + if (i < pos) + fprintf(stdout, "="); + else if (i == pos) + fprintf(stdout, ">"); + else + fprintf(stdout, " "); + } fprintf(stdout, - "%3d%%, %s remaining, %.2f MB/sec \r", + "] %3d%%, %s remaining, %.2f MB/sec \r", pgs->pc_completed, pgs->remaining_text, (double)pgs->curr_bps / (1024.0 * 1024.0)); + } else fprintf(stdout, "%3d%%\r", pgs->pc_completed);