Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make progress display include a gauge #81

Merged
merged 5 commits into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions hdl_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading