summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Pod/Perldoc/ToTerm.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Pod/Perldoc/ToTerm.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/Pod/Perldoc/ToTerm.pm49
1 files changed, 46 insertions, 3 deletions
diff --git a/Master/tlpkg/tlperl/lib/Pod/Perldoc/ToTerm.pm b/Master/tlpkg/tlperl/lib/Pod/Perldoc/ToTerm.pm
index f8d9349d10a..693b52a9059 100644
--- a/Master/tlpkg/tlperl/lib/Pod/Perldoc/ToTerm.pm
+++ b/Master/tlpkg/tlperl/lib/Pod/Perldoc/ToTerm.pm
@@ -3,7 +3,7 @@ use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '3.19';
+$VERSION = '3.23';
use parent qw(Pod::Perldoc::BaseTo);
@@ -18,13 +18,56 @@ sub indent { shift->_perldoc_elem('indent' , @_) }
sub loose { shift->_perldoc_elem('loose' , @_) }
sub quotes { shift->_perldoc_elem('quotes' , @_) }
sub sentence { shift->_perldoc_elem('sentence', @_) }
-sub width { shift->_perldoc_elem('width' , @_) }
+sub width {
+ my $self = shift;
+ $self->_perldoc_elem('width' , @_) ||
+ $self->_get_columns_from_manwidth ||
+ $self->_get_columns_from_stty ||
+ $self->_get_default_width;
+}
+
+sub _get_stty { `stty -a` }
+
+sub _get_columns_from_stty {
+ my $output = $_[0]->_get_stty;
+
+ if( $output =~ /\bcolumns\s+(\d+)/ ) { return $1; }
+ elsif( $output =~ /;\s*(\d+)\s+columns;/ ) { return $1; }
+ else { return 0 }
+ }
+
+sub _get_columns_from_manwidth {
+ my( $self ) = @_;
+
+ return 0 unless defined $ENV{MANWIDTH};
+
+ unless( $ENV{MANWIDTH} =~ m/\A\d+\z/ ) {
+ $self->warn( "Ignoring non-numeric MANWIDTH ($ENV{MANWIDTH})\n" );
+ return 0;
+ }
+
+ if( $ENV{MANWIDTH} == 0 ) {
+ $self->warn( "Ignoring MANWIDTH of 0. Really? Why even run the program? :)\n" );
+ return 0;
+ }
+
+ if( $ENV{MANWIDTH} =~ m/\A(\d+)\z/ ) { return $1 }
+
+ return 0;
+ }
+
+sub _get_default_width {
+ 76
+ }
+
sub new { return bless {}, ref($_[0]) || $_[0] }
sub parse_from_file {
my $self = shift;
+ $self->{width} = $self->width();
+
my @options =
map {; $_, $self->{$_} }
grep !m/^_/s,
@@ -34,7 +77,7 @@ sub parse_from_file {
defined(&Pod::Perldoc::DEBUG)
and Pod::Perldoc::DEBUG()
and print "About to call new Pod::Text::Termcap ",
- $Pod::Text::VERSION ? "(v$Pod::Text::VERSION) " : '',
+ $Pod::Text::VERSION ? "(v$Pod::Text::Termcap::VERSION) " : '',
"with options: ",
@options ? "[@options]" : "(nil)", "\n";
;