line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::Output::List; |
2
|
3
|
|
|
3
|
|
1670
|
use 5.020; |
|
3
|
|
|
|
|
22
|
|
3
|
3
|
|
|
3
|
|
26
|
use feature 'signatures'; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
488
|
|
4
|
3
|
|
|
3
|
|
20
|
no warnings 'experimental::signatures'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
127
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1962
|
use Module::Load 'load'; |
|
3
|
|
|
|
|
3594
|
|
|
3
|
|
|
|
|
27
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
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
|
|
|
2
|
0
|
4
|
sub detect_terminal_type($os = $^O) { |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
4
|
|
25
|
2
|
50
|
|
|
|
11
|
if( $os eq 'MSWin32' ) { |
26
|
0
|
|
|
|
|
0
|
require Win32::Console; |
27
|
0
|
0
|
|
|
|
0
|
if( Win32::Console->Mode & 0x0004 ) { #ENABLE_VIRTUAL_TERMINAL_PROCESSING |
28
|
0
|
|
|
|
|
0
|
return 'ansi'; |
29
|
|
|
|
|
|
|
} else { |
30
|
0
|
|
|
|
|
0
|
return 'win32' |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} else { |
33
|
2
|
|
|
|
|
6
|
return 'ansi'; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
2
|
1
|
1001
|
sub new($class,%args) { |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
4
|
|
38
|
2
|
|
|
|
|
7
|
my $ttype = detect_terminal_type(); |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
6
|
my $impl = 'Term::Output::List::ANSI'; |
41
|
2
|
50
|
|
|
|
7
|
if( $ttype eq 'win32' ) { |
42
|
0
|
|
|
|
|
0
|
$impl = 'Term::Output::List::Win32'; |
43
|
|
|
|
|
|
|
} |
44
|
2
|
|
|
|
|
8
|
load $impl; |
45
|
2
|
|
|
|
|
33
|
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, C or C) 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
|
|
|
|
|
|
|
1; |