I'd like to see this implemented, so that it's possible to write config
scripts that work well with both the dialog and editor frontends. As
far as I can see, a config script that asks multiple independent
questions must currently choose between either using a state machine as
described in the debconf-devel manpage, which makes backup work in the
dialog frontend but frustrates editor frontend users who would rather
see all the questions at once, or calling db_input for all the questions
and db_go at the end, removing the "go back to previous question"
functionality for the dialog frontend.
So I started out with the code from Readline.pm and came up with the
patch below. It seems to not break the few packages I've tried so far,
though obviously it deserves more testing. In particular, I have no
idea whether the loop for noninteractive elements does the right thing.
Which packages have config scripts likely to break my change?
Regards,
Magnus
diff --git a/Debconf/FrontEnd.pm b/Debconf/FrontEnd.pm
index e14ef29..67415a1 100644
--- a/Debconf/FrontEnd.pm
+++ b/Debconf/FrontEnd.pm
@@ -205,12 +205,45 @@ back up, it returns false.
sub go {
my $this=shift;
- $this->backup('');
- foreach my $element (@{$this->elements}) {
- $element->show;
+
+ # First, take care of any noninteractive elements in the block.
+ foreach my $element (grep ! $_->visible, @{$this->elements}) {
+ my $value=$element->show;
return if $this->backup && $this->capb_backup;
+ $element->question->value($value);
+ }
+
+ # Now we only have to deal with the interactive elements.
+ my @elements=grep $_->visible, @{$this->elements};
+ unless (@elements) {
+ $this->_didbackup('');
+ return 1;
+ }
+
+ # Figure out where to start, based on if we backed up to get here.
+ my $current=$this->_didbackup ? $#elements : 0;
+
+ # Loop through the elements from starting point until we move
+ # out of either side.
+ while ($current > -1 && $current < @elements) {
+ $this->backup('');
+ $elements[$current]->show;
+ if ($this->backup) {
+ $current--;
+ }
+ else {
+ $current++;
+ }
+ }
+
+ if ($current < 0) {
+ $this->_didbackup(1);
+ return;
+ }
+ else {
+ $this->_didbackup('');
+ return 1;
}
- return 1;
}
=item progress_start