1Term::Cap(3pm)         Perl Programmers Reference Guide         Term::Cap(3pm)
2
3
4

NAME

6       Term::Cap - Perl termcap interface
7

SYNOPSIS

9           require Term::Cap;
10           $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };
11           $terminal->Trequire(qw/ce ku kd/);
12           $terminal->Tgoto('cm', $col, $row, $FH);
13           $terminal->Tputs('dl', $count, $FH);
14           $terminal->Tpad($string, $count, $FH);
15

DESCRIPTION

17       These are low-level functions to extract and use capabilities from a
18       terminal capability (termcap) database.
19
20       More information on the terminal capabilities will be found in the
21       termcap manpage on most Unix-like systems.
22
23   METHODS
24           The output strings for Tputs are cached for counts of 1 for
25           performance.  Tgoto and Tpad do not cache.  "$self->{_xx}" is the
26           raw termcap data and "$self->{xx}" is the cached version.
27
28               print $terminal->Tpad($self->{_xx}, 1);
29
30           Tgoto, Tputs, and Tpad return the string and will also output the
31           string to $FH if specified.
32
33           Tgetent
34
35           Returns a blessed object reference which the user can then use to
36           send the control strings to the terminal using Tputs and Tgoto.
37
38           The function extracts the entry of the specified terminal type TERM
39           (defaults to the environment variable TERM) from the database.
40
41           It will look in the environment for a TERMCAP variable.  If found,
42           and the value does not begin with a slash, and the terminal type
43           name is the same as the environment string TERM, the TERMCAP string
44           is used instead of reading a termcap file.  If it does begin with a
45           slash, the string is used as a path name of the termcap file to
46           search.  If TERMCAP does not begin with a slash and name is
47           different from TERM, Tgetent searches the files $HOME/.termcap,
48           /etc/termcap, and /usr/share/misc/termcap, in that order, unless
49           the environment variable TERMPATH exists, in which case it
50           specifies a list of file pathnames (separated by spaces or colons)
51           to be searched instead.  Whenever multiple files are searched and a
52           tc field occurs in the requested entry, the entry it names must be
53           found in the same file or one of the succeeding files.  If there is
54           a ":tc=...:" in the TERMCAP environment variable string it will
55           continue the search in the files as above.
56
57           The extracted termcap entry is available in the object as
58           "$self->{TERMCAP}".
59
60           It takes a hash reference as an argument with two optional keys:
61
62           OSPEED
63             The terminal output bit rate (often mistakenly called the baud
64             rate) for this terminal - if not set a warning will be generated
65             and it will be defaulted to 9600.  OSPEED can be be specified as
66             either a POSIX termios/SYSV termio speeds (where 9600 equals
67             9600) or an old DSD-style speed ( where 13 equals 9600).
68
69           TERM
70             The terminal type whose termcap entry will be used - if not
71             supplied it will default to $ENV{TERM}: if that is not set then
72             Tgetent will croak.
73
74           It calls "croak" on failure.
75
76           Tpad
77
78           Outputs a literal string with appropriate padding for the current
79           terminal.
80
81           It takes three arguments:
82
83           $string
84             The literal string to be output.  If it starts with a number and
85             an optional '*' then the padding will be increased by an amount
86             relative to this number, if the '*' is present then this amount
87             will me multiplied by $cnt.  This part of $string is removed
88             before output/
89
90           $cnt
91             Will be used to modify the padding applied to string as described
92             above.
93
94           $FH
95             An optional filehandle (or IO::Handle ) that output will be
96             printed to.
97
98           The padded $string is returned.
99
100           Tputs
101
102           Output the string for the given capability padded as appropriate
103           without any parameter substitution.
104
105           It takes three arguments:
106
107           $cap
108             The capability whose string is to be output.
109
110           $cnt
111             A count passed to Tpad to modify the padding applied to the
112             output string.  If $cnt is zero or one then the resulting string
113             will be cached.
114
115           $FH
116             An optional filehandle (or IO::Handle ) that output will be
117             printed to.
118
119           The appropriate string for the capability will be returned.
120
121           Tgoto
122
123           Tgoto decodes a cursor addressing string with the given parameters.
124
125           There are four arguments:
126
127           $cap
128             The name of the capability to be output.
129
130           $col
131             The first value to be substituted in the output string ( usually
132             the column in a cursor addressing capability )
133
134           $row
135             The second value to be substituted in the output string (usually
136             the row in cursor addressing capabilities)
137
138           $FH
139             An optional filehandle (or IO::Handle ) to which the output
140             string will be printed.
141
142           Substitutions are made with $col and $row in the output string with
143           the following sprintf() line formats:
144
145            %%   output `%'
146            %d   output value as in printf %d
147            %2   output value as in printf %2d
148            %3   output value as in printf %3d
149            %.   output value as in printf %c
150            %+x  add x to value, then do %.
151
152            %>xy if value > x then add y, no output
153            %r   reverse order of two parameters, no output
154            %i   increment by one, no output
155            %B   BCD (16*(value/10)) + (value%10), no output
156
157            %n   exclusive-or all parameters with 0140 (Datamedia 2500)
158            %D   Reverse coding (value - 2*(value%16)), no output (Delta Data)
159
160           The output string will be returned.
161
162           Trequire
163
164           Takes a list of capabilities as an argument and will croak if one
165           is not found.
166

EXAMPLES

168           use Term::Cap;
169
170           # Get terminal output speed
171           require POSIX;
172           my $termios = new POSIX::Termios;
173           $termios->getattr;
174           my $ospeed = $termios->getospeed;
175
176           # Old-style ioctl code to get ospeed:
177           #     require 'ioctl.pl';
178           #     ioctl(TTY,$TIOCGETP,$sgtty);
179           #     ($ispeed,$ospeed) = unpack('cc',$sgtty);
180
181           # allocate and initialize a terminal structure
182           $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };
183
184           # require certain capabilities to be available
185           $terminal->Trequire(qw/ce ku kd/);
186
187           # Output Routines, if $FH is undefined these just return the string
188
189           # Tgoto does the % expansion stuff with the given args
190           $terminal->Tgoto('cm', $col, $row, $FH);
191
192           # Tputs doesn't do any % expansion.
193           $terminal->Tputs('dl', $count = 1, $FH);
194
196       Please see the README file in distribution.
197

AUTHOR

199       This module is part of the core Perl distribution and is also
200       maintained for CPAN by Jonathan Stowe <jns@gellyfish.com>.
201

SEE ALSO

203       termcap(5)
204

POD ERRORS

206       Hey! The above document had some coding errors, which are explained
207       below:
208
209       Around line 89:
210           You can't have =items (as at line 148) unless the first thing after
211           the =over is an =item
212
213
214
215perl v5.12.4                      2011-06-01                    Term::Cap(3pm)
Impressum