Change 'take' prompt and strip whitespace from input

This commit is contained in:
RevBar 2011-06-10 01:31:46 +02:00
parent 35100c59ef
commit 478c93cbeb

11
revbank
View file

@ -78,12 +78,10 @@ sub prompt {
print "\e[0m"; print "\e[0m";
defined $input or return; defined $input or return;
# Clean up backspaces... TODO: fix terminal :) $input =~ s/^\s+//; # trim leading whitespace
$input =~ s/^\cH+//; $input =~ s/\s+$//; # trim trailing whitespace
$input =~ s/.\cH// while $input =~ /.\cH/;
$input =~ s/^\cH+//;
if ($input =~ /^\s*abort\s*$/i) { if ($input =~ /^abort$/i) {
print "$at\n"; print "$at\n";
next LINE; # Whoa, scary out-of-scope jump! But it works :) next LINE; # Whoa, scary out-of-scope jump! But it works :)
} }
@ -355,7 +353,8 @@ sub take {
while (not @users or not defined $amount) { while (not @users or not defined $amount) {
PROMPT: for (;;) { PROMPT: for (;;) {
my $input = prompt( my $input = prompt(
"User to take from, or total amount to finish: ", "User to take from"
. (@users ? ", or total amount to finish: " : ": "),
[ users() ] [ users() ]
); );
if ($p = parse_user($input)) { if ($p = parse_user($input)) {