From: Ben Gras Date: Fri, 12 Aug 2005 12:35:17 +0000 (+0000) Subject: Progress bar prettification X-Git-Tag: v3.1.0~351 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-dsfromkey.html?a=commitdiff_plain;h=aec7e98a6d889dd280a5d234109bbf31a1e68a4d;p=minix.git Progress bar prettification --- 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");