diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-11-19 10:10:08 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-11-19 10:10:08 +0000 |
commit | 3f41b1b555368a3864ceb97995d8cd9614f84b4b (patch) | |
tree | 365ac090f5bee53341a41cdce86ace10980c0d6d | |
parent | d30d087596c8b84cde4a598c3527e1f8e75d2368 (diff) | |
download | urpmi-3f41b1b555368a3864ceb97995d8cd9614f84b4b.tar urpmi-3f41b1b555368a3864ceb97995d8cd9614f84b4b.tar.gz urpmi-3f41b1b555368a3864ceb97995d8cd9614f84b4b.tar.bz2 urpmi-3f41b1b555368a3864ceb97995d8cd9614f84b4b.tar.xz urpmi-3f41b1b555368a3864ceb97995d8cd9614f84b4b.zip |
Take into account terminal size to avoid messing up the display
-rw-r--r-- | urpm/download.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/urpm/download.pm b/urpm/download.pm index f9f4be2d..f7653f5e 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -421,6 +421,14 @@ sub sync_ssh { sync_rsync($options, @_); } +#- get the width of the terminal +my $wchar = 79; +eval { + require Term::ReadKey; + ($wchar) = Term::ReadKey::GetTerminalSize(); + --$wchar; +}; + #- default logger suitable for sync operation on STDERR only. sub sync_logger { my ($mode, $file, $percent, $total, $eta, $speed) = @_; @@ -433,9 +441,9 @@ sub sync_logger { } else { $text = N(" %s%% completed, speed = %s", $percent, $speed); } - print STDERR $text, " " x (79 - length($text)), "\r"; + print STDERR $text, " " x ($wchar - length($text)), "\r"; } elsif ($mode eq 'end') { - print STDERR " " x 79, "\r"; + print STDERR " " x $wchar, "\r"; } elsif ($mode eq 'error') { #- error is 3rd argument, saved in $percent print STDERR N("...retrieving failed: %s", $percent), "\n"; |