diff options
Diffstat (limited to 'perl-install/interactive/curses.pm')
| -rw-r--r-- | perl-install/interactive/curses.pm | 35 | 
1 files changed, 24 insertions, 11 deletions
| diff --git a/perl-install/interactive/curses.pm b/perl-install/interactive/curses.pm index 9a50522aa..64bdee5c7 100644 --- a/perl-install/interactive/curses.pm +++ b/perl-install/interactive/curses.pm @@ -3,7 +3,7 @@  # to debug, use something like  # PERLDB_OPTS=TTY=`tty` LC_ALL=fr_FR.UTF-8 xterm -geometry 80x25 -e sh -c 'DISPLAY= perl -d t.pl' -package interactive::curses; # $Id: curses.pm 262575 2009-10-22 17:25:42Z blino $ +package interactive::curses;  use diagnostics;  use strict; @@ -34,9 +34,9 @@ sub new {      $cui ||= Curses::UI->new('-color_support' => 1);      # Set some default terminal size, for serial install -    unless ($cui->{-width}) { -	$cui->{-width} = $cui->{-w} = $cui->{-bw} = 80; -    	$cui->{-height} = $cui->{-h} = $cui->{-bh} = 25; +    unless ($cui->{'-width'}) { +	$cui->{'-width'}  = $cui->{'-w'} = $cui->{'-bw'} = 80; +    	$cui->{'-height'} = $cui->{'-h'} = $cui->{'-bh'} = 25;      }      bless { cui => $cui }, $class; @@ -177,7 +177,7 @@ sub compute_size {  	$e->{curses}{'-width'} ||= length($s);      } elsif ($e->{type} eq 'expander') {  	$e->{curses}{'-width'} ||= length("<+> $e->{text}"); -    } elsif ($e->{type} eq 'text' || $e->{type} eq 'label' || $e->{type} eq 'only_label') { +    } elsif (member($e->{type}, qw(text label only_label))) {  	my @text = _messages(min(80, $width_avail - 1), ${$e->{val}}); #- -1 because of the scrollbar  	$e->{curses}{'-focusable'} = 0;  	$e->{curses}{'-height'} ||= heights(int(@text), 10, 4); @@ -352,7 +352,7 @@ sub create_widget {  	$w->set_binding('focus-up', Curses::KEY_LEFT());  	$w->set_binding('focus-down', Curses::KEY_RIGHT());  	$set = sub { $w->set_label(0, sprintf('< %s >', may_apply($e->{format}, $_[0]))) }; -    } elsif ($e->{type} eq 'list' || $e->{type} eq 'combo') { +    } elsif (member($e->{type}, qw(list combo))) {  	$w = $win->add(undef, $e->{type} eq 'combo' ? 'Popupmenu' : 'Listbox',   		       '-values' => $e->{formatted_list},  		       '-onchange' => $onchange->(sub { $e->{list}[$w->id] }), @@ -405,13 +405,26 @@ sub create_widget {      } elsif ($e->{type} eq 'label' && $e->{curses}{'-height'} == 1) {  	$w = $win->add(undef, 'Label', %options);  	$set = sub { $w->text($_[0] || '') }; -    } elsif ($e->{type} eq 'label' || $e->{type} eq 'only_label' || $e->{type} eq 'text') { +    } elsif (member($e->{type}, qw(label only_label text))) {  	$w = $win->add(undef, 'TextViewer', %options);  	$set = sub {   	    my ($text) = @_;  	    my $width = $w->{'-sw'} - ($w->{'-vscrollbar'} ? 1 : 0);  	    $w->text(join("\n", _messages($width, $text)));  	}; +    } elsif ($e->{type} eq 'range') { +	$w = $win->add(undef, 'TextEntry',  +		       '-sbborder' => 1, +		       '-text' => '',  +		       '-regexp' => '/^\d*$/', +		       '-onchange' => sub { +			   $w->text($e->{min}) if $w->text < $e->{min}; +			   $w->text($e->{max}) if $w->text > $e->{max}; +			   ${$e->{val}} = $w->text; +			   $changed->() if $changed; +		       }, +		       %options); +	$set = sub { $w->text($_[0] || '') };      } else {  	$w = $win->add(undef, $e->{hidden} ? 'PasswordEntry' : 'TextEntry',   		       '-sbborder' => 1, @@ -552,7 +565,7 @@ sub ask_fileW {      $dir = $opts->{directory} || $opts->{file} && dirname($opts->{file}); -    if($opts->{save}) { +    if ($opts->{save}) {          $file = $o->{cui}->savefilebrowser('-title' => $opts->{title}, '-path' => $dir, '-file' => basename($file));      } else {          $file = $o->{cui}->loadfilebrowser('-title' => $opts->{title}, '-path' => $dir, '-file' => basename($file)); @@ -561,13 +574,13 @@ sub ask_fileW {      my $err;      if (!$file) {  	$err = N("No file chosen"); -    } elsif(-f $file && $opts->{want_a_dir}) { +    } elsif (-f $file && $opts->{want_a_dir}) {          $file = dirname($file); -    } elsif(-d $file && !$opts->{want_a_dir}) { +    } elsif (-d $file && !$opts->{want_a_dir}) {          $err = N("You have chosen a directory, not a file");      } elsif (!-e $file && !$opts->{save}) {  	$err = $opts->{want_a_dir} ? N("No such directory") : N("No such file"); -    }; +    }      $err and $o->ask_warn('', $err) or $file;  } | 
