From fa3d4585fdc3e5cee48db59a561da0eaaeaddb23 Mon Sep 17 00:00:00 2001 From: trizen Date: Mon, 15 Jun 2020 16:17:06 +0300 Subject: No longer include newlines in the message prompt for Term::ReadLine. Instead, print the extra lines directly to STDOUT. This fixes the backspace key when Term::ReadLine::Gnu::XS is not installed. --- bin/fair-viewer | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/fair-viewer b/bin/fair-viewer index bb30e6a..ebe8dd5 100755 --- a/bin/fair-viewer +++ b/bin/fair-viewer @@ -576,9 +576,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; @@ -1924,7 +1922,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{}; # for the next page @@ -4170,7 +4172,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 { -- cgit v1.2.3