On 11/09, Ángel González wrote:
Attached is a patch that will eliminate the directory prefix from the filename displayed in the progress bar.On 07/11/14 06:12, Darshit Shah wrote:Because real life is catching up, I've very little time till the end of this year. But I'm going to try and debug this issue and fix it asap.A small suggestion before you stop touching this part of the codebase: donot include the directory-prefix (when set) in the progressbar. Its additionmay cause the filename piece to marquee (it's not uncommon that they get long), and it's unnecessary, as the goal of adding --directory-prefix was precisely to prefix every filename with that.
I've also added another aesthetic change where if the number of characters scrolled is less than 5 (random number I chose), then the filename will not be scrolled. This prevents an annoying corner case where only one or two characters are scrolled creating a very disturbing effect.
-- Thanking You, Darshit Shah
From f05948e01343cd2370c31a20923000ae4de13c79 Mon Sep 17 00:00:00 2001 From: Darshit Shah <[email protected]> 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 <[email protected]> + * 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 <[email protected]> + * 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
pgpDXJAgb5lIk.pgp
Description: PGP signature
