statiegeld: repeat color code on 2nd line of prompt

Found in interaction with `idle` plugin, which causes redraw.
This commit is contained in:
Juerd Waalboer 2023-06-10 22:22:37 +02:00
parent bf8d69b5e6
commit a00384bb0e

View file

@ -108,14 +108,14 @@ sub hook_added_entry ($class, $cart, $entry, @) {
sub hook_prompt { # ($class, $cart, $prompt), but via @_ for mutable alias sub hook_prompt { # ($class, $cart, $prompt), but via @_ for mutable alias
$S or return; $S or return;
my $m = "Scan empty container for deposit return."; my $message = "Scan empty container for deposit return.";
# The message is prepended to the prompt, so it is printed after # The message is prepended to the prompt, so it is printed after
# clear-screen (^L). # clear-screen (^L). The color is repeated on the second line because
# ignore-------end ignore----end # readline redraws only the last line of a multiline prompt.
# yellow----------------reset my $yellow = "\x01\e[e33;1m\x02";
my $statiegeld_prompt = "\x01\e[33;1m\x02$m\n+>\x01\e[0m\x02"; my $reset = "\x01\e[m\x02";
# Actual text: ^^^^^^ my $statiegeld_prompt = "$yellow$message$reset\n$yellow+>$reset";
$_[2] =~ s/^$/$statiegeld_prompt/; $_[2] =~ s/^$/$statiegeld_prompt/;
} }