line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Perldoc::ToTerm; |
2
|
1
|
|
|
1
|
|
1450
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
$VERSION = '3.28'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use parent qw(Pod::Perldoc::BaseTo); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
|
sub is_pageable { 1 } |
11
|
0
|
|
|
0
|
0
|
|
sub write_with_binmode { 0 } |
12
|
0
|
|
|
0
|
0
|
|
sub output_extension { 'txt' } |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
791
|
use Pod::Text::Termcap (); |
|
1
|
|
|
|
|
10745
|
|
|
1
|
|
|
|
|
601
|
|
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
0
|
|
sub alt { shift->_perldoc_elem('alt' , @_) } |
17
|
0
|
|
|
0
|
0
|
|
sub indent { shift->_perldoc_elem('indent' , @_) } |
18
|
0
|
|
|
0
|
0
|
|
sub loose { shift->_perldoc_elem('loose' , @_) } |
19
|
0
|
|
|
0
|
0
|
|
sub quotes { shift->_perldoc_elem('quotes' , @_) } |
20
|
0
|
|
|
0
|
0
|
|
sub sentence { shift->_perldoc_elem('sentence', @_) } |
21
|
|
|
|
|
|
|
sub width { |
22
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
23
|
0
|
0
|
0
|
|
|
|
$self->_perldoc_elem('width' , @_) || |
|
|
|
0
|
|
|
|
|
24
|
|
|
|
|
|
|
$self->_get_columns_from_manwidth || |
25
|
|
|
|
|
|
|
$self->_get_columns_from_stty || |
26
|
|
|
|
|
|
|
$self->_get_default_width; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub pager_configuration { |
30
|
0
|
|
|
0
|
0
|
|
my($self, $pager, $perldoc) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# do not modify anything on Windows or DOS |
33
|
0
|
0
|
0
|
|
|
|
return if ( $perldoc->is_mswin32 || $perldoc->is_dos ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if ( $pager =~ /less/ ) { |
|
|
0
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->_maybe_modify_environment('LESS'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ( $pager =~ /more/ ) { |
39
|
0
|
|
|
|
|
|
$self->_maybe_modify_environment('MORE'); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _maybe_modify_environment { |
46
|
0
|
|
|
0
|
|
|
my($self, $name) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ( ! defined $ENV{$name} ) { |
49
|
0
|
|
|
|
|
|
$ENV{$name} = "-R"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# if the environment is set, don't modify |
53
|
|
|
|
|
|
|
# anything |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
|
|
sub _get_stty { `stty -a` } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _get_columns_from_stty { |
60
|
0
|
|
|
0
|
|
|
my $output = $_[0]->_get_stty; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if( $output =~ /\bcolumns\s+(\d+)/ ) { return $1; } |
|
0
|
0
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
elsif( $output =~ /;\s*(\d+)\s+columns;/ ) { return $1; } |
64
|
0
|
|
|
|
|
|
else { return 0 } |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _get_columns_from_manwidth { |
68
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
return 0 unless defined $ENV{MANWIDTH}; |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
unless( $ENV{MANWIDTH} =~ m/\A\d+\z/ ) { |
73
|
0
|
|
|
|
|
|
$self->warn( "Ignoring non-numeric MANWIDTH ($ENV{MANWIDTH})\n" ); |
74
|
0
|
|
|
|
|
|
return 0; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if( $ENV{MANWIDTH} == 0 ) { |
78
|
0
|
|
|
|
|
|
$self->warn( "Ignoring MANWIDTH of 0. Really? Why even run the program? :)\n" ); |
79
|
0
|
|
|
|
|
|
return 0; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if( $ENV{MANWIDTH} =~ m/\A(\d+)\z/ ) { return $1 } |
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _get_default_width { |
88
|
0
|
|
|
0
|
|
|
76 |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
0
|
|
0
|
0
|
0
|
|
sub new { return bless {}, ref($_[0]) || $_[0] } |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub parse_from_file { |
95
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$self->{width} = $self->width(); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my @options = |
100
|
0
|
|
|
|
|
|
map {; $_, $self->{$_} } |
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
grep !m/^_/s, |
102
|
|
|
|
|
|
|
keys %$self |
103
|
|
|
|
|
|
|
; |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
0
|
|
|
|
defined(&Pod::Perldoc::DEBUG) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
106
|
|
|
|
|
|
|
and Pod::Perldoc::DEBUG() |
107
|
|
|
|
|
|
|
and print "About to call new Pod::Text::Termcap ", |
108
|
|
|
|
|
|
|
$Pod::Text::VERSION ? "(v$Pod::Text::Termcap::VERSION) " : '', |
109
|
|
|
|
|
|
|
"with options: ", |
110
|
|
|
|
|
|
|
@options ? "[@options]" : "(nil)", "\n"; |
111
|
|
|
|
|
|
|
; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
Pod::Text::Termcap->new(@options)->parse_from_file(@_); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 NAME |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Pod::Perldoc::ToTerm - render Pod with terminal escapes |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SYNOPSIS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
perldoc -o term Some::Modulename |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 DESCRIPTION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This is a "plug-in" class that allows Perldoc to use |
129
|
|
|
|
|
|
|
Pod::Text as a formatter class. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
It supports the following options, which are explained in |
132
|
|
|
|
|
|
|
L: alt, indent, loose, quotes, sentence, width |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
For example: |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
perldoc -o term -w indent:5 Some::Modulename |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 PAGER FORMATTING |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Depending on the platform, and because this class emits terminal escapes it |
141
|
|
|
|
|
|
|
will attempt to set the C<-R> flag on your pager by injecting the flag into |
142
|
|
|
|
|
|
|
your environment variable for C or C. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
On Windows and DOS, this class will not modify any environment variables. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 CAVEAT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This module may change to use a different text formatter class in the |
149
|
|
|
|
|
|
|
future, and this may change what options are supported. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SEE ALSO |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L, L, L |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 COPYRIGHT AND DISCLAIMERS |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (c) 2017 Mark Allen. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
160
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
161
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 AUTHOR |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Mark Allen C<< >> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |