NAME

Term::Output::List::ANSI - output an updateable list of ongoing jobs to an ANSI terminal

SYNOPSIS

my $printer = Term::Output::List->new(
    hook_warnings => 1,
);
my @ongoing_tasks = ('file1: frobnicating', 'file2: bamboozling', 'file3: frobnicating');
$printer->output_list(@ongoing_tasks);

$printer->output_permanent("Frobnicated gizmos"); # appears above the list

MEMBERS

fh

Filehandle used for output. Default is STDOUT.

interactive

Whether the script is run interactively and should output intermittent updateable information

hook_warnings

Install a hook for sending warnings to ->output_permanent. This prevents ugly tearing/overwriting when your code outputs warnings.

METHODS

Term::Output::List::ANSI->new()

my $output = Term::Output::List::ANSI->new(
    hook_warnings => 1,
)
hook_warnings

Install a hook for sending warnings to ->output_permanent. This prevents ugly tearing/overwriting when your code outputs warnings.

width

Width of the terminal. This is initialized at first use. You may (or may not) want to set up a $SIG{WINCH} handler to set the terminal width when the terminal size changes.

METHODS

Term::Output::List->new()

->scroll_up

Helper method to place the cursor at the top of the updateable list.

->output_permanent

$o->output_permanent("Frobnicated 3 items for job 2");
$o->output_list("Frobnicating 9 items for job 1",
                "Frobnicating 2 items for job 3",
);

Outputs items that should go on the permanent record. It is expected to output the (remaining) list of ongoing jobs after that.

->output_list @items

$o->output_list("Frobnicating 9 items for job 1",
                "Frobnicating 2 items for job 3",
);

Outputs items that can be updated later, as long as no intervening output (like from print, say or warn) has happened. If you want to output lines that should not be overwritten later, see </-output_permanent>>

->fresh_output

$o->fresh_output();

Helper subroutine to make all items from the last output list remain as is.

For compatibility between output to a terminal and output without a terminal, you should use ->output_permanent for things that should be permanent instead.