Termcap.pm revision 1
1N/A# Pod::Text::Termcap -- Convert POD data to ASCII text with format escapes. 1N/A# Copyright 1999, 2001, 2002 by Russ Allbery <rra@stanford.edu> 1N/A# This program is free software; you may redistribute it and/or modify it 1N/A# under the same terms as Perl itself. 1N/A# This is a simple subclass of Pod::Text that overrides a few key methods to 1N/A# output the right termcap escape sequences for formatted text on the current 1N/A############################################################################## 1N/A# Modules and declarations 1N/A############################################################################## 1N/A# Don't use the CVS revision as the version, since this module is also in Perl 1N/A# core and too many things could munge CVS magic revision strings. This 1N/A# number should ideally be the same as the CVS revision in podlators, however. 1N/A############################################################################## 1N/A############################################################################## 1N/A# In the initialization method, grab our terminal characteristics as well as 1N/A# do all the stuff we normally do. 1N/A # $ENV{HOME} is usually not set on Windows. The default Term::Cap path 1N/A # may not work on Solaris. 1N/A # Fall back on a hard-coded terminal speed if POSIX::Termios isn't 1N/A # available (such as on VMS). 1N/A # Fall back on the ANSI escape sequences if Term::Cap doesn't work. 1N/A# Make level one headings bold. 1N/A# Make level two headings bold. 1N/A# Fix up B<> and I<>. Note that we intentionally don't do F<>. 1N/Asub seq_b {
my $
self =
shift;
return "$$self{BOLD}$_[0]$$self{NORM}" }
1N/Asub seq_i {
my $
self =
shift;
return "$$self{UNDL}$_[0]$$self{NORM}" }
1N/A# Output any included code in bold. 1N/A# Override the wrapping code to igore the special sequences. 1N/A my $
code =
"(?:\Q$$self{BOLD}\E|\Q$$self{UNDL}\E|\Q$$self{NORM}\E)";
1N/A############################################################################## 1N/A# Module return value and documentation 1N/A############################################################################## 1N/APod::Text::Termcap - Convert POD data to ASCII text with format escapes 1N/A use Pod::Text::Termcap; 1N/A my $parser = Pod::Text::Termcap->new (sentence => 0, width => 78); 1N/A # Read POD from STDIN and write to STDOUT. 1N/A $parser->parse_from_filehandle; 1N/APod::Text::Termcap is a simple subclass of Pod::Text that highlights output 1N/Atext using the correct termcap escape sequences for the current terminal. 1N/AApart from the format codes, it in all ways functions like Pod::Text. See 1N/AL<Pod::Text> for details and available options. 1N/AThis module uses Term::Cap to retrieve the formatting escape sequences for 1N/Athe current terminal, and falls back on the ECMA-48 (the same in this 1N/Aregard as ANSI X3.64 and ISO 6429, the escape codes also used by DEC VT100 1N/Aterminals) if the bold, underline, and reset codes aren't set in the 1N/AL<Pod::Text>, L<Pod::Parser>, L<Term::Cap> 1N/AThe current version of this module is always available from its web site at 1N/APerl core distribution as of 5.6.0. 1N/ARuss Allbery <rra@stanford.edu>. 1N/A=head1 COPYRIGHT AND LICENSE 1N/ACopyright 1999, 2001, 2002 by Russ Allbery <rra@stanford.edu>. 1N/AThis program is free software; you may redistribute it and/or modify it 1N/Aunder the same terms as Perl itself.