| 1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
| 2 | .\" |
| 3 | .\" Standard preamble: |
| 4 | .\" ======================================================================== |
| 5 | .de Sh \" Subsection heading |
| 6 | .br |
| 7 | .if t .Sp |
| 8 | .ne 5 |
| 9 | .PP |
| 10 | \fB\\$1\fR |
| 11 | .PP |
| 12 | .. |
| 13 | .de Sp \" Vertical space (when we can't use .PP) |
| 14 | .if t .sp .5v |
| 15 | .if n .sp |
| 16 | .. |
| 17 | .de Vb \" Begin verbatim text |
| 18 | .ft CW |
| 19 | .nf |
| 20 | .ne \\$1 |
| 21 | .. |
| 22 | .de Ve \" End verbatim text |
| 23 | .ft R |
| 24 | .fi |
| 25 | .. |
| 26 | .\" Set up some character translations and predefined strings. \*(-- will |
| 27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left |
| 28 | .\" double quote, and \*(R" will give a right double quote. | will give a |
| 29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to |
| 30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' |
| 31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. |
| 32 | .tr \(*W-|\(bv\*(Tr |
| 33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' |
| 34 | .ie n \{\ |
| 35 | . ds -- \(*W- |
| 36 | . ds PI pi |
| 37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch |
| 38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch |
| 39 | . ds L" "" |
| 40 | . ds R" "" |
| 41 | . ds C` "" |
| 42 | . ds C' "" |
| 43 | 'br\} |
| 44 | .el\{\ |
| 45 | . ds -- \|\(em\| |
| 46 | . ds PI \(*p |
| 47 | . ds L" `` |
| 48 | . ds R" '' |
| 49 | 'br\} |
| 50 | .\" |
| 51 | .\" If the F register is turned on, we'll generate index entries on stderr for |
| 52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index |
| 53 | .\" entries marked with X<> in POD. Of course, you'll have to process the |
| 54 | .\" output yourself in some meaningful fashion. |
| 55 | .if \nF \{\ |
| 56 | . de IX |
| 57 | . tm Index:\\$1\t\\n%\t"\\$2" |
| 58 | .. |
| 59 | . nr % 0 |
| 60 | . rr F |
| 61 | .\} |
| 62 | .\" |
| 63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 64 | .\" way too many mistakes in technical documents. |
| 65 | .hy 0 |
| 66 | .if n .na |
| 67 | .\" |
| 68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). |
| 69 | .\" Fear. Run. Save yourself. No user-serviceable parts. |
| 70 | . \" fudge factors for nroff and troff |
| 71 | .if n \{\ |
| 72 | . ds #H 0 |
| 73 | . ds #V .8m |
| 74 | . ds #F .3m |
| 75 | . ds #[ \f1 |
| 76 | . ds #] \fP |
| 77 | .\} |
| 78 | .if t \{\ |
| 79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) |
| 80 | . ds #V .6m |
| 81 | . ds #F 0 |
| 82 | . ds #[ \& |
| 83 | . ds #] \& |
| 84 | .\} |
| 85 | . \" simple accents for nroff and troff |
| 86 | .if n \{\ |
| 87 | . ds ' \& |
| 88 | . ds ` \& |
| 89 | . ds ^ \& |
| 90 | . ds , \& |
| 91 | . ds ~ ~ |
| 92 | . ds / |
| 93 | .\} |
| 94 | .if t \{\ |
| 95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" |
| 96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' |
| 97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' |
| 98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' |
| 99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' |
| 100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' |
| 101 | .\} |
| 102 | . \" troff and (daisy-wheel) nroff accents |
| 103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' |
| 104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' |
| 105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] |
| 106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' |
| 107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' |
| 108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] |
| 109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] |
| 110 | .ds ae a\h'-(\w'a'u*4/10)'e |
| 111 | .ds Ae A\h'-(\w'A'u*4/10)'E |
| 112 | . \" corrections for vroff |
| 113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' |
| 114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' |
| 115 | . \" for low resolution devices (crt and lpr) |
| 116 | .if \n(.H>23 .if \n(.V>19 \ |
| 117 | \{\ |
| 118 | . ds : e |
| 119 | . ds 8 ss |
| 120 | . ds o a |
| 121 | . ds d- d\h'-1'\(ga |
| 122 | . ds D- D\h'-1'\(hy |
| 123 | . ds th \o'bp' |
| 124 | . ds Th \o'LP' |
| 125 | . ds ae ae |
| 126 | . ds Ae AE |
| 127 | .\} |
| 128 | .rm #[ #] #H #V #F C |
| 129 | .\" ======================================================================== |
| 130 | .\" |
| 131 | .IX Title "Term::Cap 3" |
| 132 | .TH Term::Cap 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" |
| 133 | .SH "NAME" |
| 134 | Term::Cap \- Perl termcap interface |
| 135 | .SH "SYNOPSIS" |
| 136 | .IX Header "SYNOPSIS" |
| 137 | .Vb 6 |
| 138 | \& require Term::Cap; |
| 139 | \& $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed }; |
| 140 | \& $terminal->Trequire(qw/ce ku kd/); |
| 141 | \& $terminal->Tgoto('cm', $col, $row, $FH); |
| 142 | \& $terminal->Tputs('dl', $count, $FH); |
| 143 | \& $terminal->Tpad($string, $count, $FH); |
| 144 | .Ve |
| 145 | .SH "DESCRIPTION" |
| 146 | .IX Header "DESCRIPTION" |
| 147 | These are low-level functions to extract and use capabilities from |
| 148 | a terminal capability (termcap) database. |
| 149 | .PP |
| 150 | More information on the terminal capabilities will be found in the |
| 151 | termcap manpage on most Unix-like systems. |
| 152 | .Sh "\s-1METHODS\s0" |
| 153 | .IX Subsection "METHODS" |
| 154 | .RS 4 |
| 155 | The output strings for \fBTputs\fR are cached for counts of 1 for performance. |
| 156 | \&\fBTgoto\fR and \fBTpad\fR do not cache. \f(CW\*(C`$self\->{_xx}\*(C'\fR is the raw termcap |
| 157 | data and \f(CW\*(C`$self\->{xx}\*(C'\fR is the cached version. |
| 158 | .Sp |
| 159 | .Vb 1 |
| 160 | \& print $terminal->Tpad($self->{_xx}, 1); |
| 161 | .Ve |
| 162 | .Sp |
| 163 | \&\fBTgoto\fR, \fBTputs\fR, and \fBTpad\fR return the string and will also |
| 164 | output the string to \f(CW$FH\fR if specified. |
| 165 | .RE |
| 166 | .IP "\fBTgetent\fR" 4 |
| 167 | .IX Item "Tgetent" |
| 168 | Returns a blessed object reference which the user can |
| 169 | then use to send the control strings to the terminal using \fBTputs\fR |
| 170 | and \fBTgoto\fR. |
| 171 | .Sp |
| 172 | The function extracts the entry of the specified terminal |
| 173 | type \fI\s-1TERM\s0\fR (defaults to the environment variable \fI\s-1TERM\s0\fR) from the |
| 174 | database. |
| 175 | .Sp |
| 176 | It will look in the environment for a \fI\s-1TERMCAP\s0\fR variable. If |
| 177 | found, and the value does not begin with a slash, and the terminal |
| 178 | type name is the same as the environment string \fI\s-1TERM\s0\fR, the |
| 179 | \&\fI\s-1TERMCAP\s0\fR string is used instead of reading a termcap file. If |
| 180 | it does begin with a slash, the string is used as a path name of |
| 181 | the termcap file to search. If \fI\s-1TERMCAP\s0\fR does not begin with a |
| 182 | slash and name is different from \fI\s-1TERM\s0\fR, \fBTgetent\fR searches the |
| 183 | files \fI$HOME/.termcap\fR, \fI/etc/termcap\fR, and \fI/usr/share/misc/termcap\fR, |
| 184 | in that order, unless the environment variable \fI\s-1TERMPATH\s0\fR exists, |
| 185 | in which case it specifies a list of file pathnames (separated by |
| 186 | spaces or colons) to be searched \fBinstead\fR. Whenever multiple |
| 187 | files are searched and a tc field occurs in the requested entry, |
| 188 | the entry it names must be found in the same file or one of the |
| 189 | succeeding files. If there is a \f(CW\*(C`:tc=...:\*(C'\fR in the \fI\s-1TERMCAP\s0\fR |
| 190 | environment variable string it will continue the search in the |
| 191 | files as above. |
| 192 | .Sp |
| 193 | The extracted termcap entry is available in the object |
| 194 | as \f(CW\*(C`$self\->{TERMCAP}\*(C'\fR. |
| 195 | .Sp |
| 196 | It takes a hash reference as an argument with two optional keys: |
| 197 | .RS 4 |
| 198 | .IP "\s-1OSPEED\s0" 2 |
| 199 | .IX Item "OSPEED" |
| 200 | The terminal output bit rate (often mistakenly called the baud rate) |
| 201 | for this terminal \- if not set a warning will be generated |
| 202 | and it will be defaulted to 9600. \fI\s-1OSPEED\s0\fR can be be specified as |
| 203 | either a \s-1POSIX\s0 termios/SYSV termio speeds (where 9600 equals 9600) or |
| 204 | an old DSD-style speed ( where 13 equals 9600). |
| 205 | .IP "\s-1TERM\s0" 2 |
| 206 | .IX Item "TERM" |
| 207 | The terminal type whose termcap entry will be used \- if not supplied it will |
| 208 | default to \f(CW$ENV\fR{\s-1TERM\s0}: if that is not set then \fBTgetent\fR will croak. |
| 209 | .RE |
| 210 | .RS 4 |
| 211 | .Sp |
| 212 | It calls \f(CW\*(C`croak\*(C'\fR on failure. |
| 213 | .RE |
| 214 | .IP "\fBTpad\fR" 4 |
| 215 | .IX Item "Tpad" |
| 216 | Outputs a literal string with appropriate padding for the current terminal. |
| 217 | .Sp |
| 218 | It takes three arguments: |
| 219 | .RS 4 |
| 220 | .IP "\fB$string\fR" 2 |
| 221 | .IX Item "$string" |
| 222 | The literal string to be output. If it starts with a number and an optional |
| 223 | \&'*' then the padding will be increased by an amount relative to this number, |
| 224 | if the '*' is present then this amount will me multiplied by \f(CW$cnt\fR. This part |
| 225 | of \f(CW$string\fR is removed before output/ |
| 226 | .IP "\fB$cnt\fR" 2 |
| 227 | .IX Item "$cnt" |
| 228 | Will be used to modify the padding applied to string as described above. |
| 229 | .IP "\fB$FH\fR" 2 |
| 230 | .IX Item "$FH" |
| 231 | An optional filehandle (or IO::Handle ) that output will be printed to. |
| 232 | .RE |
| 233 | .RS 4 |
| 234 | .Sp |
| 235 | The padded \f(CW$string\fR is returned. |
| 236 | .RE |
| 237 | .IP "\fBTputs\fR" 4 |
| 238 | .IX Item "Tputs" |
| 239 | Output the string for the given capability padded as appropriate without |
| 240 | any parameter substitution. |
| 241 | .Sp |
| 242 | It takes three arguments: |
| 243 | .RS 4 |
| 244 | .IP "\fB$cap\fR" 2 |
| 245 | .IX Item "$cap" |
| 246 | The capability whose string is to be output. |
| 247 | .IP "\fB$cnt\fR" 2 |
| 248 | .IX Item "$cnt" |
| 249 | A count passed to Tpad to modify the padding applied to the output string. |
| 250 | If \f(CW$cnt\fR is zero or one then the resulting string will be cached. |
| 251 | .IP "\fB$FH\fR" 2 |
| 252 | .IX Item "$FH" |
| 253 | An optional filehandle (or IO::Handle ) that output will be printed to. |
| 254 | .RE |
| 255 | .RS 4 |
| 256 | .Sp |
| 257 | The appropriate string for the capability will be returned. |
| 258 | .RE |
| 259 | .IP "\fBTgoto\fR" 4 |
| 260 | .IX Item "Tgoto" |
| 261 | \&\fBTgoto\fR decodes a cursor addressing string with the given parameters. |
| 262 | .Sp |
| 263 | There are four arguments: |
| 264 | .RS 4 |
| 265 | .IP "\fB$cap\fR" 2 |
| 266 | .IX Item "$cap" |
| 267 | The name of the capability to be output. |
| 268 | .IP "\fB$col\fR" 2 |
| 269 | .IX Item "$col" |
| 270 | The first value to be substituted in the output string ( usually the column |
| 271 | in a cursor addressing capability ) |
| 272 | .IP "\fB$row\fR" 2 |
| 273 | .IX Item "$row" |
| 274 | The second value to be substituted in the output string (usually the row |
| 275 | in cursor addressing capabilities) |
| 276 | .IP "\fB$FH\fR" 2 |
| 277 | .IX Item "$FH" |
| 278 | An optional filehandle (or IO::Handle ) to which the output string will be |
| 279 | printed. |
| 280 | .RE |
| 281 | .RS 4 |
| 282 | .Sp |
| 283 | Substitutions are made with \f(CW$col\fR and \f(CW$row\fR in the output string with the |
| 284 | following \fIsprintf()\fR line formats: |
| 285 | .Sp |
| 286 | .Vb 6 |
| 287 | \& %% output `%' |
| 288 | \& %d output value as in printf %d |
| 289 | \& %2 output value as in printf %2d |
| 290 | \& %3 output value as in printf %3d |
| 291 | \& %. output value as in printf %c |
| 292 | \& %+x add x to value, then do %. |
| 293 | .Ve |
| 294 | .Sp |
| 295 | .Vb 4 |
| 296 | \& %>xy if value > x then add y, no output |
| 297 | \& %r reverse order of two parameters, no output |
| 298 | \& %i increment by one, no output |
| 299 | \& %B BCD (16*(value/10)) + (value%10), no output |
| 300 | .Ve |
| 301 | .Sp |
| 302 | .Vb 2 |
| 303 | \& %n exclusive-or all parameters with 0140 (Datamedia 2500) |
| 304 | \& %D Reverse coding (value - 2*(value%16)), no output (Delta Data) |
| 305 | .Ve |
| 306 | .Sp |
| 307 | The output string will be returned. |
| 308 | .RE |
| 309 | .IP "\fBTrequire\fR" 4 |
| 310 | .IX Item "Trequire" |
| 311 | Takes a list of capabilities as an argument and will croak if one is not |
| 312 | found. |
| 313 | .SH "EXAMPLES" |
| 314 | .IX Header "EXAMPLES" |
| 315 | .Vb 1 |
| 316 | \& use Term::Cap; |
| 317 | .Ve |
| 318 | .PP |
| 319 | .Vb 5 |
| 320 | \& # Get terminal output speed |
| 321 | \& require POSIX; |
| 322 | \& my $termios = new POSIX::Termios; |
| 323 | \& $termios->getattr; |
| 324 | \& my $ospeed = $termios->getospeed; |
| 325 | .Ve |
| 326 | .PP |
| 327 | .Vb 4 |
| 328 | \& # Old-style ioctl code to get ospeed: |
| 329 | \& # require 'ioctl.pl'; |
| 330 | \& # ioctl(TTY,$TIOCGETP,$sgtty); |
| 331 | \& # ($ispeed,$ospeed) = unpack('cc',$sgtty); |
| 332 | .Ve |
| 333 | .PP |
| 334 | .Vb 2 |
| 335 | \& # allocate and initialize a terminal structure |
| 336 | \& $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed }; |
| 337 | .Ve |
| 338 | .PP |
| 339 | .Vb 2 |
| 340 | \& # require certain capabilities to be available |
| 341 | \& $terminal->Trequire(qw/ce ku kd/); |
| 342 | .Ve |
| 343 | .PP |
| 344 | .Vb 1 |
| 345 | \& # Output Routines, if $FH is undefined these just return the string |
| 346 | .Ve |
| 347 | .PP |
| 348 | .Vb 2 |
| 349 | \& # Tgoto does the % expansion stuff with the given args |
| 350 | \& $terminal->Tgoto('cm', $col, $row, $FH); |
| 351 | .Ve |
| 352 | .PP |
| 353 | .Vb 2 |
| 354 | \& # Tputs doesn't do any % expansion. |
| 355 | \& $terminal->Tputs('dl', $count = 1, $FH); |
| 356 | .Ve |
| 357 | .SH "COPYRIGHT AND LICENSE" |
| 358 | .IX Header "COPYRIGHT AND LICENSE" |
| 359 | Please see the \s-1README\s0 file in distribution. |
| 360 | .SH "AUTHOR" |
| 361 | .IX Header "AUTHOR" |
| 362 | This module is part of the core Perl distribution and is also maintained |
| 363 | for \s-1CPAN\s0 by Jonathan Stowe <jns@gellyfish.com>. |
| 364 | .SH "SEE ALSO" |
| 365 | .IX Header "SEE ALSO" |
| 366 | \&\fItermcap\fR\|(5) |