summaryrefslogtreecommitdiffstats
path: root/perl-install/interactive/newt.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-01-27 15:14:34 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-01-27 15:14:34 +0000
commit649ef4df1acfb0939ef3ea3c1ed52163e01c2597 (patch)
treeb11f1a430dcded12f185f61930977012f1de7bd1 /perl-install/interactive/newt.pm
parenta3ad8c69f2375dd7b40548ba826376d0e058460f (diff)
downloaddrakx-backup-do-not-use-649ef4df1acfb0939ef3ea3c1ed52163e01c2597.tar
drakx-backup-do-not-use-649ef4df1acfb0939ef3ea3c1ed52163e01c2597.tar.gz
drakx-backup-do-not-use-649ef4df1acfb0939ef3ea3c1ed52163e01c2597.tar.bz2
drakx-backup-do-not-use-649ef4df1acfb0939ef3ea3c1ed52163e01c2597.tar.xz
drakx-backup-do-not-use-649ef4df1acfb0939ef3ea3c1ed52163e01c2597.zip
don't blindly truncate strings to size 40 in simplify_string
Diffstat (limited to 'perl-install/interactive/newt.pm')
-rw-r--r--perl-install/interactive/newt.pm18
1 files changed, 10 insertions, 8 deletions
diff --git a/perl-install/interactive/newt.pm b/perl-install/interactive/newt.pm
index 873c27d10..fba57874c 100644
--- a/perl-install/interactive/newt.pm
+++ b/perl-install/interactive/newt.pm
@@ -135,18 +135,20 @@ sub ask_fromW_real {
} elsif ($e->{type} eq 'button') {
$w = Newt::Component::Button(-1, -1, simplify_string(may_apply($e->{format}, ${$e->{val}})));
} elsif ($e->{type} =~ /list/) {
- my ($h, $wi) = (@$l == 1 && $height > 30 ? 10 : 5, 20);
+ my ($h) = @$l == 1 && $height > 30 ? 10 : 5;
my $scroll = @{$e->{list}} > $h ? 1 << 2 : 0;
$has_scroll = 1;
$size = min(int @{$e->{list}}, $h);
$w = Newt::Component::Listbox(-1, -1, $size, $scroll); #- NEWT_FLAG_SCROLL
- foreach (@{$e->{list}}) {
- my $t = simplify_string(may_apply($e->{format}, $_));
+
+ my @l = map {
+ my $t = simplify_string(may_apply($e->{format}, $_), $width - 10);
$w->ListboxAddEntry($t, $_);
- $wi = max($wi, length $t);
- }
- $w->ListboxSetWidth(min($wi + 3, $width - 7)); # 3 added for the scrollbar (?)
+ $t;
+ } @{$e->{list}};
+
+ $w->ListboxSetWidth(max(map { length($_) } @l) + 3); # 3 added for the scrollbar (?)
$get = sub { $w->ListboxGetCurrent };
$set = sub {
my ($val) = @_;
@@ -283,9 +285,9 @@ sub wait_message_endW {
}
sub simplify_string {
- my ($s) = @_;
+ my ($s, $width) = @_;
$s =~ s/\n/ /g;
- $s = substr($s, 0, 40); #- truncate if too long
+ $s = substr($s, 0, $width || 40); #- truncate if too long
$s;
}