2 ****************************************************************************
3 * Copyright 2018-2019,2020 Thomas E. Dickey *
4 * Copyright 1998-2017,2018 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************
30 * @Id: curs_termcap.3x,v 1.43 2020/02/02 23:34:34 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>curs_termcap 3x</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
39 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
42 <H1 class="no-header">curs_termcap 3x</H1>
44 <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG> <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>PC</STRONG>, <STRONG>UP</STRONG>, <STRONG>BC</STRONG>, <STRONG>ospeed</STRONG>, <STRONG>tgetent</STRONG>, <STRONG>tgetflag</STRONG>, <STRONG>tgetnum</STRONG>, <STRONG>tgetstr</STRONG>, <STRONG>tgoto</STRONG>, <STRONG>tputs</STRONG> -
51 direct <STRONG>curses</STRONG> interface to the terminfo capability database
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
56 <STRONG>#include</STRONG> <STRONG><term.h></STRONG>
58 <STRONG>extern</STRONG> <STRONG>char</STRONG> <STRONG>PC;</STRONG>
59 <STRONG>extern</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG> <STRONG>UP;</STRONG>
60 <STRONG>extern</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG> <STRONG>BC;</STRONG>
61 <STRONG>extern</STRONG> <STRONG>short</STRONG> <STRONG>ospeed;</STRONG>
63 <STRONG>int</STRONG> <STRONG>tgetent(char</STRONG> <STRONG>*bp,</STRONG> <STRONG>const</STRONG> <STRONG>char</STRONG> <STRONG>*name);</STRONG>
64 <STRONG>int</STRONG> <STRONG>tgetflag(const</STRONG> <STRONG>char</STRONG> <STRONG>*id);</STRONG>
65 <STRONG>int</STRONG> <STRONG>tgetnum(const</STRONG> <STRONG>char</STRONG> <STRONG>*id);</STRONG>
66 <STRONG>char</STRONG> <STRONG>*tgetstr(const</STRONG> <STRONG>char</STRONG> <STRONG>*id,</STRONG> <STRONG>char</STRONG> <STRONG>**area);</STRONG>
67 <STRONG>char</STRONG> <STRONG>*tgoto(const</STRONG> <STRONG>char</STRONG> <STRONG>*cap,</STRONG> <STRONG>int</STRONG> <STRONG>col,</STRONG> <STRONG>int</STRONG> <STRONG>row);</STRONG>
68 <STRONG>int</STRONG> <STRONG>tputs(const</STRONG> <STRONG>char</STRONG> <STRONG>*str,</STRONG> <STRONG>int</STRONG> <STRONG>affcnt,</STRONG> <STRONG>int</STRONG> <STRONG>(*putc)(int));</STRONG>
71 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
72 These routines are included as a conversion aid for programs that use
73 the <EM>termcap</EM> library. Their parameters are the same and the routines
74 are emulated using the <EM>terminfo</EM> database. Thus, they can only be used
75 to query the capabilities of entries for which a terminfo entry has
79 </PRE><H3><a name="h3-INITIALIZATION">INITIALIZATION</a></H3><PRE>
80 The <STRONG>tgetent</STRONG> routine loads the entry for <EM>name</EM>. It returns:
84 0 if there is no such entry (or that it is a generic type, having
85 too little information for curses applications to run), and
87 -1 if the terminfo database could not be found.
89 This differs from the <EM>termcap</EM> library in two ways:
91 <STRONG>o</STRONG> The emulation ignores the buffer pointer <EM>bp</EM>. The <EM>termcap</EM> li-
92 brary would store a copy of the terminal description in the area
93 referenced by this pointer. However, ncurses stores its termi-
94 nal descriptions in compiled binary form, which is not the same
97 <STRONG>o</STRONG> There is a difference in return codes. The <EM>termcap</EM> library does
98 not check if the terminal description is marked with the <EM>generic</EM>
99 capability, or if the terminal description has cursor-address-
103 </PRE><H3><a name="h3-CAPABILITY-VALUES">CAPABILITY VALUES</a></H3><PRE>
104 The <STRONG>tgetflag</STRONG> routine gets the boolean entry for <EM>id</EM>, or zero if it is
107 The <STRONG>tgetnum</STRONG> routine gets the numeric entry for <EM>id</EM>, or -1 if it is not
110 The <STRONG>tgetstr</STRONG> routine returns the string entry for <EM>id</EM>, or zero if it is
111 not available. Use <STRONG>tputs</STRONG> to output the returned string. The <EM>area</EM> pa-
112 rameter is used as follows:
114 <STRONG>o</STRONG> It is assumed to be the address of a pointer to a buffer managed
115 by the calling application.
117 <STRONG>o</STRONG> However, ncurses checks to ensure that <STRONG>area</STRONG> is not NULL, and al-
118 so that the resulting buffer pointer is not NULL. If either
119 check fails, the <EM>area</EM> parameter is ignored.
121 <STRONG>o</STRONG> If the checks succeed, ncurses also copies the return value to
122 the buffer pointed to by <EM>area</EM>, and the <EM>area</EM> value will be updat-
123 ed to point past the null ending this value.
125 <STRONG>o</STRONG> The return value itself is an address in the terminal descrip-
126 tion which is loaded into memory.
128 Only the first two characters of the <STRONG>id</STRONG> parameter of <STRONG>tgetflag</STRONG>, <STRONG>tgetnum</STRONG>
129 and <STRONG>tgetstr</STRONG> are compared in lookups.
132 </PRE><H3><a name="h3-FORMATTING-CAPABILITIES">FORMATTING CAPABILITIES</a></H3><PRE>
133 The <STRONG>tgoto</STRONG> routine expands the given capability using the parameters.
135 <STRONG>o</STRONG> Because the capability may have padding characters, the output of
136 <STRONG>tgoto</STRONG> should be passed to <STRONG>tputs</STRONG> rather than some other output func-
137 tion such as <STRONG>printf</STRONG>.
139 <STRONG>o</STRONG> While <STRONG>tgoto</STRONG> is assumed to be used for the two-parameter cursor po-
140 sitioning capability, termcap applications also use it for single-
141 parameter capabilities.
143 Doing this shows a quirk in <STRONG>tgoto</STRONG>: most hardware terminals use cur-
144 sor addressing with <EM>row</EM> first, but the original developers of the
145 termcap interface chose to put the <EM>column</EM> parameter first. The
146 <STRONG>tgoto</STRONG> function swaps the order of parameters. It does this also
147 for calls requiring only a single parameter. In that case, the
148 first parameter is merely a placeholder.
150 <STRONG>o</STRONG> Normally the ncurses library is compiled with terminfo support. In
151 that case, <STRONG>tgoto</STRONG> uses <STRONG><A HREF="curs_terminfo.3x.html">tparm(3x)</A></STRONG> (a more capable formatter).
153 However, <STRONG>tparm</STRONG> is not a <EM>termcap</EM> feature, and portable <EM>termcap</EM> ap-
154 plications should not rely upon its availability.
156 The <STRONG>tputs</STRONG> routine is described on the <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG> manual page.
157 It can retrieve capabilities by either termcap or terminfo name.
160 </PRE><H3><a name="h3-GLOBAL-VARIABLES">GLOBAL VARIABLES</a></H3><PRE>
161 The variables <STRONG>PC</STRONG>, <STRONG>UP</STRONG> and <STRONG>BC</STRONG> are set by <STRONG>tgetent</STRONG> to the terminfo entry's
162 data for <STRONG>pad_char</STRONG>, <STRONG>cursor_up</STRONG> and <STRONG>backspace_if_not_bs</STRONG>, respectively. <STRONG>UP</STRONG>
163 is not used by ncurses. <STRONG>PC</STRONG> is used in the <STRONG>tdelay_output</STRONG> function. <STRONG>BC</STRONG>
164 is used in the <STRONG>tgoto</STRONG> emulation. The variable <STRONG>ospeed</STRONG> is set by ncurses
165 in a system-specific coding to reflect the terminal speed.
168 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
169 Except where explicitly noted, routines that return an integer return
170 <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG> (SVr4 only specifies "an integer value other
171 than <STRONG>ERR</STRONG>") upon successful completion.
173 Routines that return pointers return <STRONG>NULL</STRONG> on error.
176 </PRE><H2><a name="h2-BUGS">BUGS</a></H2><PRE>
177 If you call <STRONG>tgetstr</STRONG> to fetch <STRONG>ca</STRONG> or any other parameterized string, be
178 aware that it will be returned in terminfo notation, not the older and
179 not-quite-compatible termcap notation. This will not cause problems if
180 all you do with it is call <STRONG>tgoto</STRONG> or <STRONG>tparm</STRONG>, which both expand terminfo-
181 style strings as terminfo. (The <STRONG>tgoto</STRONG> function, if configured to sup-
182 port termcap, will check if the string is indeed terminfo-style by
183 looking for "%p" parameters or "$<..>" delays, and invoke a termcap-
184 style parser if the string does not appear to be terminfo).
186 Because terminfo conventions for representing padding in string capa-
187 bilities differ from termcap's, <STRONG>tputs("50");</STRONG> will put out a literal
188 "50" rather than busy-waiting for 50 milliseconds. Cope with it.
190 Note that termcap has nothing analogous to terminfo's <STRONG>sgr</STRONG> string. One
191 consequence of this is that termcap applications assume me (terminfo
192 <STRONG>sgr0</STRONG>) does not reset the alternate character set. This implementation
193 checks for, and modifies the data shown to the termcap interface to ac-
194 commodate termcap's limitation in this respect.
197 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
198 These functions are provided for supporting legacy applications, and
199 should not be used in new programs:
201 <STRONG>o</STRONG> The XSI Curses standard, Issue 4 describes these functions. Howev-
202 er, they are marked TO BE WITHDRAWN and may be removed in future
205 <STRONG>o</STRONG> X/Open Curses, Issue 5 (December 2007) marked the termcap interface
206 (along with <STRONG>vwprintw</STRONG> and <STRONG>vwscanw</STRONG>) as withdrawn.
208 Neither the XSI Curses standard nor the SVr4 man pages documented the
209 return values of <STRONG>tgetent</STRONG> correctly, though all three were in fact re-
210 turned ever since SVr1. In particular, an omission in the XSI Curses
211 documentation has been misinterpreted to mean that <STRONG>tgetent</STRONG> returns <STRONG>OK</STRONG>
212 or <STRONG>ERR</STRONG>. Because the purpose of these functions is to provide compati-
213 bility with the <EM>termcap</EM> library, that is a defect in XCurses, Issue 4,
214 Version 2 rather than in ncurses.
216 External variables are provided for support of certain termcap applica-
217 tions. However, termcap applications' use of those variables is poorly
218 documented, e.g., not distinguishing between input and output. In par-
219 ticular, some applications are reported to declare and/or modify <STRONG>os-</STRONG>
220 <STRONG>peed</STRONG>.
222 The comment that only the first two characters of the <STRONG>id</STRONG> parameter are
223 used escapes many application developers. The original BSD 4.2 termcap
224 library (and historical relics thereof) did not require a trailing null
225 NUL on the parameter name passed to <STRONG>tgetstr</STRONG>, <STRONG>tgetnum</STRONG> and <STRONG>tgetflag</STRONG>.
226 Some applications assume that the termcap interface does not require
227 the trailing NUL for the parameter name. Taking into account these is-
230 <STRONG>o</STRONG> As a special case, <STRONG>tgetflag</STRONG> matched against a single-character
231 identifier provided that was at the end of the terminal descrip-
232 tion. You should not rely upon this behavior in portable programs.
233 This implementation disallows matches against single-character ca-
236 <STRONG>o</STRONG> This implementation disallows matches by the termcap interface
237 against extended capability names which are longer than two charac-
241 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
242 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>, <STRONG><A HREF="term_variables.3x.html">term_variables(3x)</A></STRONG>, <STRONG>putc(3)</STRONG>.
244 https://invisible-island.net/ncurses/tctest.html
248 <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>
252 <li><a href="#h2-NAME">NAME</a></li>
253 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
254 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
256 <li><a href="#h3-INITIALIZATION">INITIALIZATION</a></li>
257 <li><a href="#h3-CAPABILITY-VALUES">CAPABILITY VALUES</a></li>
258 <li><a href="#h3-FORMATTING-CAPABILITIES">FORMATTING CAPABILITIES</a></li>
259 <li><a href="#h3-GLOBAL-VARIABLES">GLOBAL VARIABLES</a></li>
262 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
263 <li><a href="#h2-BUGS">BUGS</a></li>
264 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
265 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>