1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Aesthetic changes and bug fixes for progress bar

This commit is contained in:
Darshit Shah 2014-05-01 23:08:52 +02:00
parent 8c2fd06ba8
commit 6d4158122c
2 changed files with 20 additions and 9 deletions

View File

@ -1,3 +1,13 @@
2014-05-01 Darshit Shah <darnir@gmail.com> (tiny change)
* progress.c (dot_finish): Do not print extra newlines when not in verbose
mode. (Purely aesthetic change)
(get_eta): Add extra space when eta is printed.
(create_image): Remove erroneous space from being added to progress bar when
filename > MAX_FILENAME_LEN
(create_image): Remove extra space before printed download speeds
Make the filename a fixed width column.
2014-04-19 Darshit Shah <darnir@gmail.com> 2014-04-19 Darshit Shah <darnir@gmail.com>
* log.h (log_options): Add new logging options, LOG_PROGRESS. All progress * log.h (log_options): Add new logging options, LOG_PROGRESS. All progress

View File

@ -407,7 +407,7 @@ dot_finish (void *progress, double dltime)
} }
print_row_stats (dp, dltime, true); print_row_stats (dp, dltime, true);
logputs (LOG_PROGRESS, "\n\n"); logputs (LOG_VERBOSE, "\n\n");
log_set_flush (false); log_set_flush (false);
xfree (dp); xfree (dp);
@ -875,7 +875,7 @@ get_eta (int *bcd)
static void static void
create_image (struct bar_progress *bp, double dl_total_time, bool done) create_image (struct bar_progress *bp, double dl_total_time, bool done)
{ {
const int MAX_FILENAME_LEN = bp->width / 3; const int MAX_FILENAME_LEN = bp->width / 4;
char *p = bp->buffer; char *p = bp->buffer;
wgint size = bp->initial_length + bp->count; wgint size = bp->initial_length + bp->count;
@ -887,7 +887,6 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
struct bar_progress_hist *hist = &bp->hist; struct bar_progress_hist *hist = &bp->hist;
int orig_filename_len = strlen (bp->f_download); int orig_filename_len = strlen (bp->f_download);
int filename_len = MIN (orig_filename_len, MAX_FILENAME_LEN);
/* The progress bar should look like this: /* The progress bar should look like this:
file xx% [=======> ] nn,nnn 12.34KB/s eta 36m 51s file xx% [=======> ] nn,nnn 12.34KB/s eta 36m 51s
@ -909,7 +908,7 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
"=====>..." - progress bar - the rest "=====>..." - progress bar - the rest
*/ */
int dlbytes_size = 1 + MAX (size_grouped_len, 11); int dlbytes_size = 1 + MAX (size_grouped_len, 11);
int progress_size = bp->width - (filename_len + 1 + 4 + 2 + dlbytes_size + 8 + 14); int progress_size = bp->width - (MAX_FILENAME_LEN + 1 + 4 + 2 + dlbytes_size + 8 + 14);
/* The difference between the number of bytes used, /* The difference between the number of bytes used,
and the number of columns used. */ and the number of columns used. */
@ -920,8 +919,11 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
if (orig_filename_len <= MAX_FILENAME_LEN) if (orig_filename_len <= MAX_FILENAME_LEN)
{ {
int padding = MAX_FILENAME_LEN - orig_filename_len;
sprintf (p, "%s ", bp->f_download); sprintf (p, "%s ", bp->f_download);
p += filename_len + 1; p += orig_filename_len + 1;
for (;padding;padding--)
*p++ = ' ';
} }
else else
{ {
@ -931,7 +933,6 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
offset = ((int) bp->tick) % (orig_filename_len - MAX_FILENAME_LEN); offset = ((int) bp->tick) % (orig_filename_len - MAX_FILENAME_LEN);
else else
offset = 0; offset = 0;
*p++ = ' ';
memcpy (p, bp->f_download + offset, MAX_FILENAME_LEN); memcpy (p, bp->f_download + offset, MAX_FILENAME_LEN);
p += MAX_FILENAME_LEN; p += MAX_FILENAME_LEN;
*p++ = ' '; *p++ = ' ';
@ -1037,12 +1038,12 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
wgint dlquant = hist->total_bytes + bp->recent_bytes; wgint dlquant = hist->total_bytes + bp->recent_bytes;
double dltime = hist->total_time + (dl_total_time - bp->recent_start); double dltime = hist->total_time + (dl_total_time - bp->recent_start);
double dlspeed = calc_rate (dlquant, dltime, &units); double dlspeed = calc_rate (dlquant, dltime, &units);
sprintf (p, " %4.*f%s", dlspeed >= 99.95 ? 0 : dlspeed >= 9.995 ? 1 : 2, sprintf (p, "%4.*f%s", dlspeed >= 99.95 ? 0 : dlspeed >= 9.995 ? 1 : 2,
dlspeed, !opt.report_bps ? short_units[units] : short_units_bits[units]); dlspeed, !opt.report_bps ? short_units[units] : short_units_bits[units]);
move_to_end (p); move_to_end (p);
} }
else else
APPEND_LITERAL (" --.-K/s"); APPEND_LITERAL ("--.-KB/s");
if (!done) if (!done)
{ {