summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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') {