diff options
author | Thomas White <taw@physics.org> | 2009-11-25 18:12:14 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2009-11-25 18:12:14 +0100 |
commit | c275432adfec54341839aa903c19a78cde2a734c (patch) | |
tree | a7353d6de885d3ef50d3f623d9c03d0a0139d1a5 /src/utils.c | |
parent | 0a3ed7206e2bc009ba86a8072530a3f18196cf8f (diff) |
Improve progress bar
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/utils.c b/src/utils.c index faf78502..4f5f7da3 100644 --- a/src/utils.c +++ b/src/utils.c @@ -53,19 +53,20 @@ void chomp(char *s) } -void progress_bar(int val, int total) +void progress_bar(int val, int total, const char *text) { double frac; int n, i; char s[1024]; + const int width = 50; frac = (double)val/total; - n = (int)(frac*80); + n = (int)(frac*width); for ( i=0; i<n; i++ ) s[i] = '='; - for ( i=n; i<80; i++ ) s[i] = '.'; - s[80] = '\0'; - printf("\r|%s|", s); + for ( i=n; i<width; i++ ) s[i] = '.'; + s[width] = '\0'; + printf("\r%s: |%s|", text, s); if ( val == total ) printf("\n"); |