From f05948e01343cd2370c31a20923000ae4de13c79 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Wed, 19 Nov 2014 22:55:22 +0530 Subject: [PATCH 2/2] Aesthetic changes to progress bar --- src/ChangeLog | 7 +++++++ src/progress.c | 9 +++++++-- src/retr.c | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ef6ea7e..57a3611 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,12 @@ 2014-11-19 Darshit Shah + * progress.c (create_image): Do not scroll filename if amount of scrolling + is less than MIN_SCROLL_TEXT + * retr.c (fd_read_body): Do not print the directory prefix in the progress + bar + +2014-11-19 Darshit Shah + * utils.c (compile_posix_regex): Fix memory leak due to unfreed regex pointer diff --git a/src/progress.c b/src/progress.c index f813714..deecd32 100644 --- a/src/progress.c +++ b/src/progress.c @@ -964,12 +964,17 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done) int bytes_in_filename, offset_bytes, col; int *cols_ret = &col; - if (((orig_filename_cols > MAX_FILENAME_COLS) && !opt.noscroll) && !done) +#define MIN_SCROLL_TEXT 5 + if ((orig_filename_cols > MAX_FILENAME_COLS + MIN_SCROLL_TEXT) && + !opt.noscroll && + !done) offset_cols = ((int) bp->tick) % (orig_filename_cols - MAX_FILENAME_COLS + 1); else offset_cols = 0; offset_bytes = cols_to_bytes (bp->f_download, offset_cols, cols_ret); - bytes_in_filename = cols_to_bytes (bp->f_download + offset_bytes, MAX_FILENAME_COLS, cols_ret); + bytes_in_filename = cols_to_bytes (bp->f_download + offset_bytes, + MAX_FILENAME_COLS, + cols_ret); memcpy (p, bp->f_download + offset_bytes, bytes_in_filename); p += bytes_in_filename; int padding = MAX_FILENAME_COLS - *cols_ret; diff --git a/src/retr.c b/src/retr.c index ff5f5b3..5adcb59 100644 --- a/src/retr.c +++ b/src/retr.c @@ -265,11 +265,16 @@ fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread, if (opt.show_progress) { + const char *filename_progress; /* If we're skipping STARTPOS bytes, pass 0 as the INITIAL argument to progress_create because the indicator doesn't (yet) know about "skipping" data. */ wgint start = skip ? 0 : startpos; - progress = progress_create (downloaded_filename, start, start + toread); + if (opt.dir_prefix) + filename_progress = downloaded_filename + strlen (opt.dir_prefix) + 1; + else + filename_progress = downloaded_filename; + progress = progress_create (filename_progress, start, start + toread); progress_interactive = progress_interactive_p (progress); } -- 2.1.3