summaryrefslogtreecommitdiff
path: root/lib/App/Raps2
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-05-16 11:22:01 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-05-16 11:22:01 +0200
commit86d8310d5724632f2cd54723e9a2ced66bb80ba9 (patch)
treeeaea2df4240599af05bfbd499b541ba6545d8170 /lib/App/Raps2
parent06d064c1d6ba7a98c32527c0ca865c73fd65458e (diff)
Use Term::ReadLine instead of builtin readline
Diffstat (limited to 'lib/App/Raps2')
-rw-r--r--lib/App/Raps2/UI.pm14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/App/Raps2/UI.pm b/lib/App/Raps2/UI.pm
index 5192c43..089290b 100644
--- a/lib/App/Raps2/UI.pm
+++ b/lib/App/Raps2/UI.pm
@@ -7,12 +7,14 @@ use 5.010;
use Carp qw(confess);
use POSIX;
+use Term::ReadLine;
our $VERSION = '0.2';
sub new {
my ($obj) = @_;
my $ref = {};
+ $ref->{term_readline} = Term::ReadLine->new('App::Raps2');
return bless($ref, $obj);
}
@@ -28,12 +30,12 @@ sub list {
}
sub read_line {
- my ($self, $str) = @_;
+ my ($self, $str, $pre) = @_;
- print "${str}: ";
- my $input = readline(STDIN);
+ $pre //= q{};
+
+ my $input = $self->{term_readline}->readline("${str}: ${pre}");
- chomp $input;
return $input;
}
@@ -43,8 +45,8 @@ sub read_multiline {
say "${str} (^D to quit)";
- while (my $line = <STDIN>) {
- $in .= $line;
+ while (my $line = $self->read_line('multiline')) {
+ $in .= "${line}\n";
}
return $in;
}