| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
|
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2021-2024 -- leonerd@leonerd.org.uk |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
771
|
use v5.26; |
|
|
1
|
|
|
|
|
4
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
81
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
54
|
use Object::Pad 0.807; |
|
|
1
|
|
|
|
|
41
|
|
|
|
1
|
|
|
|
|
62
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package App::sdview::Output::Terminal 0.20; |
|
13
|
|
|
|
|
|
|
class App::sdview::Output::Terminal :strict(params); |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1410
|
inherit App::sdview::Output::Formatted; |
|
|
1
|
|
|
|
|
23
|
|
|
|
1
|
|
|
|
|
75
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
9
|
use constant format => "terminal"; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
111
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
9
|
use Scalar::Util qw( blessed ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
84
|
|
|
20
|
1
|
|
|
1
|
|
797
|
use String::Tagged::Terminal 0.08; # for OSC 8 hyperlink support |
|
|
1
|
|
|
|
|
14755
|
|
|
|
1
|
|
|
|
|
115
|
|
|
21
|
1
|
|
|
1
|
|
10
|
use Term::Size; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1356
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
C - generate terminal formatted output from L |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$ sdview README.pod -o terminal |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
(though this is likely the default output mode) |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This output module generates formatted output with embedded terminal control |
|
36
|
|
|
|
|
|
|
codes, allowing colours and formatting information to be displayed on a |
|
37
|
|
|
|
|
|
|
terminal. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
By default, if the process standard output stream appears to be a TTY device, |
|
40
|
|
|
|
|
|
|
the output is piped via F to act as a simple iteractive pager. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 OPTIONS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item -O nopager |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Disables use of F as an output pager, causing output to be printed to |
|
51
|
|
|
|
|
|
|
the terminal directly. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item -O width=NN |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Overrides the detected width of the terminal. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
field $pager :param = !!1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# TODO: Is this the neatest way to do this? |
|
64
|
|
|
|
|
|
|
ADJUST :params ( :$nopager = undef ) { |
|
65
|
|
|
|
|
|
|
$pager = !!0 if $nopager; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
0
|
|
field $width :param :reader = scalar Term::Size::chars; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
0
|
0
|
|
method setup_output () |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
{ |
|
72
|
0
|
0
|
0
|
|
|
|
if( $pager and -T STDOUT ) { |
|
73
|
0
|
|
|
|
|
|
open my $outh, "|-", "less", "-R"; |
|
74
|
0
|
|
|
|
|
|
$outh->binmode( ":encoding(UTF-8)" ); |
|
75
|
0
|
|
|
|
|
|
select $outh; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
else { |
|
78
|
0
|
|
|
|
|
|
STDOUT->binmode( ":encoding(UTF-8)" ); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
0
|
0
|
|
method say ( @s ) |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
{ |
|
84
|
|
|
|
|
|
|
say map { |
|
85
|
0
|
0
|
|
|
|
|
blessed $_ ? String::Tagged::Terminal->new_from_formatting($_)->build_terminal : "$_" |
|
|
0
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} @s; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Paul Evans |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
0x55AA; |