.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "IO::Pager::Perl 3" .TH IO::Pager::Perl 3 "2019-10-08" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" IO::Pager::Perl \- Page text a screenful at a time, like more or less .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Term:ReadKey; #Optional, but recommended \& use IO::Pager::Perl; \& \& my $t = IO::Pager::Perl\->new( rows => 25, cols => 80 ); \& $t\->add_text( $text ); \& $t\->more(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a module for paging through text one screenful at a time. It supports the features you expectcusing the shortcuts you expect. .PP IO::Pager::Perl is an enhanced fork of Term::Pager. .SH "USAGE" .IX Header "USAGE" .SS "Create the Pager" .IX Subsection "Create the Pager" .Vb 1 \& $t = IO::Pager::Perl\->new( option => value, ... ); .Ve .PP If no options are specified, sensible default values will be used. The following options are recognized, and shown with the default value: .IP "\fIrows\fR =>25?" 4 .IX Item "rows =>25?" The number of rows on your terminal. The terminal is queried directly with Term::ReadKey if loaded or \f(CW\*(C`stty\*(C'\fR or \f(CW\*(C`tput\*(C'\fR, and if these fail it defaults to 25. .IP "\fIcols\fR =>80?" 4 .IX Item "cols =>80?" The number of columns on your terminal. The terminal is queried directly with Term::ReadKey if loaded or \f(CW\*(C`stty\*(C'\fR or \f(CW\*(C`tput\*(C'\fR, and if these fail it defaults to 80. .IP "\fIspeed\fR =>38400?" 4 .IX Item "speed =>38400?" The speed (baud rate) of your terminal. The terminal is queried directly with Term::ReadKey if loaded or \f(CW\*(C`stty\*(C'\fR, and if these fail it defaults to a sensible value. .IP "\fIeof\fR =>0" 4 .IX Item "eof =>0" Exit at end of file. .IP "\fIfold\fR =>1" 4 .IX Item "fold =>1" Wrap long lines. .IP "\fIlineNo\fR =>0" 4 .IX Item "lineNo =>0" If true, line numbering is added to the output. .IP "\fIpause\fR =>0" 4 .IX Item "pause =>0" If defined, the pager will pause when the this character sequence is encountered in the input text. Set to ^L i.e; \*(L"\ecL\*(R" to mimic traditional behavior of \*(L"1\*(R" in more. .IP "\fIraw\fR =>0" 4 .IX Item "raw =>0" Pass control characters from input unadulterated to the terminal. By default, chracters other than tab and newline will be converted to caret notation e.g; ^@ for null or ^L for form feed. .IP "\fIsqueeze\fR =>0" 4 .IX Item "squeeze =>0" Collapse multiple blank lines into one. .IP "\fIstatusCol\fR =>0" 4 .IX Item "statusCol =>0" Add a column with markers indicating which row match a search expression. .IP "\fIvisualBeep\fR =>0" 4 .IX Item "visualBeep =>0" Flash the screen when beeping. .PP \fIAccessors\fR .IX Subsection "Accessors" .PP There are accessors for all of the above properties, however those for rows, cols, speed, fold and squeeze are read only. .PP .Vb 2 \& #Is visualBeep set? \& $t\->visualBeep(); \& \& #Enable line numbering \& $t\->lineNo(1); .Ve .SS "Adding Text" .IX Subsection "Adding Text" You will need some text to page through. You can specify text as as a parameter to the constructor: .PP .Vb 1 \& text => $text .Ve .PP Or even add text later: .PP .Vb 1 \& $t\->add_text( $text ); .Ve .PP If you wish to continuously add text to the pager, you must setup your own event loop, and indicate to \f(CW\*(C`more\*(C'\fR that it should relinquish control e.g; .PP .Vb 6 \& eval{ \& while( $t\->more(RT=>.05) ){ \& ... \& $t\->add_text("More text to page"); \& } \& }; .Ve .PP The eval block captures the exception thrown upon termination of the pager so that your own program may continue. The \fI\s-1RT\s0\fR parameter indicates that you wish to provide content in real time. This value is also passed to \&\*(L"ReadKey\*(R" in Term::ReadKey as the maximum blocking time per keypress and should be between 0 and 1, with larger values trading greater interface responsiveness for slight delays in output. A value of \-1 may also be used to request non-blocking polls, but likely will not behave as you would hope. .PP \&\s-1NOTE:\s0 If Term::ReadKey is not loaded but \s-1RT\s0 is true, screen updates will only occur on keypress. .SS "Adding Functionality and Internationalization (I18N)" .IX Subsection "Adding Functionality and Internationalization (I18N)" It is possible to extend the features of IO::Pager::Perl by supplying the \&\f(CW\*(C`add_func\*(C'\fR method with a hash of character keys and callback values to be invoked upon matching keypress; where \ec? represents Control\-? and \ee? represents Alt\-? The existing pairings are: .PP .Vb 10 \& \*(Aqh\*(Aq => \e&help, \& \*(Aqq\*(Aq => \e&done, \& \*(Aqr\*(Aq => \e&refresh, #also "\ecL" \& "\en"=> \e&downline, #also "\ee[B" \& \*(Aq \*(Aq => \e&downpage, #also "\ecv" \& \*(Aqd\*(Aq => \e&downhalf, \& \*(Aqb\*(Aq => \e&uppage, #also "\eev" \& \*(Aqy\*(Aq => \e&upline, #also "\ee[A" \& \*(Aqu\*(Aq => \e&uphalf, \& \*(Aqg\*(Aq => \e&to_top, #also \*(Aq<\*(Aq \& \*(AqG\*(Aq => \e&to_bott, #also \*(Aq>\*(Aq \& \*(Aq/\*(Aq => \e&search, \& \*(Aq?\*(Aq => \e&hcraes, #reverse search \& \*(Aqn\*(Aq => \e&next_match, #also \*(AqP\*(Aq \& \*(Aqp\*(Aq => \e&prev_match, #also \*(AqN\*(Aq \& "\ee[D" => \e&move_left, \& "\ee[C" => \e&move_right, \& \*(Aq#\*(Aq => \e&toggle_numbering, .Ve .PP And a special sequence of a number followed by enter analogous to: .PP .Vb 1 \& \*(Aq/(\ed+)/\*(Aq => \e&jump(\e1) .Ve .PP if the value for that key is true. .PP The \f(CW\*(C`dialog\*(C'\fR method may be particularly useful when enhancing the pager. It accepts a string to display, and an optional timeout to sleep for before the dialog is cleared. If the timeout is missing or 0, the dialog remains until a key is pressed. .PP .Vb 4 \& my $t = IO::Pager::Perl\->new(); \& $t\->add_text("Text to display"); \& $t\->add_func(\*(Aq!\*(Aq=>\e&boo); \& $t\->more(); \& \& sub boo{ my $self = shift; $self\->dialog("BOO!", 1); } .Ve .PP Should you add additional functionality to your pager, you will likely want to change the contents of the help dialog or possibly the status line. Use the \&\f(CW\*(C`I18N\*(C'\fR method to replace the default text or save text for your own interface. .PP .Vb 2 \& #Get the default help text \& my $help = $t\->I18N(\*(Aqhelp\*(Aq); \& \& #Minimal status line \& $t\->I18N(\*(Aqprompt\*(Aq, " help"); .Ve .PP Current text elements available for customization are: .PP .Vb 7 \& 404 \- search text not found dialog \& bottom \- prompt line end of file indicator \& continue \- text to display at the bottom of the help dialog \& help \- help dialog text, a list of keys and their functions \& prompt \- displayed at the bottom of the screen \& status \- brief message to include in the status line \& top \- prompt line start of file indicator .Ve .PP \&\fIstatus\fR is intended for sharing short messages not worthy of a dialog e.g; when debugging. You will need to call the \f(CW\*(C`prompt\*(C'\fR method after setting it to refresh the status line of the display, then void \fIstatus\fR and call \f(CW\*(C`prompt\*(C'\fR again to clear the message. .PP \fIScalability\fR .IX Subsection "Scalability" .PP The help text will be split in two horizontally on a null character if the text is wider than the display, and shown in two sequential dialogs. .PP Similarly, the status text will be cropped at a null character for narrow displays. .SH "CAVEATS" .IX Header "CAVEATS" .SS "UN*X" .IX Subsection "UN*X" This modules currently only works in UN*X\-like environment. .SS "Performance" .IX Subsection "Performance" For simplicity, the current implementation loads the entire message to view at once; thus not requiring a distinction between piped contents and files. This may require significant memory for large files. .SS "Termcap" .IX Subsection "Termcap" This module uses Termcap, which has been deprecated the Open Group, and may not be supported by your operating system for much longer. .PP If the termcap entry for your ancient esoteric terminal is wrong or incomplete, this module may either fill your screen with unintelligible gibberish, or drop back to a feature-free mode. .PP Eventually, support for Terminfo may also be added. .SS "Signals" .IX Subsection "Signals" IO::Pager::Perl sets a global signal handler for \fI\s-1SIGWINCH\s0\fR, this is the 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 \fI\s-1WINCH\s0\fR attribute of the \f(CW\*(C`new\*(C'\fR method. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" IO::Pager::Perl checks the \fI\s-1TERM\s0\fR and \fI\s-1TERMCAP\s0\fR variables. .SH "SEE ALSO" .IX Header "SEE ALSO" IO::Pager, Term::Cap, Term::ReadKey, \&\fBtermcap\fR\|(5), \fBstty\fR\|(1), \fBtput\fR\|(1), \fBless\fR\|(1) .SH "AUTHORS" .IX Header "AUTHORS" .Vb 1 \& Jerrad Pierce jpierce@cpan.org \& \& Jeff Weisberg \- http://www.tcp4me.com .Ve .SH "LICENSE" .IX Header "LICENSE" This software may be copied and distributed under the terms found in the Perl \*(L"Artistic License\*(R". .PP A copy of the \*(L"Artistic License\*(R" may be found in the standard Perl distribution.