Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
No longer include newlines in the message prompt for Term::ReadLine.
Browse files Browse the repository at this point in the history
Instead, print the extra lines directly to STDOUT.

This fixes the backspace key when Term::ReadLine::Gnu::XS is not installed.
  • Loading branch information
trizen committed Jun 15, 2020
1 parent fbc11fa commit cf335f1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bin/straw-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,7 @@ if ($opt{history}) {
}

# Add history to Term::ReadLine
if (eval { $term->can('ReadHistory') }) {
$term->ReadHistory($opt{history_file});
}
eval { $term->ReadHistory($opt{history_file}) };

# All history entries
my @history = $term->history_list;
Expand Down Expand Up @@ -1921,7 +1919,11 @@ sub get_user_input {
my $input = unpack(
'A*', defined($opt{std_input})
? delete($opt{std_input})
: ($term->readline($text) // return ':return')
: (do {
my @lines = split(/\R/, $text);
say for @lines[0..$#lines-1];
$term->readline($lines[-1]);
} // return ':return')
) =~ s/^\s+//r;

return q{:next} if $input eq q{}; # <ENTER> for the next page
Expand Down Expand Up @@ -4167,7 +4169,8 @@ sub print_videos {
}

sub press_enter_to_continue {
scalar $term->readline(colored("\n=>> Press ENTER to continue...", 'bold'));
say '';
scalar $term->readline(colored("=>> Press ENTER to continue...", 'bold'));
}

sub main_quit {
Expand Down

0 comments on commit cf335f1

Please sign in to comment.