1 .\" $NetBSD: termcap.3,v 1.34 2009/03/03 07:37:48 wiz Exp $
3 .\" Copyright (c) 1980, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)termcap.3 8.2 (Berkeley) 12/11/93
42 .Nd terminal independent operation routines
51 .Vt struct tinfo *info;
53 .Fn tgetent "char *bp" "const char *name"
55 .Fn tgetnum "const char *id"
57 .Fn tgetflag "const char *id"
59 .Fn tgetstr "const char *id" "char **area"
61 .Fn tgoto "const char *cm" "int destcol" "int destline"
63 .Fn tputs "const char *cp" "int affcnt" "int (*outc)(int)"
65 .Fn t_getent "struct tinfo **info" "const char *name"
67 .Fn t_getnum "struct tinfo *info" "const char *id"
69 .Fn t_getflag "struct tinfo *info" "const char *id"
71 .Fn t_getstr "struct tinfo *info" "const char *id" "char **area" "size_t *limit"
73 .Fn t_agetstr "struct tinfo *info" "const char *id"
75 .Fn t_getterm "struct tinfo *info" "char **area" "size_t *limit"
77 .Fn t_goto "struct tinfo *info" "const char *id" "int destcol" "int destline" "char *buffer" "size_t limit"
79 .Fn t_puts "struct tinfo *info" "const char *cp" "int affcnt" "void (*outc)(char, void *)" "void *args"
81 .Fn t_freent "struct tinfo *info"
83 .Fn t_setinfo "struct tinfo **info" "const char *entry"
86 .Fn t_putws "struct tinfo *info" "const wchar_t *cp" "int affcnt" "void (*outc)(wchar_t, void *)" "void *args"
88 These functions extract and use capabilities from a terminal capability data
90 .Pa /usr/share/misc/termcap ,
91 the format of which is described in
93 These are low level routines;
96 for a higher level package.
101 extracts the entry for terminal
108 should be a character buffer of size
109 1024 and must be retained through all subsequent calls to
117 returns \-1 if none of the
119 data base files could be opened,
120 0 if the terminal name given does not have an entry,
121 and 1 if all goes well.
122 It will look in the environment for a
125 If found, and the value does not begin with a slash, the value does
126 not contain the ZZ capability (see
128 for a description of this capability),
129 and the terminal type
131 is the same as the environment string
135 string is used instead of reading a
138 If the value does contain the ZZ capability then the
140 environment string is used to read
142 if the read fails for any reason the value of
144 will be used despite it containing ZZ.
147 does begin with a slash, the string is used as a path name
153 does not begin with a slash and
161 .Pa /usr/share/misc/termcap ,
162 in that order, unless the environment variable
165 in which case it specifies a list of file pathnames
166 (separated by spaces or colons) to be searched instead.
167 Whenever multiple files are searched and a
169 field occurs in the requested entry, the entry it names must be found
170 in the same file or one of the succeeding files.
171 This can speed up entry into programs that call
173 as well as help debug new terminal descriptions
174 or make one for your terminal if you can't write the file
175 .Pa /usr/share/misc/termcap .
180 gets the numeric value of capability
182 returning \-1 if it is not given for the terminal.
186 returns 1 if the specified capability is present in
187 the terminal's entry, 0 if it is not.
191 returns the string value of the capability
197 and does not point to a pointer to
199 it copies the string value into the buffer pointed to by
203 pointer past the copy of the string.
204 It decodes the abbreviations for this field described in
206 except for cursor addressing and padding information.
212 if the capability was not found.
217 returns a cursor addressing string decoded from
223 It uses the external variables
234 if necessary to avoid placing
243 should be sure to turn off the
248 may now output a tab.
249 Note that programs using termcap should in general turn off
251 anyway since some terminals use control-I for other functions,
252 such as nondestructive space.)
255 sequence is given which is not understood, then
263 decodes the leading padding information of the string
266 gives the number of lines affected by the operation, or 1 if this is
269 is a routine which is called with each character in turn.
270 The external variable
272 should contain the output speed of the terminal as encoded by
274 The external variable
276 should contain a pad character to be used (from the
285 function operates in a similar manner to the
287 function excepting that the
289 argument is a pointer to a pointer of the opaque type
293 succeeds then the argument
295 will be updated with the address of an object that contains the termcap
297 This pointer can then be passed to calls of
302 When the information pointed to by
304 is no longer required any storage associated with the object can be
312 operate in the same manner as
316 with the exception that the pointer to the termcap object is passed along
317 with the id of the capability required.
321 performs the same function as
325 parameter that gives the number of characters that can be inserted in to
326 the array pointed to by
330 argument is updated by the
332 call to give the number of characters that remain available in
334 If the t_getstr call fails then
336 will be returned and errno set to indicate the failure,
338 indicates there was no termcap entry for the given
341 indicates the retrieved entry would have overflowed
343 If t_getstr is called with
347 then the size required to hold the capability string will be returned in
349 so the caller can allocate enough storage to hold the capability.
353 performs the same function as
355 except it handles memory allocation automatically.
358 allocates will be freed when
364 returns a copy of the termcap name string of the termcap entry
367 in the buffer pointed to by
370 returns 0 on success and \-1 on error.
371 On error errno will be set to
373 if the termcap entry in
377 if the size of the name exceeds the size specified by
383 then the size required to hold the terminal name will be returned in
385 allowing sufficient storage to be allocated.
390 then no bounds checking will be performed.
394 function is the same as the
396 function excepting that the capabilities for
400 are extracted from the
402 object and that the string formed by
406 argument, the number of characters allowed to be placed in
410 If the expansion performed by
412 would exceed the space in
416 will return \-1 and set errno to
422 function excepting that
424 holds a pointer to the termcap object that was returned by a previous
426 call, this object will be used to retrieve the
428 attribute for the terminal.
433 but it operates on a string of wide characters.
436 function is a pointer to a function that will be called by
438 to output each character in the
443 function will be called with two parameters.
444 The first is the character
445 to be printed and the second is an optional argument that was passed to
450 The interpretation of the contents of
452 is dependent solely on the implementation of
457 function allows the termcap entry contained in the
459 string to be inserted into the
462 Memory sufficient to hold the contents of
464 is automatically allocated.
465 This allows the programmer to provide a fail over terminal capability
466 string if fetching the termcap entry from the termcap database fails.
467 The format of the string
469 is assumed to be a valid termcap entry.
471 NOTE: For termcap entries that are larger than 1023 bytes a special
474 is added to the end of the termcap entry retrieved.
475 The number that follows this entry is the address of the buffer allocated
476 to hold the full termcap entry.
477 The caller may retrieve the pointer to the extended buffer by performing a
481 capability, the string is the output of a
483 %p and may be converted back to a pointer using
486 The ZZ capability is only necessary if the caller wishes to
487 directly manipulate the termcap entry, all the termcap function calls
488 automatically use the extended buffer to retrieve terminal capabilities.
490 .Bl -tag -width /usr/share/misc/termcap -compact
491 .It Pa /usr/lib/libtermcap.a
493 library (also known as
495 .It Pa /usr/share/misc/termcap
496 standard terminal capability data base
497 .It Pa $HOME/.termcap
498 user's terminal capability data base
507 t_*() functions appeared in
511 functions appeared in