summaryrefslogtreecommitdiff
path: root/lib/App/Raps2
diff options
context:
space:
mode:
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;
}