summaryrefslogtreecommitdiffstats
path: root/src/pacman/callback.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/callback.c')
-rw-r--r--src/pacman/callback.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 5edcc966..46ff2e88 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -351,7 +351,9 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
int len, wclen, wcwid, padwid;
wchar_t *wcstr;
- if(config->noprogressbar) {
+ const int cols = getcols(0);
+
+ if(config->noprogressbar || cols == 0) {
return;
}
@@ -397,7 +399,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
return;
}
- infolen = getcols() * 6 / 10;
+ infolen = cols * 6 / 10;
if (infolen < 50) {
infolen = 50;
}
@@ -454,7 +456,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
free(wcstr);
/* call refactored fill progress function */
- fill_progress(percent, percent, getcols() - infolen);
+ fill_progress(percent, percent, cols - infolen);
if(percent == 100) {
alpm_list_t *i = NULL;
@@ -497,7 +499,9 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
int file_percent = 0, total_percent = 0;
char rate_size = 'K', xfered_size = 'K';
- if(config->noprogressbar || file_total == -1) {
+ const int cols = getcols(0);
+
+ if(config->noprogressbar || cols == 0 || file_total == -1) {
if(file_xfered == 0) {
printf(_("downloading %s...\n"), filename);
fflush(stdout);
@@ -505,7 +509,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
return;
}
- infolen = getcols() * 6 / 10;
+ infolen = cols * 6 / 10;
if (infolen < 50) {
infolen = 50;
}
@@ -662,9 +666,9 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
free(wcfname);
if(totaldownload) {
- fill_progress(file_percent, total_percent, getcols() - infolen);
+ fill_progress(file_percent, total_percent, cols - infolen);
} else {
- fill_progress(file_percent, file_percent, getcols() - infolen);
+ fill_progress(file_percent, file_percent, cols - infolen);
}
return;
}