2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml">
5 <title>Term::Cap - Perl termcap interface
</title>
6 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
7 <link rev=
"made" href=
"mailto:" />
10 <body style=
"background-color: white">
11 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
12 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
13 <big><strong><span class=
"block"> Term::Cap - Perl termcap interface
</span></strong></big>
17 <p><a name=
"__index__"></a></p>
22 <li><a href=
"#name">NAME
</a></li>
23 <li><a href=
"#synopsis">SYNOPSIS
</a></li>
24 <li><a href=
"#description">DESCRIPTION
</a></li>
27 <li><a href=
"#methods">METHODS
</a></li>
30 <li><a href=
"#examples">EXAMPLES
</a></li>
31 <li><a href=
"#copyright_and_license">COPYRIGHT AND LICENSE
</a></li>
32 <li><a href=
"#author">AUTHOR
</a></li>
33 <li><a href=
"#see_also">SEE ALSO
</a></li>
40 <h1><a name=
"name">NAME
</a></h1>
41 <p>Term::Cap - Perl termcap interface
</p>
45 <h1><a name=
"synopsis">SYNOPSIS
</a></h1>
48 $terminal = Tgetent Term::Cap { TERM =
> undef, OSPEED =
> $ospeed };
49 $terminal-
>Trequire(qw/ce ku kd/);
50 $terminal-
>Tgoto('cm', $col, $row, $FH);
51 $terminal-
>Tputs('dl', $count, $FH);
52 $terminal-
>Tpad($string, $count, $FH);
</pre>
56 <h1><a name=
"description">DESCRIPTION
</a></h1>
57 <p>These are low-level functions to extract and use capabilities from
58 a terminal capability (termcap) database.
</p>
59 <p>More information on the terminal capabilities will be found in the
60 termcap manpage on most Unix-like systems.
</p>
63 <h2><a name=
"methods">METHODS
</a></h2>
64 <p>The output strings for
<strong>Tputs
</strong> are cached for counts of
1 for performance.
65 <strong>Tgoto
</strong> and
<strong>Tpad
</strong> do not cache.
<code>$self-
>{_xx}
</code> is the raw termcap
66 data and
<code>$self-
>{xx}
</code> is the cached version.
</p>
68 print $terminal-
>Tpad($self-
>{_xx},
1);
</pre>
69 <p><strong>Tgoto
</strong>,
<strong>Tputs
</strong>, and
<strong>Tpad
</strong> return the string and will also
70 output the string to $FH if specified.
</p>
72 <dt><strong><a name=
"item_tgetent"><strong>Tgetent
</strong></a></strong>
75 <p>Returns a blessed object reference which the user can
76 then use to send the control strings to the terminal using
<strong>Tputs
</strong>
77 and
<strong>Tgoto
</strong>.
</p>
80 <p>The function extracts the entry of the specified terminal
81 type
<em>TERM
</em> (defaults to the environment variable
<em>TERM
</em>) from the
85 <p>It will look in the environment for a
<em>TERMCAP
</em> variable. If
86 found, and the value does not begin with a slash, and the terminal
87 type name is the same as the environment string
<em>TERM
</em>, the
88 <em>TERMCAP
</em> string is used instead of reading a termcap file. If
89 it does begin with a slash, the string is used as a path name of
90 the termcap file to search. If
<em>TERMCAP
</em> does not begin with a
91 slash and name is different from
<em>TERM
</em>,
<strong>Tgetent
</strong> searches the
92 files
<em>$HOME/.termcap
</em>,
<em>/etc/termcap
</em>, and
<em>/usr/share/misc/termcap
</em>,
93 in that order, unless the environment variable
<em>TERMPATH
</em> exists,
94 in which case it specifies a list of file pathnames (separated by
95 spaces or colons) to be searched
<strong>instead
</strong>. Whenever multiple
96 files are searched and a tc field occurs in the requested entry,
97 the entry it names must be found in the same file or one of the
98 succeeding files. If there is a
<code>:tc=...:
</code> in the
<em>TERMCAP
</em>
99 environment variable string it will continue the search in the
103 <p>The extracted termcap entry is available in the object
104 as
<code>$self-
>{TERMCAP}
</code>.
</p>
107 <p>It takes a hash reference as an argument with two optional keys:
</p>
110 <dt><strong><a name=
"item_ospeed">OSPEED
</a></strong>
113 <p>The terminal output bit rate (often mistakenly called the baud rate)
114 for this terminal - if not set a warning will be generated
115 and it will be defaulted to
9600.
<em>OSPEED
</em> can be be specified as
116 either a POSIX termios/SYSV termio speeds (where
9600 equals
9600) or
117 an old DSD-style speed ( where
13 equals
9600).
</p>
120 <dt><strong><a name=
"item_term">TERM
</a></strong>
123 <p>The terminal type whose termcap entry will be used - if not supplied it will
124 default to $ENV{TERM}: if that is not set then
<strong>Tgetent
</strong> will croak.
</p>
128 <p>It calls
<code>croak
</code> on failure.
</p>
129 <dt><strong><a name=
"item_tpad"><strong>Tpad
</strong></a></strong>
132 <p>Outputs a literal string with appropriate padding for the current terminal.
</p>
135 <p>It takes three arguments:
</p>
138 <dt><strong><a name=
"item__string"><strong>$string
</strong></a></strong>
141 <p>The literal string to be output. If it starts with a number and an optional
142 '*' then the padding will be increased by an amount relative to this number,
143 if the '*' is present then this amount will me multiplied by $cnt. This part
144 of $string is removed before output/
</p>
147 <dt><strong><a name=
"item__cnt"><strong>$cnt
</strong></a></strong>
150 <p>Will be used to modify the padding applied to string as described above.
</p>
153 <dt><strong><a name=
"item__fh"><strong>$FH
</strong></a></strong>
156 <p>An optional filehandle (or IO::Handle ) that output will be printed to.
</p>
160 <p>The padded $string is returned.
</p>
161 <dt><strong><a name=
"item_tputs"><strong>Tputs
</strong></a></strong>
164 <p>Output the string for the given capability padded as appropriate without
165 any parameter substitution.
</p>
168 <p>It takes three arguments:
</p>
171 <dt><strong><a name=
"item__cap"><strong>$cap
</strong></a></strong>
174 <p>The capability whose string is to be output.
</p>
177 <dt><strong><strong>$cnt
</strong></strong>
180 <p>A count passed to Tpad to modify the padding applied to the output string.
181 If $cnt is zero or one then the resulting string will be cached.
</p>
184 <dt><strong><strong>$FH
</strong></strong>
187 <p>An optional filehandle (or IO::Handle ) that output will be printed to.
</p>
191 <p>The appropriate string for the capability will be returned.
</p>
192 <dt><strong><a name=
"item_tgoto"><strong>Tgoto
</strong></a></strong>
195 <p><strong>Tgoto
</strong> decodes a cursor addressing string with the given parameters.
</p>
198 <p>There are four arguments:
</p>
201 <dt><strong><strong>$cap
</strong></strong>
204 <p>The name of the capability to be output.
</p>
207 <dt><strong><a name=
"item__col"><strong>$col
</strong></a></strong>
210 <p>The first value to be substituted in the output string ( usually the column
211 in a cursor addressing capability )
</p>
214 <dt><strong><a name=
"item__row"><strong>$row
</strong></a></strong>
217 <p>The second value to be substituted in the output string (usually the row
218 in cursor addressing capabilities)
</p>
221 <dt><strong><strong>$FH
</strong></strong>
224 <p>An optional filehandle (or IO::Handle ) to which the output string will be
229 <p>Substitutions are made with $col and $row in the output string with the
230 following
<code>sprintf()
</code> line formats:
</p>
233 %d output value as in printf %d
234 %
2 output value as in printf %
2d
235 %
3 output value as in printf %
3d
236 %. output value as in printf %c
237 %+x add x to value, then do %.
</pre>
239 %
>xy if value
> x then add y, no output
240 %r reverse order of two parameters, no output
241 %i increment by one, no output
242 %B BCD (
16*(value/
10)) + (value%
10), no output
</pre>
244 %n exclusive-or all parameters with
0140 (Datamedia
2500)
245 %D Reverse coding (value -
2*(value%
16)), no output (Delta Data)
</pre>
246 <p>The output string will be returned.
</p>
247 <dt><strong><a name=
"item_trequire"><strong>Trequire
</strong></a></strong>
250 <p>Takes a list of capabilities as an argument and will croak if one is not
258 <h1><a name=
"examples">EXAMPLES
</a></h1>
262 # Get terminal output speed
264 my $termios = new POSIX::Termios;
265 $termios-
>getattr;
266 my $ospeed = $termios-
>getospeed;
</pre>
268 # Old-style ioctl code to get ospeed:
269 # require 'ioctl.pl';
270 # ioctl(TTY,$TIOCGETP,$sgtty);
271 # ($ispeed,$ospeed) = unpack('cc',$sgtty);
</pre>
273 # allocate and initialize a terminal structure
274 $terminal = Tgetent Term::Cap { TERM =
> undef, OSPEED =
> $ospeed };
</pre>
276 # require certain capabilities to be available
277 $terminal-
>Trequire(qw/ce ku kd/);
</pre>
279 # Output Routines, if $FH is undefined these just return the string
</pre>
281 # Tgoto does the % expansion stuff with the given args
282 $terminal-
>Tgoto('cm', $col, $row, $FH);
</pre>
284 # Tputs doesn't do any % expansion.
285 $terminal-
>Tputs('dl', $count =
1, $FH);
</pre>
289 <h1><a name=
"copyright_and_license">COPYRIGHT AND LICENSE
</a></h1>
290 <p>Please see the README file in distribution.
</p>
294 <h1><a name=
"author">AUTHOR
</a></h1>
295 <p>This module is part of the core Perl distribution and is also maintained
296 for CPAN by Jonathan Stowe
<<a href=
"mailto:jns@gellyfish.com">jns@gellyfish.com
</a>>.
</p>
300 <h1><a name=
"see_also">SEE ALSO
</a></h1>
301 <p><code>termcap(
5)
</code></p>
302 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
303 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
304 <big><strong><span class=
"block"> Term::Cap - Perl termcap interface
</span></strong></big>