diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-03-20 20:16:32 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-03-20 20:16:32 +0000 |
commit | 49b1d198b904f7658485889050df71bfedad4927 (patch) | |
tree | ffa7307d56c6209370b71c44c0660220d3b290d2 /urpm/download.pm | |
parent | 0387778bef42c1d9b7c69dbf19aee9ddb1e1cbfa (diff) | |
download | urpmi-49b1d198b904f7658485889050df71bfedad4927.tar urpmi-49b1d198b904f7658485889050df71bfedad4927.tar.gz urpmi-49b1d198b904f7658485889050df71bfedad4927.tar.bz2 urpmi-49b1d198b904f7658485889050df71bfedad4927.tar.xz urpmi-49b1d198b904f7658485889050df71bfedad4927.zip |
o handle displaying utf8 download progression in non-utf8 terminal
(ie clean the full line when we can't be sure of the number of characters
that will be displayed)
Diffstat (limited to 'urpm/download.pm')
-rw-r--r-- | urpm/download.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/urpm/download.pm b/urpm/download.pm index 9ccd2f2b..654ee7f3 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -5,6 +5,7 @@ package urpm::download; use strict; use urpm::msg; use urpm::util; +use bytes(); use Cwd; use Exporter; @@ -686,7 +687,13 @@ sub sync_logger { $text = N(" %s%% completed, speed = %s", $percent, $speed); } if (length($text) > $wchar) { $text = substr($text, 0, $wchar) } - print STDERR $text, " " x ($wchar - length($text)), "\r"; + if (bytes::length($text) < $wchar) { + # clearing more than needed in case the terminal is not handling utf8 and we have a utf8 string + print STDERR $text, " " x ($wchar - bytes::length($text)), "\r"; + } else { + # clearing all the line first since we can't really know the "length" of the string + print STDERR " " x $wchar, "\r", $text, "\r"; + } } elsif ($mode eq 'end') { print STDERR " " x $wchar, "\r"; } elsif ($mode eq 'error') { |