From a2fd94241a60c39cd4c7db96a73d97ee09830614 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Thu, 19 Jan 2023 03:04:16 +0100 Subject: [PATCH] statiegeld: better prompt hijacking --- plugins/statiegeld | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/statiegeld b/plugins/statiegeld index dfe1a40..63e49c5 100644 --- a/plugins/statiegeld +++ b/plugins/statiegeld @@ -101,15 +101,19 @@ sub hook_added_entry ($class, $cart, $entry, @) { } } +# Override main revbank prompt sub hook_prompt { # ($class, $cart, $prompt), but via @_ for mutable alias $S or return; - my $statiegeld_prompt = "\x01\e[33;1m\x02+>\x01\e[0m\x02"; # yellow "+>" + my $m = "Scan products for deposit return."; + + # The message is prepended to the prompt, so it is printed after + # clear-screen (^L). + # ignore----------end ignore-----end + # yellow----------------reset + my $statiegeld_prompt = "\x01\e[33;1m\x02$m\n+>\x01\e[0m\x02"; + # Actual text: ^^^^^^ - if ($_[2] eq "" or $_[2] eq $statiegeld_prompt) { - # Assumption: only the main prompt will have fewer than 3 \w characters - print "\e[33;1mScan products for deposit return.\e[0m\n" if not $_[1]->size; - } $_[2] =~ s/^$/$statiegeld_prompt/; }