diff options
Diffstat (limited to 'perl-install/interactive/stdio.pm')
-rw-r--r-- | perl-install/interactive/stdio.pm | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/perl-install/interactive/stdio.pm b/perl-install/interactive/stdio.pm index ba3088876..5bc53a0f5 100644 --- a/perl-install/interactive/stdio.pm +++ b/perl-install/interactive/stdio.pm @@ -1,4 +1,4 @@ -package interactive::stdio; # $Id$ +package interactive::stdio; use diagnostics; use strict; @@ -19,7 +19,7 @@ sub readln() { sub check_it { my ($i, $n) = @_; - $i =~ /^\s*\d+\s*$/ && 1 <= $i && $i <= $n + $i =~ /^\s*\d+\s*$/ && 1 <= $i && $i <= $n; } sub good_choice { @@ -45,7 +45,7 @@ ask_fromW_begin: my ($e) = @_; $e->{type} = 'list' if $e->{type} =~ /(icon|tree)list/; - #- combo doesn't exist, fallback to a sensible default + #- combo does not exist, fallback to a sensible default $e->{type} = $e->{not_edit} ? 'list' : 'entry' if $e->{type} eq 'combo'; if ($e->{type} eq 'entry') { @@ -63,14 +63,14 @@ ask_fromW_begin: my @labels; my $format_label = sub { my ($e) = @_; return sprintf("`%s' %s %s\n", ${$e->{val}}, $e->{label}, $e->{text}) }; my $do_widget = sub { - my ($e, $ind) = @_; + my ($e, $_ind) = @_; if ($e->{type} eq 'bool') { print "$e->{text} $e->{label}\n"; print N("Your choice? (0/1, default `%s') ", ${$e->{val}} || '0'); my $i = readln(); if ($i) { - to_bool($i) != to_bool(${$e->{val}}) and $common->{callbacks}{changed}->($ind); + to_bool($i) != to_bool(${$e->{val}}) && $e->{changed} and $e->{changed}->(); ${$e->{val}} = $i; } } elsif ($e->{type} =~ /list/) { @@ -89,12 +89,18 @@ ask_fromW_begin: print "\n"; my $i = good_choice(may_apply($e->{format}, ${$e->{val}}), $n); print "Setting to <", $i ? ${$e->{list}}[$i-1] : ${$e->{val}}, ">\n"; - $i and ${$e->{val}} = ${$e->{list}}[$i-1], $common->{callbacks}{changed}->($ind); + if ($i) { + ${$e->{val}} = ${$e->{list}}[$i-1]; + $e->{changed} and $e->{changed}->(); + } } elsif ($e->{type} eq 'button') { print N("Button `%s': %s", $e->{label}, may_apply($e->{format}, ${$e->{val}})), " $e->{text}\n"; print N("Do you want to click on this button?"); my $i = readln(); - $i && $i !~ /^n/i and $e->{clicked_may_quit}(), $common->{callbacks}{changed}->($ind); + if ($i && $i !~ /^n/i) { + $e->{clicked_may_quit}(); + $e->{changed} and $e->{changed}->(); + } } elsif ($e->{type} eq 'label') { my $t = $format_label->($e); push @labels, $t; @@ -106,7 +112,7 @@ ask_fromW_begin: ${$e->{val}} = $i || ${$e->{val}}; ${$e->{val}} = '' if ${$e->{val}} eq 'void'; print "Setting to <", ${$e->{val}}, ">\n"; - $i and $common->{callbacks}{changed}->($ind); + $i && $e->{changed} and $e->{changed}->(); } else { printf "UNSUPPORTED WIDGET TYPE (type <%s> label <%s> text <%s> val <%s>\n", $e->{type}, $e->{label}, $e->{text}, ${$e->{val}}; } @@ -153,28 +159,21 @@ Your choice? "); } else { $i = 1; } - my ($callback_error) = $common->{callbacks}{$i == 2 ? 'canceled' : 'complete'}->(); - $callback_error and goto ask_fromW_begin; - return !($i == 2); + if ($i == 1 && !$common->{validate}()) { + goto ask_fromW_begin; + } + return $i != 2; } sub wait_messageW { - my ($_o, $_title, $message) = @_; - print join "\n", @$message; + my ($_o, $_title, $message, $message_modifiable) = @_; + print join "\n", $message, $message_modifiable; } sub wait_message_nextW { - my $m = join "\n", @{$_[1]}; + my $m = $_[1]; print "\r$m", ' ' x (60 - length $m); } sub wait_message_endW { print "\nDone\n" } -sub ok { - N("Ok"); -} - -sub cancel { - N("Cancel"); -} - 1; |