mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-03 18:59:55 -05:00
callback: use variable length for progressbar text
This fixes FS#17523 We always used a fixed value of 50 for textlen, which is often not enough for download progress bar. At least we can use a bigger width on large terminal (e.g. 60% of width) and keep 50 as minimum. before: nautilus-2.28.4-1-x... 5.7M 789.2K/s 00:00:07 [####################################] 100% after: nautilus-2.28.4-1-x86_64 5.7M 770.7K/s 00:00:08 [##############################] 100% Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
e5dce888c0
commit
e4be3e06af
@ -320,7 +320,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
|
|||||||
float timediff;
|
float timediff;
|
||||||
|
|
||||||
/* size of line to allocate for text printing (e.g. not progressbar) */
|
/* size of line to allocate for text printing (e.g. not progressbar) */
|
||||||
const int infolen = 50;
|
int infolen;
|
||||||
int tmp, digits, textlen;
|
int tmp, digits, textlen;
|
||||||
char *opr = NULL;
|
char *opr = NULL;
|
||||||
/* used for wide character width determination and printing */
|
/* used for wide character width determination and printing */
|
||||||
@ -331,6 +331,11 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
infolen = getcols() * 6 / 10;
|
||||||
|
if (infolen < 50) {
|
||||||
|
infolen = 50;
|
||||||
|
}
|
||||||
|
|
||||||
if(percent == 0) {
|
if(percent == 0) {
|
||||||
timediff = get_update_timediff(1);
|
timediff = get_update_timediff(1);
|
||||||
} else {
|
} else {
|
||||||
@ -449,9 +454,8 @@ void cb_dl_total(off_t total)
|
|||||||
/* callback to handle display of download progress */
|
/* callback to handle display of download progress */
|
||||||
void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
|
void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
|
||||||
{
|
{
|
||||||
const int infolen = 50;
|
int infolen;
|
||||||
/* explanation of magic 28 number at the end */
|
int filenamelen;
|
||||||
const int filenamelen = infolen - 28;
|
|
||||||
char *fname, *p;
|
char *fname, *p;
|
||||||
/* used for wide character width determination and printing */
|
/* used for wide character width determination and printing */
|
||||||
int len, wclen, wcwid, padwid;
|
int len, wclen, wcwid, padwid;
|
||||||
@ -472,6 +476,13 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
infolen = getcols() * 6 / 10;
|
||||||
|
if (infolen < 50) {
|
||||||
|
infolen = 50;
|
||||||
|
}
|
||||||
|
/* explanation of magic 28 number at the end */
|
||||||
|
filenamelen = infolen - 28;
|
||||||
|
|
||||||
/* only use TotalDownload if enabled and we have a callback value */
|
/* only use TotalDownload if enabled and we have a callback value */
|
||||||
if(config->totaldownload && list_total) {
|
if(config->totaldownload && list_total) {
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user