Skip to content

Commit

Permalink
add "?" command to menupick
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Dominus committed Jan 1, 2013
1 parent d045875 commit 91cbec2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions menupick
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ if ($opt->{n} > 0 && @item > $opt->{n}) {
exit 2;
}

for my $i (0 .. $#item) {
printf $ttyout "%2d. %s\n", $i, $item[$i];
sub show_menu {
for my $i (0 .. $#item) {
printf $ttyout "%2d. %s\n", $i, $item[$i];
}
}
show_menu();

my @set = ();
while (1) {
my $in = prompt($ttyin, $ttyout);
last unless $in =~ /\S/;
my $quit = $in =~ s/!\s*$//;
if ($in =~ /^\s*\?\s*$/) {
print_set($ttyout, @set);
next;
}
modify($in, \@set);
last if $quit;
}
Expand Down Expand Up @@ -66,3 +73,8 @@ sub modify {
}
@$set = sort { $a <=> $b } keys %set;
}

sub print_set {
my ($out) = shift;
print $out "@_\n";
}

0 comments on commit 91cbec2

Please sign in to comment.