NAME

Text::Table::Boxed::Pager - Display table on terminal ala 'more'

SYNOPSIS

use Text::Table::Boxed;
use Text::Table::Boxed::Pager qw/view_table paginate_table/;

my $tb = Text::Table::Boxed->new({
  columns => [ ... ],
  style   => "boxrule",
});
$tb->load( ... );

$rows_before_quit = view_table($tb);

$text = paginate_table($tb, lines_per_page => 55);

DESCRIPTION

These demonstrate use of the "rows" feature of Text::Table::Boxed. See the code.

view_table($tb)

This displays a table on the terminal, pausing after each screen-full for the user to press ENTER (or q to stop).

The titles are re-displayed on every screen so they are always visible.

Multi-line rows are kept together on the same screen if possible.

RETURNS: The total number of table rows which were displayed, as either a positive or negative value. A negative value is returned if the user entered 'q' to quit early, and the absolute value indicates how far they got before giving up.

view_table() is an application of the more general paginate_table API.

$text = paginate_table($tb, pages_per_line => NUMER, OPTIONS)

This "paginates" a table for displaying NUMBER lines per page, by default returning all the output in a single string without user interaction. The table is rendered in sections which fit on a page, repeating the titles at the top of each page, etc.

OPTIONS

output_cb => SUBREF

A callback called to output one or more text fragments passed as parameterss. The default appends the fragments to an internal buffer which is eventually returned: output_cb => sub{ $buffer .= join("",@_) };

endpage_cb => SUBREF

A callback called at the bottom of each page. If it returns TRUE processing continues, otherwise processing aborts.

The default outputs endpage_text (via the output_cb callback).

endpage_text => "\f"

A string to output at the bottom of each page, by default a "form feed" character.

lpp_reduction => 0

A number of lines to leave unoccupied at the bottom of each page before calling the endpage_cb callback. Default is zero. (This is used by view_table to use the bottom line of each screen for user interaction.)

AUTHOR

Jim Avera (jim.avera at gmail)

LICENSE

CC0 or Public Domain. However your application is likely subject to the more restrictive licenses of Text::Table and other modules.