From aec7e98a6d889dd280a5d234109bbf31a1e68a4d Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 12 Aug 2005 12:35:17 +0000 Subject: [PATCH] Progress bar prettification --- commands/simple/progressbar.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/commands/simple/progressbar.c b/commands/simple/progressbar.c index 3373e9e50..164f74a26 100755 --- a/commands/simple/progressbar.c +++ b/commands/simple/progressbar.c @@ -22,7 +22,7 @@ prettyprogress(long b, long maxb, time_t starttime) secremain = (maxb - b) / bpsec; minremain = (secremain / 60) % 60; hremain = secremain / 3600; - len = printf("Remainining: %ld files. ", maxb-b); + len = printf("Remaining: %ld files. ", maxb-b); #if 0 len += printf("ETA: %d:%02d:%02d ", @@ -38,7 +38,7 @@ prettyprogress(long b, long maxb, time_t starttime) printf("|"); for(; i < len-2; i++) printf("-"); - printf("]\n"); + printf("]\n"); } else printf("\n"); return; @@ -61,13 +61,16 @@ char *argv[]; for(l = 1; l <= LINES+1; l++) printf("\n"); printf(""); while(fgets(line, sizeof(line), stdin)) { + char *nl; i++; for(l = 0; l <= LINES; l++) printf(""); if(i <= count) prettyprogress(i, count, start); else printf("\n"); printf(""); for(l = 0; l < LINES; l++) printf(""); - printf("\r%s", line); + if((nl = strchr(line, '\n'))) *nl = '\0'; + line[78] = '\0'; + printf("\r%s\r", line); } printf("\nDone.\n");