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-2023 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
512
|
use v5.26; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
28
|
|
8
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
30
|
use Object::Pad 0.800; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
54
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package App::sdview::Output::Terminal 0.11; |
13
|
|
|
|
|
|
|
class App::sdview::Output::Terminal |
14
|
|
|
|
|
|
|
:isa(App::sdview::Output::Formatted) |
15
|
1
|
|
|
1
|
|
669
|
:strict(params); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
190
|
use constant format => "terminal"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw( blessed ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
20
|
1
|
|
|
1
|
|
614
|
use String::Tagged::Terminal; |
|
1
|
|
|
|
|
8900
|
|
|
1
|
|
|
|
|
44
|
|
21
|
1
|
|
|
1
|
|
6
|
use Term::Size; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
589
|
|
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
|
0
|
|
|
|
|
|
method setup_output () |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
|
{ |
46
|
0
|
0
|
|
|
|
|
if( -T STDOUT ) { |
47
|
0
|
|
|
|
|
|
open my $outh, "|-", "less", "-R"; |
48
|
0
|
|
|
|
|
|
$outh->binmode( ":encoding(UTF-8)" ); |
49
|
0
|
|
|
|
|
|
select $outh; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
method width () |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
0
|
|
{ |
55
|
0
|
|
|
|
|
|
return scalar Term::Size::chars; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
method say ( @s ) |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
0
|
|
{ |
60
|
|
|
|
|
|
|
say map { |
61
|
0
|
0
|
|
|
|
|
blessed $_ ? String::Tagged::Terminal->new_from_formatting($_)->build_terminal : "$_" |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} @s; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Paul Evans |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
0x55AA; |