statiegeld: better prompt hijacking
This commit is contained in:
parent
2bbaf20366
commit
a2fd94241a
1 changed files with 9 additions and 5 deletions
|
@ -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
|
sub hook_prompt { # ($class, $cart, $prompt), but via @_ for mutable alias
|
||||||
$S or return;
|
$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/;
|
$_[2] =~ s/^$/$statiegeld_prompt/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue