]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_termcap.3x
ncurses 6.0 - patch 20161126
[ncurses.git] / man / curs_termcap.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2015,2016 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.32 2016/03/19 22:52:25 tom Exp $
30 .TH curs_termcap 3X ""
31 .de bP
32 .IP \(bu 4
33 ..
34 .na
35 .hy 0
36 .ds n 5
37 .SH NAME
38 \fBPC\fR,
39 \fBUP\fR,
40 \fBBC\fR,
41 \fBospeed\fR,
42 \fBtgetent\fR,
43 \fBtgetflag\fR,
44 \fBtgetnum\fR,
45 \fBtgetstr\fR,
46 \fBtgoto\fR,
47 \fBtputs\fR \- direct \fBcurses\fR interface to the terminfo capability database
48 .ad
49 .hy
50 .SH SYNOPSIS
51 \fB#include <curses.h>\fR
52 .br
53 \fB#include <term.h>\fR
54 .sp
55 \fBextern char PC;\fR
56 .br
57 \fBextern char * UP;\fR
58 .br
59 \fBextern char * BC;\fR
60 .br
61 \fBextern @NCURSES_OSPEED@ ospeed;\fR
62 .sp
63 \fBint tgetent(char *bp, const char *name);\fR
64 .br
65 \fBint tgetflag(char *id);\fR
66 .br
67 \fBint tgetnum(char *id);\fR
68 .br
69 \fBchar *tgetstr(char *id, char **area);\fR
70 .br
71 \fBchar *tgoto(const char *cap, int col, int row);\fR
72 .br
73 \fBint tputs(const char *str, int affcnt, int (*putc)(int));\fR
74 .br
75 .SH DESCRIPTION
76 These routines are included as a conversion aid for programs that use
77 the \fItermcap\fR library.  Their parameters are the same and the
78 routines are emulated using the \fIterminfo\fR database.  Thus, they
79 can only be used to query the capabilities of entries for which a
80 terminfo entry has been compiled.
81 .SS INITIALIZATION
82 .PP
83 The \fBtgetent\fR routine loads the entry for \fIname\fR.
84 It returns:
85 .RS 3
86 .TP 3
87 1
88 on success,
89 .TP 3
90 0
91 if there is no such entry
92 (or that it is a generic type, having too little information for curses
93 applications to run), and
94 .TP 3
95 \-1
96 if the terminfo database could not be found.
97 .RE
98 .PP
99 This differs from the \fItermcap\fP library in two ways:
100 .RS 3
101 .bP
102 The emulation ignores the buffer pointer \fIbp\fR.
103 The \fItermcap\fP library would store a copy of the terminal
104 description in the area referenced by this pointer.
105 However, ncurses stores its terminal descriptions in compiled
106 binary form, which is not the same thing.
107 .bP
108 There is a difference in return codes.
109 The \fItermcap\fP library does not check if the terminal
110 description is marked with the \fIgeneric\fP capability,
111 or if the terminal description has cursor-addressing.
112 .RE
113 .SS CAPABILITY VALUES
114 .PP
115 The \fBtgetflag\fR routine gets the boolean entry for \fIid\fR,
116 or zero if it is not available.
117 .PP
118 The \fBtgetnum\fR routine gets the numeric entry for \fIid\fR,
119 or \-1 if it is not available.
120 .PP
121 The \fBtgetstr\fR routine returns the string entry for \fIid\fR,
122 or zero if it is not available.
123 Use \fBtputs\fR to output the returned string.
124 The \fIarea\fP parameter is used as follows:
125 .RS 3
126 .bP
127 It is assumed to be the address of a pointer to a buffer managed by the
128 calling application.
129 .bP
130 However, ncurses checks to ensure that \fBarea\fP is not NULL,
131 and also that the resulting buffer pointer is not NULL.
132 If either check fails, the \fIarea\fP parameter is ignored.
133 .bP
134 If the checks succeed, ncurses also copies the return value to
135 the buffer pointed to by \fIarea\fR,
136 and the \fIarea\fR value will be updated to point past the null ending
137 this value.
138 .bP
139 The return value itself is an address in the terminal description which
140 is loaded into memory.
141 .RE
142 .PP
143 Only the first two characters of the \fBid\fR parameter of
144 \fBtgetflag\fR,
145 \fBtgetnum\fR and
146 \fBtgetstr\fR are compared in lookups.
147 .SS FORMATTING CAPABILITIES
148 .PP
149 The \fBtgoto\fR routine expands the given capability using the parameters.
150 .bP
151 Because the capability may have padding characters,
152 the output of \fBtgoto\fP should be passed to \fBtputs\fR
153 rather than some other output function such as \fBprintf\fP.
154 .bP
155 While \fBtgoto\fP is assumed to be used for the two-parameter
156 cursor positioning capability,
157 termcap applications also use it for single-parameter capabilities.
158 .IP
159 Doing this shows a quirk in \fBtgoto\fP: most hardware
160 terminals use cursor addressing with \fIrow\fP first,
161 but the original developers of the termcap interface chose to
162 put the \fIcolumn\fP parameter first.
163 The \fBtgoto\fP function swaps the order of parameters.
164 It does this also for calls requiring only a single parameter.
165 In that case, the first parameter is merely a placeholder.
166 .bP
167 Normally the ncurses library is compiled with terminfo support.
168 In that case, \fBtgoto\fP uses \fBtparm\fP (a more capable formatter).
169 .PP
170 The \fBtputs\fR routine is described on the \fBcurs_terminfo\fR(3X) manual
171 page.  It can retrieve capabilities by either termcap or terminfo name.
172 .SS GLOBAL VARIABLES
173 .PP
174 The variables
175 \fBPC\fR,
176 \fBUP\fR and
177 \fBBC\fR
178 are set by \fBtgetent\fR to the terminfo entry's data for
179 \fBpad_char\fR,
180 \fBcursor_up\fR and
181 \fBbackspace_if_not_bs\fR,
182 respectively.
183 \fBUP\fR is not used by ncurses.
184 \fBPC\fR is used in the \fBtdelay_output\fR function.
185 \fBBC\fR is used in the \fBtgoto\fR emulation.
186 The variable \fBospeed\fR is set by ncurses in a system-specific coding
187 to reflect the terminal speed.
188 .
189 .SH RETURN VALUE
190 Except where explicitly noted,
191 routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
192 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
193 completion.
194 .PP
195 Routines that return pointers return \fBNULL\fR on error.
196 .SH BUGS
197 If you call \fBtgetstr\fR to fetch \fBca\fR or any other parameterized string,
198 be aware that it will be returned in terminfo notation, not the older and
199 not-quite-compatible termcap notation.  This will not cause problems if all
200 you do with it is call \fBtgoto\fR or \fBtparm\fR, which both expand
201 terminfo-style strings as terminfo.
202 (The \fBtgoto\fR function, if configured to support termcap, will check
203 if the string is indeed terminfo-style by looking for "%p" parameters or
204 "$<..>" delays, and invoke a termcap-style parser if the string does not
205 appear to be terminfo).
206 .PP
207 Because terminfo conventions for representing padding in string capabilities
208 differ from termcap's, \fBtputs("50");\fR will put out a literal "50" rather
209 than busy-waiting for 50 milliseconds.  Cope with it.
210 .PP
211 Note that termcap has nothing analogous to terminfo's \fBsgr\fR string.
212 One consequence of this is that termcap applications assume \fRme\fR
213 (terminfo \fBsgr0\fR) does not reset the alternate character set.
214 This implementation checks for, and modifies the data shown to the
215 termcap interface to accommodate termcap's limitation in this respect.
216 .SH PORTABILITY
217 The XSI Curses standard, Issue 4 describes these functions.  However, they
218 are marked TO BE WITHDRAWN and may be removed in future versions.
219 .PP
220 Neither the XSI Curses standard nor the SVr4 man pages documented the return
221 values of \fBtgetent\fR correctly, though all three were in fact returned ever
222 since SVr1.
223 In particular, an omission in the XSI Curses documentation has been
224 misinterpreted to mean that \fBtgetent\fR returns \fBOK\fR or \fBERR\fR.
225 Because the purpose of these functions is to provide compatibility with
226 the \fItermcap\fR library, that is a defect in XCurses, Issue 4, Version 2
227 rather than in ncurses.
228 .PP
229 External variables are provided for support of certain termcap applications.
230 However, termcap applications' use of those variables is poorly documented,
231 e.g., not distinguishing between input and output.
232 In particular, some applications are reported to declare and/or
233 modify \fBospeed\fR.
234 .PP
235 The comment that only the first two characters of the \fBid\fR parameter
236 are used escapes many application developers.
237 The original BSD 4.2 termcap library (and historical relics thereof)
238 did not require a trailing null NUL on the parameter name passed
239 to \fBtgetstr\fP, \fBtgetnum\fP and \fBtgetflag\fP.
240 Some applications assume that the termcap interface does not require
241 the trailing NUL for the parameter name.
242 Taking into account these issues:
243 .bP
244 As a special case,
245 \fBtgetflag\fP matched against a single-character identifier
246 provided that was at the end of the terminal description.
247 You should not rely upon this behavior in portable programs.
248 This implementation disallows matches against single-character capability names.
249 .bP
250 This implementation disallows matches by the termcap interface against
251 extended capability names which are longer than two characters.
252 .SH SEE ALSO
253 \fBcurses\fR(3X),
254 \fBterminfo\fR(\*n),
255 \fBterm_variables\fR(3X),
256 \fBputc\fR(3).
257 .sp
258 http://invisible-island.net/ncurses/tctest.html