]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_termcap.3x
ncurses 5.9 - patch 20120303
[ncurses.git] / man / curs_termcap.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_termcap.3x,v 1.27 2011/10/15 21:11:24 tom Exp $
30 .TH curs_termcap 3X ""
31 .na
32 .hy 0
33 .ds n 5
34 .SH NAME
35 \fBPC\fR,
36 \fBUP\fR,
37 \fBBC\fR,
38 \fBospeed\fR,
39 \fBtgetent\fR,
40 \fBtgetflag\fR,
41 \fBtgetnum\fR,
42 \fBtgetstr\fR,
43 \fBtgoto\fR,
44 \fBtputs\fR \- direct \fBcurses\fR interface to the terminfo capability database
45 .ad
46 .hy
47 .SH SYNOPSIS
48 \fB#include <curses.h>\fR
49 .br
50 \fB#include <term.h>\fR
51 .sp
52 \fBextern char PC;\fR
53 .br
54 \fBextern char * UP;\fR
55 .br
56 \fBextern char * BC;\fR
57 .br
58 \fBextern @NCURSES_OSPEED@ ospeed;\fR
59 .sp
60 \fBint tgetent(char *bp, const char *name);\fR
61 .br
62 \fBint tgetflag(char *id);\fR
63 .br
64 \fBint tgetnum(char *id);\fR
65 .br
66 \fBchar *tgetstr(char *id, char **area);\fR
67 .br
68 \fBchar *tgoto(const char *cap, int col, int row);\fR
69 .br
70 \fBint tputs(const char *str, int affcnt, int (*putc)(int));\fR
71 .br
72 .SH DESCRIPTION
73 These routines are included as a conversion aid for programs that use
74 the \fItermcap\fR library.  Their parameters are the same and the
75 routines are emulated using the \fIterminfo\fR database.  Thus, they
76 can only be used to query the capabilities of entries for which a
77 terminfo entry has been compiled.
78 .PP
79 The \fBtgetent\fR routine loads the entry for \fIname\fR.
80 It returns:
81 .RS 3
82 .TP 3
83 1
84 on success,
85 .TP 3
86 0
87 if there is no such entry
88 (or that it is a generic type, having too little information for curses
89 applications to run), and
90 .TP 3
91 \-1
92 if the terminfo database could not be found.
93 .RE
94 .PP
95 This differs from the \fItermcap\fP library in two ways:
96 .RS 3
97 .TP 3
98 -
99 The emulation ignores the buffer pointer \fIbp\fR.
100 The \fItermcap\fP library would store a copy of the terminal
101 description in the area referenced by this pointer.
102 However, ncurses stores its terminal descriptions in compiled
103 binary form, which is not the same thing.
104 .TP 3
105 -
106 There is a difference in return codes.
107 The \fItermcap\fP library does not check if the terminal
108 description is marked with the \fIgeneric\fP capability,
109 or if the terminal description has cursor-addressing.
110 .RE
111 .PP
112 The \fBtgetflag\fR routine gets the boolean entry for \fIid\fR,
113 or zero if it is not available.
114 .PP
115 The \fBtgetnum\fR routine gets the numeric entry for \fIid\fR,
116 or \-1 if it is not available.
117 .PP
118 The \fBtgetstr\fR routine returns the string entry for \fIid\fR,
119 or zero if it is not available.
120 Use \fBtputs\fR to output the returned string.
121 The return value will also be copied to the buffer pointed to by \fIarea\fR,
122 and the \fIarea\fR value will be updated to point past the null ending
123 this value.
124 .PP
125 Only the first two characters of the \fBid\fR parameter of
126 \fBtgetflag\fR,
127 \fBtgetnum\fR and
128 \fBtgetstr\fR are compared in lookups.
129 .PP
130 The \fBtgoto\fR routine instantiates the parameters into the given capability.
131 The output from this routine is to be passed to \fBtputs\fR.
132 .PP
133 The \fBtputs\fR routine is described on the \fBcurs_terminfo\fR(3X) manual
134 page.  It can retrieve capabilities by either termcap or terminfo name.
135 .PP
136 The variables
137 \fBPC\fR,
138 \fBUP\fR and
139 \fBBC\fR
140 are set by \fBtgetent\fR to the terminfo entry's data for
141 \fBpad_char\fR,
142 \fBcursor_up\fR and
143 \fBbackspace_if_not_bs\fR,
144 respectively.
145 \fBUP\fR is not used by ncurses.
146 \fBPC\fR is used in the \fBtdelay_output\fR function.
147 \fBBC\fR is used in the \fBtgoto\fR emulation.
148 The variable \fBospeed\fR is set by ncurses in a system-specific coding
149 to reflect the terminal speed.
150 .
151 .SH RETURN VALUE
152 Except where explicitly noted,
153 routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
154 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
155 completion.
156 .PP
157 Routines that return pointers return \fBNULL\fR on error.
158 .SH BUGS
159 If you call \fBtgetstr\fR to fetch \fBca\fR or any other parameterized string,
160 be aware that it will be returned in terminfo notation, not the older and
161 not-quite-compatible termcap notation.  This will not cause problems if all
162 you do with it is call \fBtgoto\fR or \fBtparm\fR, which both expand
163 terminfo-style strings as terminfo.
164 (The \fBtgoto\fR function, if configured to support termcap, will check
165 if the string is indeed terminfo-style by looking for "%p" parameters or
166 "$<..>" delays, and invoke a termcap-style parser if the string does not
167 appear to be terminfo).
168 .PP
169 Because terminfo conventions for representing padding in string capabilities
170 differ from termcap's, \fBtputs("50");\fR will put out a literal "50" rather
171 than busy-waiting for 50 milliseconds.  Cope with it.
172 .PP
173 Note that termcap has nothing analogous to terminfo's \fBsgr\fR string.
174 One consequence of this is that termcap applications assume \fRme\fR
175 (terminfo \fBsgr0\fR) does not reset the alternate character set.
176 This implementation checks for, and modifies the data shown to the
177 termcap interface to accommodate termcap's limitation in this respect.
178 .SH PORTABILITY
179 The XSI Curses standard, Issue 4 describes these functions.  However, they
180 are marked TO BE WITHDRAWN and may be removed in future versions.
181 .PP
182 Neither the XSI Curses standard nor the SVr4 man pages documented the return
183 values of \fBtgetent\fR correctly, though all three were in fact returned ever
184 since SVr1.
185 In particular, an omission in the XSI Curses documentation has been
186 misinterpreted to mean that \fBtgetent\fR returns \fBOK\fR or \fBERR\fR.
187 Because the purpose of these functions is to provide compatibility with
188 the \fItermcap\fR library, that is a defect in XCurses, Issue 4, Version 2
189 rather than in ncurses.
190 .PP
191 External variables are provided for support of certain termcap applications.
192 However, termcap applications' use of those variables is poorly documented,
193 e.g., not distinguishing between input and output.
194 In particular, some applications are reported to declare and/or
195 modify \fBospeed\fR.
196 .SH SEE ALSO
197 \fBcurses\fR(3X),
198 \fBterminfo\fR(\*n),
199 \fBterm_variables\fR(3X),
200 \fBputc\fR(3).