summaryrefslogtreecommitdiffstats
path: root/perl-install/interactive_newt.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-02-04 16:29:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-02-04 16:29:32 +0000
commita1b093733a765c854715cdccc5bb21854e601a7d (patch)
tree7f8aa04ead9c37efc06c2ceca8ba381011d25d3c /perl-install/interactive_newt.pm
parent41a18a501c0c935ddfbbb2c17fc1b29533983817 (diff)
downloaddrakx-backup-do-not-use-a1b093733a765c854715cdccc5bb21854e601a7d.tar
drakx-backup-do-not-use-a1b093733a765c854715cdccc5bb21854e601a7d.tar.gz
drakx-backup-do-not-use-a1b093733a765c854715cdccc5bb21854e601a7d.tar.bz2
drakx-backup-do-not-use-a1b093733a765c854715cdccc5bb21854e601a7d.tar.xz
drakx-backup-do-not-use-a1b093733a765c854715cdccc5bb21854e601a7d.zip
fix adaptation to the terminal size, should now work in 80x25
Diffstat (limited to 'perl-install/interactive_newt.pm')
-rw-r--r--perl-install/interactive_newt.pm28
1 files changed, 21 insertions, 7 deletions
diff --git a/perl-install/interactive_newt.pm b/perl-install/interactive_newt.pm
index de924405d..0c8671f19 100644
--- a/perl-install/interactive_newt.pm
+++ b/perl-install/interactive_newt.pm
@@ -11,14 +11,14 @@ use common qw(:common :functional);
use log;
use Newt::Newt; #- !! provides Newt and not Newt::Newt
-my $width = 80;
-my $height = 25;
+my ($width, $height) = (80, 25);
my @wait_messages;
sub new() {
Newt::Init;
Newt::Cls;
Newt::SetSuspendCallback;
+ ($width, $height) = Newt::GetScreenSize;
open STDERR,">/dev/null" if $::isStandalone;
bless {}, $_[0];
}
@@ -32,9 +32,20 @@ sub exit() { end; exit($_[0]) }
END { end() }
sub myTextbox {
+ my $allow_scroll = shift;
+
+ my $width = $width - 9;
my @l = map { /(.{1,$width})/g } map { split "\n" } @_;
- my $h = min($height, int @l);
- my $flag = 1 << 6; $flag |= 1 << 2 if $h < @l; #- NEWT_FLAG_SCROLL
+ my $h = min($height - 13, int @l);
+ my $flag = 1 << 6;
+ if ($h < @l) {
+ if ($allow_scroll) {
+ $flag |= 1 << 2; #- NEWT_FLAG_SCROLL
+ } else {
+ # remove the text, no other way!
+ @l = @l[0 .. $h-1];
+ }
+ }
my $mess = Newt::Component::Textbox(1, 0, my $w = max(map { length } @l) + 1, $h, $flag);
$mess->TextboxSetText(join("\n", @_));
$mess, $w + 1, $h;
@@ -100,7 +111,10 @@ sub ask_from_entries_refW {
# $get = sub { $adj->get_value };
} elsif ($e->{type} =~ /list/) {
my ($h, $wi) = (5, 20);
- $w = Newt::Component::Listbox(-1, -1, $h, @{$e->{list}} > $h ? 1 << 2 : 0); #- NEWT_FLAG_SCROLL
+ my $scroll = @{$e->{list}} > $h ? 1 << 2 : 0;
+ $size = min(int @{$e->{list}}, $h);
+
+ $w = Newt::Component::Listbox(-1, -1, $h, $scroll); #- NEWT_FLAG_SCROLL
foreach (@{$e->{list}}) {
my $t = may_apply($e->{format}, $_);
$w->ListboxAddEntry($t, $_);
@@ -158,7 +172,7 @@ sub ask_from_entries_refW {
my ($buttons, $ok, $cancel) = Newt::Grid::ButtonBar($common->{ok} || '', if_($common->{cancel}, $common->{cancel}));
my $form = Newt::Component::Form(\undef, '', 0);
- my $window = Newt::Grid::GridBasicWindow(first(myTextbox(@{$common->{messages}})), $listg, $buttons);
+ my $window = Newt::Grid::GridBasicWindow(first(myTextbox(@widgets == 0, @{$common->{messages}})), $listg, $buttons);
$window->GridWrappedWindow($common->{title} || '');
$form->FormAddGrid($window, 1);
@@ -188,7 +202,7 @@ sub ask_from_entries_refW {
sub waitbox {
my ($title, $messages) = @_;
- my ($t, $w, $h) = myTextbox(@$messages);
+ my ($t, $w, $h) = myTextbox(1, 0, @$messages);
my $f = Newt::Component::Form(\undef, '', 0);
Newt::CenteredWindow($w, $h, $title);
$f->FormAddComponent($t);