summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/install_steps_stdio.pm1
-rw-r--r--perl-install/interactive_stdio.pm174
2 files changed, 124 insertions, 51 deletions
diff --git a/perl-install/install_steps_stdio.pm b/perl-install/install_steps_stdio.pm
index 4b0771c55..518640d29 100644
--- a/perl-install/install_steps_stdio.pm
+++ b/perl-install/install_steps_stdio.pm
@@ -14,7 +14,6 @@ use lang;
sub new($$) {
my ($type, $o) = @_;
- $o->{partitioning}{readonly} = 1; #- needed til diskdrake is graphic only...
(bless {}, ref $type || $type)->SUPER::new($o);
}
diff --git a/perl-install/interactive_stdio.pm b/perl-install/interactive_stdio.pm
index e9e23cfb7..5c0ffa882 100644
--- a/perl-install/interactive_stdio.pm
+++ b/perl-install/interactive_stdio.pm
@@ -22,65 +22,139 @@ sub check_it {
$i =~ /^\s*\d+\s*$/ && 1 <= $i && $i <= $n
}
-sub ask_from_listW {
- my ($o, $title_, $messages, $list, $def) = @_;
- my ($title, @okcancel) = ref $title_ ? @$title_ : ($title_, _("Ok"), _("Cancel"));
- print map { "$_\n" } @$messages;
+sub good_choice {
+ my ($def_s, $max) = @_;
my $i;
+ do {
+ defined $i and print _("Bad choice, try again\n");
+ print _("Your choice? (default %s) ", $def_s);
+ $i = readln();
+ } until (!$i || check_it($i, $max));
+ $i;
+}
- if (@$list < 10 && sum(map { length $_ } @$list) < 50) {
- my @l;
- do {
- if (defined $i) {
- @l ? print _("Ambiguity (%s), be more precise\n", join(", ", @l)) :
- print _("Bad choice, try again\n");
+sub ask_fromW {
+ my ($o, $common, $l, $l2) = @_;
+
+ask_fromW_begin:
+
+ my $already_entries = 0;
+ my $predo_widget = sub {
+ my ($e) = @_;
+
+ $e->{type} = 'list' if $e->{type} =~ /(icon|tree)list/;
+ #- combo doesn't exist, fallback to a sensible default
+ $e->{type} = $e->{not_edit} ? 'list' : 'entry' if $e->{type} eq 'combo';
+
+ if ($e->{type} eq 'entry') {
+ my $t = "\t$e->{label} $e->{text}\n";
+ if ($already_entries) {
+ length($already_entries) > 1 and print _("Entries you'll have to fill:\n%s", $already_entries);
+ $already_entries = 1;
+ print $t;
+ } else {
+ $already_entries = $t;
}
- @$list == 1 ? print @$list :
- print join("/", @$list), _(" ? (default %s) ", $def);
- $i = readln() || $def;
- @l = grep { /^$i/ } @$list;
- } until (@l == 1);
- $l[0];
- } else {
- my $n = 0; foreach (@$list) {
- $n++;
- $def eq $_ and $def = $n;
- print "$n: $_\n";
}
- do {
- defined $i and print _("Bad choice, try again\n");
- print _("Your choice? (default %s) ", $def);
- $i = readln() || $def;
- } until (check_it($i, $n));
- $list->[$i - 1];
- }
-}
+ };
+
+ my @labels = ();
+ my $format_label = sub { my ($e) = @_; return "`${$e->{val}}' $e->{label} $e->{text}\n"; };
+ my $do_widget = sub {
+ my ($e, $ind) = @_;
-sub ask_many_from_listW {
- my ($o, $title, $messages, $l) = @_;
- my ($list, $val) = ($l->{labels}, $l->{ref});
- my @defaults;
- print map { "$_\n" } @$messages;
- my $n = 0; foreach (@$list) {
- $n++;
- print "$n: $_\n";
- push @defaults, $n if ${$val->[$n - 1]};
+ if ($e->{type} eq 'bool') {
+ print "$e->{text} $e->{label}\n";
+ print _("Your choice? (0/1, default `%s') ", ${$e->{val}} || '0');
+ my $i = readln();
+ if ($i ne '') {
+ to_bool($i) != to_bool(${$e->{val}}) and $common->{callbacks}{changed}->($ind);
+ ${$e->{val}} = $i;
+ }
+ } elsif ($e->{type} =~ /list/) {
+ ($e->{text} || $e->{label}) and print "=> $e->{label} $e->{text}\n";
+ my $n = 0; my $size = 0; my $def_n = 0;
+ foreach (@{$e->{list}}) {
+ $n++;
+ my $t = "$n: " . may_apply($e->{format}, $_) . "\t";
+ if ($size + length($t) >= 80) {
+ print "\n";
+ $size = 0;
+ }
+ print $t;
+ $size += length($t);
+ ${$e->{val}} eq $_ and $def_n = $n;
+ }
+ 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);
+ } elsif ($e->{type} eq 'button') {
+ print _("Button `%s': %s", $e->{label}, may_apply($e->{format}, ${$e->{val}})), " $e->{text}\n";
+ print _("Do you want to click on this button? ");
+ my $i = readln();
+ ($i && $i !~ /^n/i) and $e->{clicked_may_quit}(), $common->{callbacks}{changed}->($ind);
+ } elsif ($e->{type} eq 'label') {
+ my $t = $format_label->($e);
+ push @labels, $t;
+ print $t;
+ } elsif ($e->{type} eq 'entry') {
+ print "$e->{label} $e->{text}\n";
+ print _("Your choice? (default `%s'%s) ", ${$e->{val}}, ${$e->{val}} ne '' ? " enter `void' for void entry" : '');
+ my $i = readln();
+ ${$e->{val}} = $i || ${$e->{val}};
+ ${$e->{val}} = '' if ${$e->{val}} eq 'void';
+ print "Setting to <${$e->{val}}>\n";
+ $i and $common->{callbacks}{changed}->($ind);
+ } else {
+ print "UNSUPPORTED WIDGET TYPE (type <$e->{type}> label <$e->{label}> text <$e->{text}> val <${$e->{val}}>\n";
+ }
+ };
+
+ print "* ";
+ $common->{title} and print "$common->{title}\n";
+ print map { "$_\n" } @{$common->{messages}};
+
+ $predo_widget->($_) foreach (@$l);
+ if (listlength(@$l) > 30) {
+ my $ll = listlength(@$l);
+ print _("=> There are many things to choose from ($ll).\n");
+ask_fromW_handle_verylonglist:
+ print _(
+"Please choose the first number of the 10-range you wish to edit,
+or just hit Enter to proceed.
+Your choice? ");
+ my $i = readln();
+ if (check_it($i, $ll)) {
+ map_index { $do_widget->($_, $::i) } grep_index { $::i >= $i-1 && $::i < $i+9 } @$l;
+ goto ask_fromW_handle_verylonglist;
+ }
+ } else {
+ map_index { $do_widget->($_, $::i) } @$l;
}
+
+ my $lab;
+ map_index { $labels[$::i] && (($lab = $format_label->($_)) ne $labels[$::i]) and print _("=> Notice, a label changed:\n%s", $lab); }
+ grep { $_->{type} eq 'label' } @$l;
+
my $i;
- TRY_AGAIN:
- defined $i and print _("Bad choice, try again\n");
- print _("Your choice? (default %s enter `none' for none) ", join(',', @defaults));
- $i = readln();
- my @t = split ',', $i;
- if ($i =~ /^none$/i) {
- @t = ();
+ if (listlength(@$l) != 1 || $common->{ok} ne _("Ok") || $common->{cancel} ne _("Cancel")) {
+ print "[1] ", $common->{ok} || _("Ok");
+ $common->{cancel} and print " [2] $common->{cancel}";
+ @$l and print " [9] ", _("Re-submit");
+ print "\n";
+ do {
+ defined $i and print _("Bad choice, try again\n");
+ print _("Your choice? (default %s) ", $common->{focus_cancel} ? $common->{cancel} : $common->{ok});
+ $i = readln() || ($common->{focus_cancel} ? "2" : "1");
+ } until (check_it($i, 9));
+ $i == 9 and goto ask_fromW_begin;
} else {
- foreach (@t) { check_it($_, $n) or goto TRY_AGAIN }
+ $i = 1;
}
-
- $$_ = 0 foreach @$val;
- ${$val->[$_ - 1]} = 1 foreach @t;
- $val;
+ my ($callback_error) = $common->{callbacks}{$i == 2 ? 'canceled' : 'complete'}->();
+ $callback_error and goto ask_fromW_begin;
+ return !($i == 2);
}
sub wait_messageW {