undo: recent transaction list as part of prompt
This hides it when the command is given as a oneliner ("undo 123\n", as opposed to "undo\n" + "123\n").
This commit is contained in:
parent
11ca0a86b2
commit
0b43e5d7a4
1 changed files with 6 additions and 5 deletions
11
plugins/undo
11
plugins/undo
|
@ -6,7 +6,7 @@ my $filename = ".revbank.undo";
|
||||||
|
|
||||||
my @TAB;
|
my @TAB;
|
||||||
|
|
||||||
sub command :Tab(undo) ($self, $cart, $command, @) {
|
sub command :Tab(undo) ($self, $cart, $command, @) {
|
||||||
$command eq 'undo' or return NEXT;
|
$command eq 'undo' or return NEXT;
|
||||||
|
|
||||||
$cart->size and return REJECT, "Undo is not available mid-transaction.";
|
$cart->size and return REJECT, "Undo is not available mid-transaction.";
|
||||||
|
@ -23,16 +23,17 @@ sub command :Tab(undo) ($self, $cart, $command, @) {
|
||||||
|
|
||||||
@TAB = ();
|
@TAB = ();
|
||||||
|
|
||||||
|
my $menu = "";
|
||||||
my $max = @log < 15 ? @log : 15;
|
my $max = @log < 15 ? @log : 15;
|
||||||
for my $txn (@log[-$max .. -1]) {
|
for my $txn (@log[-$max .. -1]) {
|
||||||
print "ID: $txn->{tid} $txn->{dt} ", (
|
$menu .= "ID: $txn->{tid} $txn->{dt} " . join(", ",
|
||||||
join ", ", map { sprintf "%s:%+.2f", @$_ } @{ $txn->{deltas} }
|
map { sprintf "%s:%+.2f", @$_ } @{ $txn->{deltas} }
|
||||||
), "\n";
|
) . "\n";
|
||||||
|
|
||||||
push @TAB, $txn->{tid};
|
push @TAB, $txn->{tid};
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Transaction ID", \&undo;
|
return $menu . "Transaction ID", \&undo;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub tab { @TAB }
|
sub tab { @TAB }
|
||||||
|
|
Loading…
Add table
Reference in a new issue