From 0b43e5d7a47138b65ff7b3d9ebdc81441ce26628 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Mon, 16 Jan 2023 03:06:48 +0100 Subject: [PATCH] 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"). --- plugins/undo | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/undo b/plugins/undo index f51d9e9..18b3c45 100644 --- a/plugins/undo +++ b/plugins/undo @@ -6,7 +6,7 @@ my $filename = ".revbank.undo"; my @TAB; -sub command :Tab(undo) ($self, $cart, $command, @) { +sub command :Tab(undo) ($self, $cart, $command, @) { $command eq 'undo' or return NEXT; $cart->size and return REJECT, "Undo is not available mid-transaction."; @@ -23,16 +23,17 @@ sub command :Tab(undo) ($self, $cart, $command, @) { @TAB = (); + my $menu = ""; my $max = @log < 15 ? @log : 15; for my $txn (@log[-$max .. -1]) { - print "ID: $txn->{tid} $txn->{dt} ", ( - join ", ", map { sprintf "%s:%+.2f", @$_ } @{ $txn->{deltas} } - ), "\n"; + $menu .= "ID: $txn->{tid} $txn->{dt} " . join(", ", + map { sprintf "%s:%+.2f", @$_ } @{ $txn->{deltas} } + ) . "\n"; push @TAB, $txn->{tid}; } - return "Transaction ID", \&undo; + return $menu . "Transaction ID", \&undo; } sub tab { @TAB }