From 3f41b1b555368a3864ceb97995d8cd9614f84b4b Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 19 Nov 2004 10:10:08 +0000 Subject: Take into account terminal size to avoid messing up the display --- urpm/download.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'urpm') 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"; -- cgit v1.2.1