summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-20 20:16:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-20 20:16:32 +0000
commit49b1d198b904f7658485889050df71bfedad4927 (patch)
treeffa7307d56c6209370b71c44c0660220d3b290d2
parent0387778bef42c1d9b7c69dbf19aee9ddb1e1cbfa (diff)
downloadurpmi-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)
-rw-r--r--NEWS3
-rw-r--r--urpm/download.pm9
2 files changed, 11 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 1a0fe1ca..4758b208 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
- urpmi:
o fix getting rpms from different media on same DVD
+ 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)
- bash-completion (guillomovitch):
o don't complete on available packages if completed item is clearly a file
o only select available packages for selected medias
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') {