blib/lib/Term/Output/List.pm

filter: Statementstmt 80.7% 21 / 26 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 75.0% 30 / 40 SCAR 17.1
CC
5
Cov
72%
detect_terminal_type
8.1
new
2.1
BEGIN
1.0
CRAP 5.6
« blib/lib/Term/Output/List/ANSI.pm ↑ Summary
1 package Term::Output::List;
2 3 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Module::Load 'load';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our $VERSION = '0.03';
9  
10 =head1 NAME
11  
12 Term::Output::List - output an updateable list of ongoing jobs
13  
14 =head1 SYNOPSIS
15  
16 my $printer = Term::Output::List->new();
17 my @ongoing_tasks = ('file1: frobnicating', 'file2: bamboozling', 'file3: frobnicating');
18 $printer->output_list(@ongoing_tasks);
19  
20 $printer->output_permanent("Frobnicated gizmos"); # appears above the list
21  
22 =cut
23  
24 2 ▶sub detect_terminal_type($os = $^O) {
Subroutine detect_terminal_type: called CC=4 SCAR=20.9
Pod undocumented
25 2 ▶ if( $os eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($os eq 'MSWin32') { } 0 2 2
26 0 require Win32::Console;
27 0 ▶ if( Win32::Console->Mode & 0x0004 ) { #ENABLE_VIRTUAL_TERMINAL_PROCESSING
Branch: 1 branch
BranchTrueFalseTotal
if ('Win32::Console'->Mode & 4) { } 0 0 0
28 0 return 'ansi';
29 } else {
30 0 return 'win32'
31 }
32 } else {
33 2 return 'ansi';
34 }
35 }
36  
37 ▶sub new($class,%args) {
Subroutine new: called CC=2 SCAR=7.2
Pod documented
38 2 my $ttype = detect_terminal_type();
39
40 2 my $impl = 'Term::Output::List::ANSI';
41 2 ▶ if( $ttype eq 'win32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ttype eq "win32") 0 2 2
42 0 $impl = 'Term::Output::List::Win32';
43 }
44 2 load $impl;
45 2 return $impl->new( %args )
46 }
47  
48 =head1 METHODS
49  
50 =head2 C<< Term::Output::List->new() >>
51  
52 =cut
53  
54 =head2 C<< ->scroll_up >>
55  
56 Helper method to place the cursor at the top of the updateable list.
57  
58 =head2 C<< ->output_permanent >>
59  
60 $o->output_permanent("Frobnicated 3 items for job 2");
61 $o->output_list("Frobnicating 9 items for job 1",
62 "Frobnicating 2 items for job 3",
63 );
64  
65 Outputs items that should go on the permanent record. It is expected to
66 output the (remaining) list of ongoing jobs after that.
67  
68 =head2 C<< ->output_list @items >>
69  
70 $o->output_list("Frobnicating 9 items for job 1",
71 "Frobnicating 2 items for job 3",
72 );
73  
74 Outputs items that can be updated later, as long as no intervening output
75 (like from C<print>, C<say> or C<warn>) has happened. If you want to output
76 lines that should not be overwritten later, see C<</->output_permanent>>
77  
78 =head2 C<< ->fresh_output >>
79  
80 $o->fresh_output();
81  
82 Helper subroutine to make all items from the last output list remain as is.
83  
84 For compatibility between output to a terminal and output without a terminal,
85 you should use C<< ->output_permanent >> for things that should be permanent
86 instead.
87  
88 =cut
89  
90  
91 3 1;
« blib/lib/Term/Output/List/ANSI.pm ↑ Summary