]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_termcap.3x
a3b8bd8c3e041eea621940a73d3a3a3669fd503f
[ncurses.git] / man / curs_termcap.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2011,2012 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.28 2012/11/03 21:56:15 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 .PP
82 The \fBtgetent\fR routine loads the entry for \fIname\fR.
83 It returns:
84 .RS 3
85 .TP 3
86 1
87 on success,
88 .TP 3
89 0
90 if there is no such entry
91 (or that it is a generic type, having too little information for curses
92 applications to run), and
93 .TP 3
94 \-1
95 if the terminfo database could not be found.
96 .RE
97 .PP
98 This differs from the \fItermcap\fP library in two ways:
99 .RS 3
100 .bP
101 The emulation ignores the buffer pointer \fIbp\fR.
102 The \fItermcap\fP library would store a copy of the terminal
103 description in the area referenced by this pointer.
104 However, ncurses stores its terminal descriptions in compiled
105 binary form, which is not the same thing.
106 .bP
107 There is a difference in return codes.
108 The \fItermcap\fP library does not check if the terminal
109 description is marked with the \fIgeneric\fP capability,
110 or if the terminal description has cursor-addressing.
111 .RE
112 .PP
113 The \fBtgetflag\fR routine gets the boolean entry for \fIid\fR,
114 or zero if it is not available.
115 .PP
116 The \fBtgetnum\fR routine gets the numeric entry for \fIid\fR,
117 or \-1 if it is not available.
118 .PP
119 The \fBtgetstr\fR routine returns the string entry for \fIid\fR,
120 or zero if it is not available.
121 Use \fBtputs\fR to output the returned string.
122 The return value will also be copied to the buffer pointed to by \fIarea\fR,
123 and the \fIarea\fR value will be updated to point past the null ending
124 this value.
125 .PP
126 Only the first two characters of the \fBid\fR parameter of
127 \fBtgetflag\fR,
128 \fBtgetnum\fR and
129 \fBtgetstr\fR are compared in lookups.
130 .PP
131 The \fBtgoto\fR routine instantiates the parameters into the given capability.
132 The output from this routine is to be passed to \fBtputs\fR.
133 .PP
134 The \fBtputs\fR routine is described on the \fBcurs_terminfo\fR(3X) manual
135 page.  It can retrieve capabilities by either termcap or terminfo name.
136 .PP
137 The variables
138 \fBPC\fR,
139 \fBUP\fR and
140 \fBBC\fR
141 are set by \fBtgetent\fR to the terminfo entry's data for
142 \fBpad_char\fR,
143 \fBcursor_up\fR and
144 \fBbackspace_if_not_bs\fR,
145 respectively.
146 \fBUP\fR is not used by ncurses.
147 \fBPC\fR is used in the \fBtdelay_output\fR function.
148 \fBBC\fR is used in the \fBtgoto\fR emulation.
149 The variable \fBospeed\fR is set by ncurses in a system-specific coding
150 to reflect the terminal speed.
151 .
152 .SH RETURN VALUE
153 Except where explicitly noted,
154 routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
155 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
156 completion.
157 .PP
158 Routines that return pointers return \fBNULL\fR on error.
159 .SH BUGS
160 If you call \fBtgetstr\fR to fetch \fBca\fR or any other parameterized string,
161 be aware that it will be returned in terminfo notation, not the older and
162 not-quite-compatible termcap notation.  This will not cause problems if all
163 you do with it is call \fBtgoto\fR or \fBtparm\fR, which both expand
164 terminfo-style strings as terminfo.
165 (The \fBtgoto\fR function, if configured to support termcap, will check
166 if the string is indeed terminfo-style by looking for "%p" parameters or
167 "$<..>" delays, and invoke a termcap-style parser if the string does not
168 appear to be terminfo).
169 .PP
170 Because terminfo conventions for representing padding in string capabilities
171 differ from termcap's, \fBtputs("50");\fR will put out a literal "50" rather
172 than busy-waiting for 50 milliseconds.  Cope with it.
173 .PP
174 Note that termcap has nothing analogous to terminfo's \fBsgr\fR string.
175 One consequence of this is that termcap applications assume \fRme\fR
176 (terminfo \fBsgr0\fR) does not reset the alternate character set.
177 This implementation checks for, and modifies the data shown to the
178 termcap interface to accommodate termcap's limitation in this respect.
179 .SH PORTABILITY
180 The XSI Curses standard, Issue 4 describes these functions.  However, they
181 are marked TO BE WITHDRAWN and may be removed in future versions.
182 .PP
183 Neither the XSI Curses standard nor the SVr4 man pages documented the return
184 values of \fBtgetent\fR correctly, though all three were in fact returned ever
185 since SVr1.
186 In particular, an omission in the XSI Curses documentation has been
187 misinterpreted to mean that \fBtgetent\fR returns \fBOK\fR or \fBERR\fR.
188 Because the purpose of these functions is to provide compatibility with
189 the \fItermcap\fR library, that is a defect in XCurses, Issue 4, Version 2
190 rather than in ncurses.
191 .PP
192 External variables are provided for support of certain termcap applications.
193 However, termcap applications' use of those variables is poorly documented,
194 e.g., not distinguishing between input and output.
195 In particular, some applications are reported to declare and/or
196 modify \fBospeed\fR.
197 .SH SEE ALSO
198 \fBcurses\fR(3X),
199 \fBterminfo\fR(\*n),
200 \fBterm_variables\fR(3X),
201 \fBputc\fR(3).