diff options
author | gregor herrmann <gregoa@debian.org> | 2020-11-07 16:12:40 +0100 |
---|---|---|
committer | gregor herrmann <gregoa@debian.org> | 2020-11-07 16:12:40 +0100 |
commit | ce05415780ef4a2bbc5585542af06779094fc159 (patch) | |
tree | e22db1edca17aa72029b9f72e59741626ec6801c | |
parent | 6b41ba15a7c79e312173cf49fb0245f32ac3a164 (diff) |
New upstream version 2.10
-rw-r--r-- | CHANGES | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | MANIFEST | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | META.json | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | META.yml | 7 | ||||
-rw-r--r-- | Makefile.PL | 9 | ||||
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | TODO | 58 | ||||
-rw-r--r-- | lib/IO/Pager.pm | 2 | ||||
-rwxr-xr-x | lib/IO/Pager/Perl.pm | 91 | ||||
-rw-r--r-- | lib/IO/Pager/less.pm | 4 | ||||
-rwxr-xr-x | lib/IO/Pager/tp | 13 | ||||
-rw-r--r-- | t/16-PurePerl_interactive.t | 7 |
12 files changed, 142 insertions, 75 deletions
@@ -1,5 +1,14 @@ Revision history for Perl extension IO::Pager. +2.10 Nov + ::Perl Alter tp local script installation for parallel make. RT#133651 + + ::Perl Add basic Windows support. RT#133663 + + ::Perl Add TOPT environment variable to tp. + + ::Perl Enable scrollbar in interactive test 16. + 2.01 Nov 02 2020 ::Perl Fixed bug that left terminal in unclean state if exit at EOF was enabled. diff --git a/META.json b/META.json index b5f8b39..8fbcb5f 100644..100755 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Jerrad Pierce <jpierce@cpan.org>, Florent Angly <florent.angly@gmail.com>" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", + "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010", "license" : [ "unknown" ], @@ -53,9 +53,11 @@ } }, "release_status" : "stable", - "version" : "2.01", + "version" : "2.10", "x_runtime" : { - "recommends" : {} + "recommends" : { + "Win32::Console::ANSI" : 0 + } }, - "x_serialization_backend" : "JSON::PP version 2.97001" + "x_serialization_backend" : "JSON::PP version 4.04" } @@ -12,7 +12,7 @@ build_requires: configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' +generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -35,7 +35,8 @@ requires: Tie::Handle: '0' base: '0' perl: '5.008000' -version: '2.01' +version: '2.10' x_runtime: - recommends: {} + recommends: + Win32::Console::ANSI: 0 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/Makefile.PL b/Makefile.PL index f748bbf..11d6be8 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,6 +1,9 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. + +my @WINANSI = $^O =~ /MSWin/ ? ('Win32::Console::ANSI'=>0) : (); + WriteMakefile( 'MIN_PERL_VERSION' => 5.8.0, 'NAME' => 'IO::Pager', @@ -11,7 +14,7 @@ WriteMakefile( 'Env' => 0, 'Exporter' => 0, 'File::Temp' => 0, - 'bignum' => 0, + 'bignum' => 0 }, 'PREREQ_PM' => { 'base' => 0, @@ -26,12 +29,12 @@ WriteMakefile( 'Text::Wrap' => 0, 'Tie::Handle' => 0, }, - EXE_FILES => [ 'blib/lib/IO/Pager/tp' ], + EXE_FILES => [ 'lib/IO/Pager/tp' ], META_MERGE => { "meta-spec" => { version => 2 }, runtime => { recommends => { -# #Since Term::Pager is unmodern + @WINANSI # 'Term::ReadKey' => 0, }, }, @@ -12,7 +12,7 @@ IO::Pager is lightweight and can be used to locate an available pager and set the PAGER environment variable sanely or as a factory for creating objects defined elsewhere such as IO::Pager::Buffered, IO::Pager::Unbuffered, and IO::Pager::less which provides a pure perl -pager. +pager called tp. IO::Pager subclasses are designed to programmatically decide whether or not to pipe a filehandle's output to a program specified in PAGER. @@ -38,8 +38,13 @@ Multiple core modules are used: base, Env, File::Spec, File::Which, IO::Handle, PerlIO, SelectSaver, Symbol, Text::Wrap, Tie::Handle +Term::ReadKey is also require for IO::Pager::less, IO::Pager::Perl and tp. +Win32::Console::ANSI, included in some distributions of Win32 perl like +Strawberry is recommended on Windows for IO::Pager::less et al. to function. + Test::More is used during the installation procedure. + PORTABILITY IO::Pager is intended to be as portable as possible, I've tested it on numerous @@ -2,16 +2,30 @@ Important things here and in code flagged with XXX Ctrl-Home/End for top/bottom. -Pgup/PgDn (konsole) for file next/prev? -2.0 - squishing throws off line numbering. okay for jumping, awkward for - cross-referencing file in an editor +2.10 +IPP Use alternate screen buffer? + +IPP MS Windows +IPP scrolling commands are wonky, therefore we currently waste +IPP cycles refreshing... but it works! Fix? +IPP https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#viewport-positioning + +IPP more.com exits at EOF. Tests should be longer, or warn of this? +IPP or set $ENV{PAGER}='IO::Pager::less' if $^O =~ /MSWin/ + + MakeMaker __VERSION__? + +2.00 +IPP Fix interaction with KDE konsole RT#133662 +IPP Check xterm, rxvt, gde-term, etc. +IPP Goofy term sizes (and WINCH) 1.03 - grep scrolling is borked - dialog, refresh if _grep instead of specific row refresh - modify calls to line() to pass row? keep a buffer of - {_row}->[$row]=$line? - use screen as buffer: scroll-up decrement cursor until match/top & emit +IPP grep scrolling is borked +IPP dialog, refresh if _grep instead of specific row refresh +IPP modify calls to line() to pass row? keep a buffer of +IPP {_row}->[$row]=$line? +IPP use screen as buffer: scroll-up decrement cursor until match/top & emit Lesskey #command !! - toggle-option #switch toggle_* to this?! @@ -26,17 +40,16 @@ IPP kcub1[left],kcuf1[right],kcuu1[up],kcud1[down],kLFT[S-left],kRIT[S-right] IPP kprv,knxt,khome,kend,kbs[backspace],kf1(help?),kich1(insert as mark?) 1.02 -IPP rename tp to ppp ("pure" perl pager)? (except stty/tput, and ReadKey) +IPP Rearchitect around String::Tagged::Terminal? Term::Screen? -IPP return if $Squeeze and $me->{_text}-[cur] eq '' and -IPP $me->{_text}->[prev] eq '' +IPP Move squeeze from input to logical display to allow runtime toggle? IPP Document line numbering impacts?! (perf, RAM...) +IPP okay for jumping, awkward for x-ref file in an editor IPP WINCH reflow: keep cursor at same content? IPP Display filename in status line? -IPP Rearchitect around String::Tagged::Terminal? 1.01 @@ -48,18 +61,6 @@ IPP TERM=vt100; also Term::Size::Win32 or Win32::Readch 1.00 IPP #Consolidate _cursor+{rows} and _end?? -IPP resize 126 $me->{_end} = $me->{rows} - 1; #NOOP -IPP new 113 $me->{_end} = $me->{rows} - 1; #NOOP, just setting up -IPP line 507 $me->{_end} = $n; #Advance past pause!! -IPP down_ln 518 if( $me->{_end} >= $me->{_txtN}-1 ){ #detect EOF!! -IPP down_ln 522 if(length($me->{pause}) && $me->{_end}<$me->{rows}-1){ -IPP down_ln 523 print $t->Tgoto('cm', 0, $me->{_end}+1 ); } # move! -IPP down_ln 532 $me->line( ++$me->{_end} ); #print! -IPP up_line 552 $me->{_end}--; #NOOP, just keeping up -IPP jump 609 $me->{_end} = $me->{_cursor} + $me->{rows}; #NOOP -IPP search 671 $me->{_end} = $me->{_cursor} + $me->{rows}; # - 1; -IPP search 678 $me->{_end} -= $x; #NOOP, just keeping up - IPP Pause bugs IPP Left/right when paused causes vertical scrolling @@ -70,8 +71,6 @@ IPP read from pipe, file IPP navigation IPP search -IPP $0 as name in status line? - IPP Wrap up tp for PerlTools? 0.43 @@ -84,8 +83,6 @@ IPP Wrap up tp for PerlTools? print() on unopened filehandle STDOUT at Term/Pager.pm line 330 print() on unopened filehandle STDOUT at Term/Pager.pm line 395..399 - Test functionality w/|w/o Term::ReadKey - 0.35 Odd failure of test 11 under tcsh and win-bash because *reference* has extra trailing newline. @@ -97,4 +94,7 @@ IPP Wrap up tp for PerlTools? and document location of each in matrix OR use table-driven tests? new/open each class scalar vs. glob vs. OO - (non-)fully qualified subclass name
\ No newline at end of file + (non-)fully qualified subclass name + +IPP w/|w/o Term::ReadKey + diff --git a/lib/IO/Pager.pm b/lib/IO/Pager.pm index 9342b7f..cd41bec 100644 --- a/lib/IO/Pager.pm +++ b/lib/IO/Pager.pm @@ -1,5 +1,5 @@ package IO::Pager; -our $VERSION = "2.01"; #Untouched since 1.03 +our $VERSION = "2.10"; #Untouched since 1.03 use 5.008; #At least, for decent perlio, and other modernisms use strict; diff --git a/lib/IO/Pager/Perl.pm b/lib/IO/Pager/Perl.pm index 19aed7d..9afee34 100755 --- a/lib/IO/Pager/Perl.pm +++ b/lib/IO/Pager/Perl.pm @@ -1,5 +1,5 @@ package IO::Pager::Perl; -our $VERSION = '2.01'; #Untouched since 2.01 +our $VERSION = '2.10'; #Untouched since 2.10 use strict; use warnings; @@ -14,11 +14,10 @@ sub ReadMode; sub ReadKey; sub new { - print "\e[?1000;1006;1015h"; my $class = shift; my %param = @_; - local $ENV{TERM} = $ENV{TERM} || ''; - local $ENV{TERMCAP} = $ENV{TERM} || ''; + $ENV{TERM} = $ENV{TERM} || ''; + $ENV{TERMCAP} = $ENV{TERMCAP} || ''; my %dims = get_size(cols =>$param{cols} ||80, rows =>$param{rows} ||25, @@ -27,25 +26,38 @@ sub new { #screen is vt100 compatible but does not list sf?! #No matter, it's only used for workaround mode. - if( $ENV{TERM} eq 'screen' && $ENV{TERMCAP} !~ /sf/ ){ - $ENV{TERM} = 'vt100'; + $ENV{TERM} = 'vt100' if( $ENV{TERM} eq 'screen' && $ENV{TERMCAP} !~ /sf/ ); + + #Hack together Windows support. We could use Term::Screen(::Uni), + #but that uses many layers of tie-ing, some of which could be inheritiance. + #This way also reduces dependencies + if( $^O =~ /MSWin/ ){ + eval "use Win32::Console::ANSI;"; + if( $@ ){ + warn "Could not load Win32::Console::ANSI, falling back to dumb mode - $@"; } + else{ + $ENV{TERM} = 'WINANSI'; + #Windows lacks vb as does the fallback Term::Cap vt220 entry, add our own + #https://www.ibiblio.org/oswg/oswg-nightly/oswg/en_US.ISO_8859-1/articles/alessandro-rubini/visual-bell/visual-bell-howto.html#VISIBLEBELL + $ENV{TERMCAP} = do{ undef $/; $_=<DATA>; y/\n//d; $_ }; + } } - -#cm=>cup, ce=>el, cl=>clear, sf=>ind, sr=>ri -#md=>bold, me=>sgr0, mr=>rev, us=>smul - #Speed is mostly useless except Term::Cap expects it? + else{ + #Try to enable mouse support + print "\e[?1000;1006;1015h"; + } + #Speed is mostly useless except Term::Cap demands it my $t = Term::Cap->Tgetent({ OSPEED => $param{speed} }); - eval{ $t->Trequire(qw/cm ce cl sf sr/) }; - my $dumb = $@ ? 1 : 0; + my $dumb = eval{ $t->Trequire(qw/cm ce cl sf sr/) } ? 1 : 0; - my %primitives = ( - # if the entries don't exist, nothing bad will happen + #CORE: cm=>cup, ce=>el, cl=>clear, sf=>ind, sr=>ri + #EXTRA: md=>bold, me=>sgr0, mr=>rev, us=>smul, vb=>flash + my %primitives = (# if the entries don't exist, nothing bad will happen BLD => $t->Tputs('md'), # Bold ULN => $t->Tputs('us'), # Underscore REV => $t->Tputs('mr'), # Reverse NOR => $t->Tputs('me'), # Normal ); - my $text; if( defined( $param{text} ) ){ my $ref = ref( $param{text} ); @@ -126,12 +138,14 @@ EOH add_keys(\&to_bott, '>', 'G', '$', "\e>", "\e[F", "\e0E", "\e0W", "\e[4~"); #M-> ? End End End add_keys(\&downpage, ' ', 'z', "\cV", , 'f', "\cF", "\e ", "\e[6~"); #M- PgDn + add_keys(\&downpage, "\eOs") if $ENV{TERM} eq 'WINANSI'; add_keys(\&downhalf, 'd', "\cD"); add_keys(\&downline, 'e', 'j', 'J', "\cE", "\cN", "\e[B"); #down - add_keys(\&downline_raw, "\n"); + add_keys(\&downline_raw, "\n", "\r"); add_keys(\&upline, 'y', 'k', "\cY", "\cK", 'K', 'Y', "\cP", "\e[A"); #up add_keys(\&uphalf, 'u', "\cU"); add_keys(\&uppage, 'w', 'b', "\cB", "\ev", "\e[5~"); #M-v PgUp + add_keys(\&uppage, "\eOy") if $ENV{TERM} eq 'WINANSI'; add_keys(\&to_top, '<', 'g', "\e<", "\e[H", "\e0", "\e[1~"); #M-< Home Home Home add_keys(\&next_file, ':n', "\e[1;4C"); @@ -173,7 +187,7 @@ EOH $me->{_end} = $me->{rows} - 1; - $SIG{WINCH} = sub{ $me->resize() }; + $SIG{WINCH} = sub{ $me->resize() } unless $ENV{TERM} eq 'WINANSI'; $me->{cols}-- if $me->{scrollBar}; #Can we fold? @@ -207,7 +221,7 @@ sub resize { } $me->status(); - $me->{WINCH}->() if ref($me->{WINCH}) eq 'CODE'; + $me->{WINCH}->() if ref($me->{WINCH}) eq 'CODE'; } sub get_size { @@ -230,13 +244,16 @@ sub get_size { *ReadKey = sub{ getc() }; #Can we get better defaults? - if( `stty` =~ /speed/ ){ - @dims{'rows','cols'} = ($1-1,$2-1) if `stty size` =~ /^(\d+)\s+(\d+)$/; - $dims{speed} = $1 if `stty speed` =~ /^(\d+)$/; + if( $ENV{TERM} eq 'WINANSI' ){ + eval{ @dims{'rows','cols'} = Win32::Console::ANSI::Cursor() }; + } + elsif( `stty` =~ /speed/ ){ + @dims{'rows','cols'} = ($1-1,$2-1) if `stty size` =~ /^(\d+)\s+(\d+)$/; + $dims{speed} = $1 if `stty speed` =~ /^(\d+)$/; } else{ - $dims{rows} = `tput lines` || $dims{rows}; - $dims{cols} = `tput cols` || $dims{cols}; + $dims{rows} = `tput lines` || $dims{rows}; + $dims{cols} = `tput cols` || $dims{cols}; } } return %dims; @@ -351,7 +368,6 @@ sub more { } else{ print $me->{NOR}; - $DB::single = 1; #INPUT LOOP, revised with inspiration from Term::Screen::getch() @@ -400,7 +416,7 @@ sub more { elsif( $char eq "\cG" ){ $input = ''; $exit = 1; } - elsif( $char eq "\n" ){ + elsif( $char eq "\n" || $char eq "\r" ){ #Remove extraneous characters that could cause infinite error loop #XXX this prevents goofy RPN-like repeated commands $input =~ y/0-9//cd;# chomp($input); @@ -774,6 +790,7 @@ sub down_lines{ $me->{_cursor}++; } } + $me->refresh() if $ENV{TERM} eq 'WINANSI'; #XXX Windows scroll is lame $me->scrollBar() if $me->{scrollBar}; } sub downhalf { $_[0]->down_lines( $_[0]->{rows} / 2 ); } @@ -781,7 +798,6 @@ sub downpage { $_[0]->down_lines( $_[0]->{rows} ); #WTF?! add_text in tp's while-loop cannot be reached if there's #no delay here until something other than downpage is called?! select(undef, undef, undef, .1); #XXX WTF?! -# warn "\n\n", map{$_[0]->{$_}."\n"} qw/rows _cursor _end/; } sub downline { $_[0]->down_lines( 1 ); } #Term::ReadKey doesn't offer sufficiently fine control; we want CS8 but -OCRNL @@ -816,6 +832,7 @@ sub up_lines{ } } + $me->refresh() if $ENV{TERM} eq 'WINANSI'; #XXX Windows scroll is lame print $me->{_term}->Tgoto('cm',0,$me->{rows}); # goto bottom $me->scrollBar() if $me->{scrollBar}; } @@ -1094,6 +1111,24 @@ sub dumb_mode{ } 1; +__DATA__ +WINANSI|vt220|Win32 Console based on DEC VT220 in vt100 emulation mode: +am:mi:xn:xo: +co#80:li#24: +RA=\E[?7l:SA=\E[?7h: +ac=kkllmmjjnnwwqquuttvvxx:ae=\E(B:al=\E[L:as=\E(0: +bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH: +cr=^M:cs=\E[%i%d;%dr:dc=\E[P:dl=\E[M:do=\E[B: +ei=\E[4l:ho=\E[H:im=\E[4h: +is=\E[1;24r\E[24;1H: +nd=\E[C: +kd=\E[B::kl=\E[D:kr=\E[C:ku=\E[A:le=^H: +mb=\E[5m:md=\E[1m:me=\E[m:mr=\E[7m: +kb=\0177: +r2=\E>\E[24;1H\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E=:rc=\E8: +sc=\E7:se=\E[27m:sf=\ED:so=\E[7m:sr=\EM:ta=^I: +ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?25h:vi=\E[?25l: +vb=\E7\E[?5h\E[?5l\E[?5h\E[?5l\E[?5h\E[?5l\E[?5h\E[?5l\E8: __END__ =pod @@ -1457,6 +1492,10 @@ only way it can effectively detect and accommodate changes in terminal size. If you also need notification of this signal, the handler will trigger any callback assigned to the I<WINCH> attribute of the C<new> method. +I<WINCH> is not available on Windows. You will need to manually refresh your +screen B<^L> if you resize the terminal in Windows to clean up the text +however, this will not change the size of the pager itself. + =head1 ENVIRONMENT IO::Pager::Perl checks the I<TERM> and I<TERMCAP> variables. diff --git a/lib/IO/Pager/less.pm b/lib/IO/Pager/less.pm index 26db0fa..749f599 100644 --- a/lib/IO/Pager/less.pm +++ b/lib/IO/Pager/less.pm @@ -227,10 +227,6 @@ L<IO::Pager>, L<Term::Pager>, L<IO::Pager::Buffered>, L<IO::Pager::Page>, Jerrad Pierce <jpierce@cpan.org> -Florent Angly <florent.angly@gmail.com> - -This module was inspired by Monte Mitzelfelt's IO::Page 0.02 - Significant proddage provided by Tye McQueen. =head1 COPYRIGHT AND LICENSE diff --git a/lib/IO/Pager/tp b/lib/IO/Pager/tp index bc924ad..94a3a7b 100755 --- a/lib/IO/Pager/tp +++ b/lib/IO/Pager/tp @@ -6,7 +6,7 @@ use Term::ReadKey; use Getopt::Long; use vars '$VERSION'; -$VERSION = '2.01'; #Untouched since 2.01 +$VERSION = '2.10'; #Untouched since 2.10 my %Opts = (fold=>1); (my $LESS = $ENV{LESS} || '') =~ s/P.+(?:\$|$)//; @@ -18,6 +18,7 @@ $Opts{squeeze} = 1 if $LESS =~ /s/; $Opts{fold} = 0 if $LESS =~ /S/; $Opts{pause} = "\cL" if defined($ENV{MORE}) && $ENV{MORE} =~ /l/; +@ARGV = (map('-'.$_, split(//, $ENV{TPOPT})), @ARGV) if defined($ENV{TPOPT}); my %Long; #Custom argument processing @@ -145,7 +146,7 @@ to trigger this e.g; You might also supply a regular expression as STR e.g; - tp -f '[ie]t' bar #pauses on lines in bar with "i" or "e" in them + tp -f '[ie]t' bar #pauses on lines in bar with "it" or "et" in them =item B<-J> @@ -306,7 +307,13 @@ C<C-> is Control, C<M-> is Meta/Alt, C<S-> is Shift, and C<\d+> is a sequence of =head1 ENVIRONMENT -tp checks the I<LESS>, I<MORE>, I<TERM> and I<TERMCAP> variables. +tp checks the I<LESS>, I<MORE>, I<TPOPT>, I<TERM> and I<TERMCAP> variables. + +The I<TPOPT> variable is used to set options explicitly for tp, by +concatenating undecorated options together e.g; Sr for squished raw output. + +I<LESS> and I<MORE> are checked for options that tp supports, and if detected +they are enabled. =head1 SEE ALSO diff --git a/t/16-PurePerl_interactive.t b/t/16-PurePerl_interactive.t index c265e6d..98910e2 100644 --- a/t/16-PurePerl_interactive.t +++ b/t/16-PurePerl_interactive.t @@ -12,6 +12,7 @@ SKIP: { use blib; $ENV{PERL5OPT} = '-Mblib'; + $ENV{TPOPT} = '['; require IO::Pager; require IO::Pager::less; { @@ -23,13 +24,17 @@ SKIP: { #XXX repeating input loop, but cannot hurt to preserve the instructions warn "\n\nCurrent IO::Pager::Less is suboptimal \e[7;5m*** Press Ctrl-L to refresh ***\e[0m\n\n\n"; - $BOB->print("This pager is implemented in perl\n") foreach 1..25; + #XX $BOB->{scrollBar}=1; + + $BOB->print("This pager is implemented in perl. Note the nifty scrollbar at right.\n") foreach 1..250; $BOB->print("\nEnd of text, try pressing 'Q' to exit.\n"); } select STDERR; my $A1 = prompt("\nDid you see 'This pager is implemented in perl' in a pager? [Yn]"); ok is_yes($A1), 'OO, factory instantiation'; + my $A2 = prompt("\nDid the scrollbar update as you scrolled? [Yn]"); + ok is_yes($A2), 'Scrollbar works.'; } |