]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_terminfo.3x
ncurses 6.4 - patch 20230701
[ncurses.git] / man / curs_terminfo.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_terminfo.3x,v 1.93 2023/07/01 15:33:35 tom Exp $
31 .TH curs_terminfo 3X 2023-07-01 "ncurses 6.4" "Library calls"
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .ds n 5
41 .na
42 .hy 0
43 .SH NAME
44 \fBdel_curterm\fP,
45 \fBmvcur\fP,
46 \fBputp\fP,
47 \fBrestartterm\fP,
48 \fBset_curterm\fP,
49 \fBsetupterm\fP,
50 \fBtigetflag\fP,
51 \fBtigetnum\fP,
52 \fBtigetstr\fP,
53 \fBtiparm\fP,
54 \fBtiparm_s\fP,
55 \fBtiscan_s\fP,
56 \fBtparm\fP,
57 \fBtputs\fP,
58 \fBvid_attr\fP,
59 \fBvid_puts\fP,
60 \fBvidattr\fP,
61 \fBvidputs\fP \- \fBcurses\fP interfaces to terminfo database
62 .ad
63 .hy
64 .SH SYNOPSIS
65 .nf
66 \fB#include <curses.h>\fP
67 \fB#include <term.h>\fP
68 .sp
69 \fBTERMINAL *cur_term;\fP
70 .sp
71 \fBconst char * const boolnames[];\fP
72 \fBconst char * const boolcodes[];\fP
73 \fBconst char * const boolfnames[];\fP
74 \fBconst char * const numnames[];\fP
75 \fBconst char * const numcodes[];\fP
76 \fBconst char * const numfnames[];\fP
77 \fBconst char * const strnames[];\fP
78 \fBconst char * const strcodes[];\fP
79 \fBconst char * const strfnames[];\fP
80 .sp
81 \fBint setupterm(const char *\fIterm\fB, int \fIfiledes\fB, int *\fIerrret\fB);\fR
82 .br
83 \fBTERMINAL *set_curterm(TERMINAL *\fInterm\fB);\fR
84 .br
85 \fBint del_curterm(TERMINAL *\fIoterm\fB);\fR
86 .br
87 \fBint restartterm(const char *\fIterm\fB, int \fIfiledes\fB, int *\fIerrret\fB);\fR
88 .sp
89 \fBchar *tparm(const char *\fIstr\fB, ...);\fR
90 .br
91         \fIor\fP
92 .br
93 \fBchar *tparm(const char *\fIstr\fB, long \fIp1 ... \fBlong \fIp9\fB);\fR
94 .sp
95 \fBint tputs(const char *\fIstr\fB, int \fIaffcnt\fB, int (*\fIputc\fB)(int));\fR
96 .br
97 \fBint putp(const char *\fIstr\fB);\fR
98 .sp
99 \fBint vidputs(chtype \fIattrs\fB, int (*\fIputc\fB)(int));\fR
100 .br
101 \fBint vidattr(chtype \fIattrs\fB);\fR
102 .br
103 \fBint vid_puts(attr_t \fIattrs\fB, short \fIpair\fB, void *\fIopts\fB, int (*\fIputc\fB)(int));\fR
104 .br
105 \fBint vid_attr(attr_t \fIattrs\fB, short \fIpair\fB, void *\fIopts\fB);\fR
106 .sp
107 \fBint mvcur(int \fIoldrow\fB, int \fIoldcol\fB, int \fInewrow\fR, int \fInewcol\fB);\fR
108 .sp
109 \fBint tigetflag(const char *\fIcapname\fB);\fR
110 .br
111 \fBint tigetnum(const char *\fIcapname\fB);\fR
112 .br
113 \fBchar *tigetstr(const char *\fIcapname\fB);\fR
114 .sp
115 \fBchar *tiparm(const char *\fIstr\fB, ...);\fR
116 .sp
117 /* extensions */
118 .br
119 \fBchar *tiparm_s(int \fIexpected\fB, int \fImask\fB, const char *\fIstr\fB, ...);\fR
120 .br
121 \fBint tiscan_s(int *\fIexpected\fB, int *\fImask\fB, const char *\fIstr\fB);\fR
122 .br
123 .fi
124 .SH DESCRIPTION
125 These low-level routines must be called by programs that have to deal
126 directly with the \fBterminfo\fP database to handle certain terminal
127 capabilities, such as programming function keys.
128 For all other
129 functionality, \fBcurses\fP routines are more suitable and their use is
130 recommended.
131 .PP
132 None of these functions use (or are aware of) multibyte character strings
133 such as UTF-8:
134 .bP
135 capability names use the POSIX portable character set
136 .bP
137 capability string values have no associated encoding;
138 they are strings of 8-bit characters.
139 .SS Initialization
140 Initially, \fBsetupterm\fP should be called.
141 The high-level curses functions \fBinitscr\fP and
142 \fBnewterm\fP call \fBsetupterm\fP to initialize the
143 low-level set of terminal-dependent variables
144 [listed in \fBterminfo\fP(\*n)].
145 .PP
146 Applications can use the
147 terminal capabilities either directly (via header definitions),
148 or by special functions.
149 The header files \fBcurses.h\fP and \fBterm.h\fP should be included (in this
150 order) to get the definitions for these strings, numbers, and flags.
151 .PP
152 The \fBterminfo\fP variables
153 \fBlines\fP and \fBcolumns\fP are initialized by \fBsetupterm\fP as
154 follows:
155 .bP
156 If \fBuse_env(FALSE)\fP has been called, values for
157 \fBlines\fP and \fBcolumns\fP specified in \fBterminfo\fP are used.
158 .bP
159 Otherwise, if the environment variables \fBLINES\fP and \fBCOLUMNS\fP
160 exist, their values are used.
161 If these environment variables do not
162 exist and the program is running in a window, the current window size
163 is used.
164 Otherwise, if the environment variables do not exist, the
165 values for \fBlines\fP and \fBcolumns\fP specified in the
166 \fBterminfo\fP database are used.
167 .PP
168 Parameterized strings should be passed through \fBtparm\fP to instantiate them.
169 All \fBterminfo\fP strings
170 (including the output of \fBtparm\fP)
171 should be printed
172 with \fBtputs\fP or \fBputp\fP.
173 Call \fBreset_shell_mode\fP to restore the
174 tty modes before exiting [see \fBcurs_kernel\fP(3X)].
175 .PP
176 Programs which use
177 cursor addressing should
178 .bP
179 output \fBenter_ca_mode\fP upon startup and
180 .bP
181 output \fBexit_ca_mode\fP before exiting.
182 .PP
183 Programs which execute shell subprocesses should
184 .bP
185 call \fBreset_shell_mode\fP and
186 output \fBexit_ca_mode\fP before the shell
187 is called and
188 .bP
189 output \fBenter_ca_mode\fP and
190 call \fBreset_prog_mode\fP after returning from the shell.
191 .PP
192 The \fBsetupterm\fP routine reads in the \fBterminfo\fP database,
193 initializing the \fBterminfo\fP structures, but does not set up the
194 output virtualization structures used by \fBcurses\fP.
195 These are its parameters:
196 .RS 3
197 .TP 5
198 \fIterm\fP
199 is the terminal type, a character string.
200 If \fIterm\fP is null, the environment variable \fBTERM\fP is used.
201 .TP 5
202 \fIfiledes\fP
203 is the file descriptor used for getting and setting terminal I/O modes.
204 .IP
205 Higher-level applications use \fBnewterm\fP(3X) for initializing the terminal,
206 passing an output \fIstream\fP rather than a \fIdescriptor\fP.
207 In curses, the two are the same because \fBnewterm\fP calls \fBsetupterm\fP,
208 passing the file descriptor derived from its output stream parameter.
209 .TP 5
210 \fIerrret\fP
211 points to an optional location where an error status can be returned to
212 the caller.
213 If \fIerrret\fP is not null,
214 then \fBsetupterm\fP returns \fBOK\fP or
215 \fBERR\fP and stores a status value in the integer pointed to by
216 \fIerrret\fP.
217 A return value of \fBOK\fP combined with status of \fB1\fP in \fIerrret\fP
218 is normal.
219 .IP
220 If \fBERR\fP is returned, examine \fIerrret\fP:
221 .RS
222 .TP 5
223 .B 1
224 means that the terminal is hardcopy, cannot be used for curses applications.
225 .IP
226 \fBsetupterm\fP determines if the entry is a hardcopy type by
227 checking the \fBhc\fP (\fBhardcopy\fP) capability.
228 .TP 5
229 .B 0
230 means that the terminal could not be found,
231 or that it is a generic type,
232 having too little information for curses applications to run.
233 .IP
234 \fBsetupterm\fP determines if the entry is a generic type by
235 checking the \fBgn\fP (\fBgeneric_type\fP) capability.
236 .TP 5
237 .B \-1
238 means that the \fBterminfo\fP database could not be found.
239 .RE
240 .IP
241 If \fIerrret\fP is
242 null, \fBsetupterm\fP prints an error message upon finding an error
243 and exits.
244 Thus, the simplest call is:
245 .sp
246       \fBsetupterm((char *)0, 1, (int *)0);\fP,
247 .sp
248 which uses all the defaults and sends the output to \fBstdout\fP.
249 .RE
250 .\" ***************************************************************************
251 .SS The Terminal State
252 The \fBsetupterm\fP routine stores its information about the terminal
253 in a \fBTERMINAL\fP structure pointed to by the global variable \fBcur_term\fP.
254 If it detects an error,
255 or decides that the terminal is unsuitable (hardcopy or generic),
256 it discards this information,
257 making it not available to applications.
258 .PP
259 If \fBsetupterm\fP is called repeatedly for the same terminal type,
260 it will reuse the information.
261 It maintains only one copy of a given terminal's capabilities in memory.
262 If it is called for different terminal types,
263 \fBsetupterm\fP allocates new storage for each set of terminal capabilities.
264 .PP
265 The \fBset_curterm\fP routine sets \fBcur_term\fP to
266 \fInterm\fP, and makes all of the \fBterminfo\fP boolean, numeric, and
267 string variables use the values from \fInterm\fP.
268 It returns the old value of \fBcur_term\fP.
269 .PP
270 The \fBdel_curterm\fP routine frees the space pointed to by
271 \fIoterm\fP and makes it available for further use.
272 If \fIoterm\fP is
273 the same as \fBcur_term\fP, references to any of the \fBterminfo\fP
274 boolean, numeric, and string variables thereafter may refer to invalid
275 memory locations until another \fBsetupterm\fP has been called.
276 .PP
277 The \fBrestartterm\fP routine is similar to \fBsetupterm\fP and \fBinitscr\fP,
278 except that it is called after restoring memory to a previous state (for
279 example, when reloading a game saved as a core image dump).
280 \fBrestartterm\fP assumes that the windows and the input and output options
281 are the same as when memory was saved,
282 but the terminal type and baud rate may be different.
283 Accordingly, \fBrestartterm\fP saves various tty state bits,
284 calls \fBsetupterm\fP, and then restores the bits.
285 .\" ***************************************************************************
286 .SS Formatting Output
287 The \fBtparm\fP routine instantiates the string \fIstr\fP with
288 parameters \fIpi\fP.  A pointer is returned to the result of \fIstr\fP
289 with the parameters applied.
290 Application developers should keep in mind these quirks of the interface:
291 .bP
292 Although \fBtparm\fP's actual parameters may be integers or strings,
293 the prototype expects \fBlong\fP (integer) values.
294 .bP
295 Aside from the \fBset_attributes\fP (\fBsgr\fP) capability,
296 most terminal capabilities require no more than one or two parameters.
297 .bP
298 Padding information is ignored by \fBtparm\fP;
299 it is interpreted by \fBtputs\fP.
300 .bP
301 The capability string is null-terminated.
302 Use \*(``\\200\*('' where an ASCII NUL is needed in the output.
303 .PP
304 \fBtiparm\fP is a newer form of \fBtparm\fP which uses \fI<stdarg.h>\fP
305 rather than a fixed-parameter list.
306 Its numeric parameters are integers (int) rather than longs.
307 .PP
308 Both \fBtparm\fP and \fBtiparm\fP assume that the application passes
309 parameters consistent with the terminal description.
310 Two extensions are provided as alternatives to deal with untrusted data:
311 .bP
312 \fBtiparm_s\fP is an extension which is a safer formatting function
313 than \fBtparm\fR or \fBtiparm\fR,
314 because it allows the developer to tell the curses
315 library how many parameters to expect in the parameter list,
316 and which may be string parameters.
317 .IP
318 The \fImask\fP parameter has one bit set for each of the parameters
319 (up to 9) which will be passed as char* rather than numbers.
320 .bP
321 The extension \fBtiscan_s\fP allows the application
322 to inspect a formatting capability to see what the curses library would assume.
323 .\" ***************************************************************************
324 .SS Output Functions
325 The \fBtputs\fP routine applies padding information
326 (i.e., by interpreting marker embedded in the terminfo capability
327 such as \*(``$<5>\*('' as 5 milliseconds)
328 to the string
329 \fIstr\fP and outputs it:
330 .bP
331 The \fIstr\fP parameter must be a terminfo string
332 variable or the return value from
333 \fBtparm\fP, \fBtiparm\fP, \fBtgetstr\fP, or \fBtgoto\fP.
334 .IP
335 The \fBtgetstr\fP and \fBtgoto\fP functions are part of the \fItermcap\fP
336 interface,
337 which happens to share this function name with the \fIterminfo\fP interface.
338 .bP
339 \fIaffcnt\fP is the number of lines affected, or 1 if
340 not applicable.
341 .bP
342 \fIputc\fP is a \fBputchar\fP-like routine to which
343 the characters are passed, one at a time.
344 .PP
345 The \fBputp\fR routine calls \fBtputs(\fIstr\fB, 1, putchar)\fR.
346 The output of \fBputp\fP always goes to \fBstdout\fP, rather than
347 the \fIfiledes\fP specified in \fBsetupterm\fP.
348 .PP
349 The \fBvidputs\fP routine displays the string on the terminal in the
350 video attribute mode \fIattrs\fP, which is any combination of the
351 attributes listed in \fBcurses\fP(3X).
352 The characters are passed to
353 the \fBputchar\fP-like routine \fIputc\fP.
354 .PP
355 The \fBvidattr\fP routine is like the \fBvidputs\fP routine, except
356 that it outputs through \fBputchar\fP.
357 .PP
358 The \fBvid_attr\fP and \fBvid_puts\fP routines correspond
359 to vidattr and vidputs, respectively.
360 They use a set of arguments for representing the video attributes plus color,
361 i.e.,
362 .bP
363 \fIattrs\fP of type \fBattr_t\fP for the attributes and
364 .bP
365 \fIpair\fP of type \fBshort\fP for the color-pair number.
366 .PP
367 The \fBvid_attr\fP and \fBvid_puts\fP routines
368 are designed to use the attribute constants with the \fBWA_\fP prefix.
369 .PP
370 X/Open Curses reserves the \fIopts\fP argument for future use,
371 saying that applications must provide a null pointer for that argument.
372 As an extension,
373 this implementation allows \fIopts\fP to be used as a pointer to \fBint\fP,
374 which overrides the \fIpair\fP (\fBshort\fP) argument.
375 .PP
376 The \fBmvcur\fP routine provides low-level cursor motion.
377 It takes effect immediately (rather than at the next refresh).
378 Unlike the other low-level output functions,
379 which either write to the standard output or pass an output function parameter,
380 \fBmvcur\fP uses an output file descriptor derived from
381 the output stream parameter of \fBnewterm\fP(3X).
382 .PP
383 While \fBputp\fP and \fBmvcur\fP are low-level functions which
384 do not use the high-level curses state,
385 they are declared in \fB<curses.h>\fP because SystemV did this
386 (see \fIHISTORY\fP).
387 .\" ***************************************************************************
388 .SS Terminal Capability Functions
389 The \fBtigetflag\fP, \fBtigetnum\fP and \fBtigetstr\fP routines return
390 the value of the capability corresponding to the \fBterminfo\fP
391 \fIcapname\fP passed to them, such as \fBxenl\fP.
392 The \fIcapname\fP for each capability is given in the table column entitled
393 \fIcapname\fP code in the capabilities section of \fBterminfo\fP(\*n).
394 .PP
395 These routines return special values to denote errors.
396 .PP
397 The \fBtigetflag\fP routine returns
398 .TP
399 \fB\-1\fP
400 if \fIcapname\fP is not a boolean capability,
401 or
402 .TP
403 \fB0\fP
404 if it is canceled or absent from the terminal description.
405 .PP
406 The \fBtigetnum\fP routine returns
407 .TP
408 \fB\-2\fP
409 if \fIcapname\fP is not a numeric capability, or
410 .TP
411 \fB\-1\fP
412 if it is canceled or absent from the terminal description.
413 .PP
414 The \fBtigetstr\fP routine returns
415 .TP
416 \fB(char *)\-1\fP
417 if \fIcapname\fP is not a string capability,
418 or
419 .TP
420 \fB0\fP
421 if it is canceled or absent from the terminal description.
422 .\" ***************************************************************************
423 .SS Terminal Capability Names
424 These null-terminated arrays contain
425 .bP
426 the short terminfo names (\*(``codes\*(''),
427 .bP
428 the \fBtermcap\fP names (\*(``names\*(''), and
429 .bP
430 the long terminfo names (\*(``fnames\*('')
431 .PP
432 for each of the predefined \fBterminfo\fP variables:
433 .sp
434 .RS
435 \fBconst char *boolnames[]\fP, \fB*boolcodes[]\fP, \fB*boolfnames[]\fP
436 .br
437 \fBconst char *numnames[]\fP, \fB*numcodes[]\fP, \fB*numfnames[]\fP
438 .br
439 \fBconst char *strnames[]\fP, \fB*strcodes[]\fP, \fB*strfnames[]\fP
440 .RE
441 .\" ***************************************************************************
442 .SS Releasing Memory
443 Each successful call to \fBsetupterm\fP allocates memory to hold the terminal
444 description.
445 As a side-effect, it sets \fBcur_term\fP to point to this memory.
446 If an application calls
447 .sp
448         \fBdel_curterm(cur_term);\fP
449 .sp
450 the memory will be freed.
451 .PP
452 The formatting functions \fBtparm\fP and \fBtiparm\fP extend the storage
453 allocated by \fBsetupterm\fP:
454 .bP
455 the \*(``static\*('' terminfo variables [a-z].
456 Before ncurses 6.3, those were shared by all screens.
457 With ncurses 6.3, those are allocated per screen.
458 See \fBterminfo\fP(\*n) for details.
459 .bP
460 to improve performance, ncurses 6.3 caches the result of analyzing terminfo
461 strings for their parameter types.
462 That is stored as a binary tree referenced from the \fBTERMINAL\fP structure.
463 .PP
464 The higher-level \fBinitscr\fP and \fBnewterm\fP functions use \fBsetupterm\fP.
465 Normally they do not free this memory, but it is possible to do that using
466 the \fBdelscreen\fP(3X) function.
467 .\" ***************************************************************************
468 .SH RETURN VALUE
469 Routines that return an integer return \fBERR\fP upon failure and \fBOK\fP
470 (SVr4 only specifies \*(``an integer value other than \fBERR\fP\*('')
471 upon successful completion,
472 unless otherwise noted in the preceding routine descriptions.
473 .PP
474 Routines that return pointers always return \fBNULL\fP on error.
475 .PP
476 X/Open defines no error conditions.
477 In this implementation
478 .RS 3
479 .TP 5
480 \fBdel_curterm\fP
481 returns an error
482 if its terminal parameter is null.
483 .TP 5
484 \fBputp\fP
485 calls \fBtputs\fP, returning the same error-codes.
486 .TP 5
487 \fBrestartterm\fP
488 returns an error
489 if the associated call to \fBsetupterm\fP returns an error.
490 .TP 5
491 \fBsetupterm\fP
492 returns an error
493 if it cannot allocate enough memory, or
494 create the initial windows (stdscr, curscr, newscr).
495 Other error conditions are documented above.
496 .TP 5
497 \fBtparm\fP
498 returns a null if the capability would require unexpected parameters,
499 e.g., too many, too few, or incorrect types
500 (strings where integers are expected, or vice versa).
501 .TP 5
502 \fBtputs\fP
503 returns an error if the string parameter is null.
504 It does not detect I/O errors:
505 X/Open states that \fBtputs\fP ignores the return value
506 of the output function \fIputc\fP.
507 .RE
508 .\" ***************************************************************************
509 .SS Compatibility macros
510 This implementation provides a few macros for compatibility with systems
511 before SVr4 (see \fIHISTORY\fP).
512 Those include
513 \fBcrmode\fP,
514 \fBfixterm\fP,
515 \fBgettmode\fP,
516 \fBnocrmode\fP,
517 \fBresetterm\fP,
518 \fBsaveterm\fP, and
519 \fBsetterm\fP.
520 .PP
521 In SVr4, those are found in \fB<curses.h>\fP,
522 but except for \fBsetterm\fP, are likewise macros.
523 The one function, \fBsetterm\fP, is mentioned in the manual page.
524 The manual page notes that the \fBsetterm\fP routine
525 was replaced by \fBsetupterm\fP, stating that the call:
526 .sp
527       \fBsetupterm(\fIterm\fB, 1, (int *)0)\fR
528 .sp
529 provides the same functionality as \fBsetterm(\fIterm\fB)\fR,
530 and is not recommended for new programs.
531 This implementation provides each of those symbols
532 as macros for BSD compatibility,
533 .\" ***************************************************************************
534 .SH HISTORY
535 SVr2 introduced the terminfo feature.
536 Its programming manual mentioned these low-level functions:
537 .TS
538 l l
539 _ _
540 l l.
541 \fBFunction\fP  \fBDescription\fP
542 fixterm restore tty to \*(``in curses\*('' state
543 gettmode        establish current tty modes
544 mvcur   low level cursor motion
545 putp    T{
546 utility function that uses \fBtputs\fP to send characters via \fBputchar\fP.
547 T}
548 resetterm       set tty modes to \*(``out of curses\*('' state
549 resetty reset tty flags to stored value
550 saveterm        save current modes as \*(``in curses\*('' state
551 savetty store current tty flags
552 setterm establish terminal with given type
553 setupterm       establish terminal with given type
554 tparm   instantiate a string expression with parameters
555 tputs   apply padding information to a string
556 vidattr like \fBvidputs\fP, but outputs through \fBputchar\fP
557 vidputs T{
558 output a string to put terminal in a specified video attribute mode
559 T}
560 .TE
561 .PP
562 The programming manual also mentioned
563 functions provided for termcap compatibility
564 (commenting that they \*(``may go away at a later date\*(''):
565 .TS
566 l l
567 _ _
568 l l.
569 \fBFunction\fP  \fBDescription\fP
570 tgetent look up termcap entry for given \fIname\fP
571 tgetflag        get boolean entry for given \fIid\fP
572 tgetnum get numeric entry for given \fIid\fP
573 tgetstr get string entry for given \fIid\fP
574 tgoto   apply parameters to given capability
575 tputs   T{
576 apply padding to capability, calling a function to put characters
577 T}
578 .TE
579 .PP
580 Early terminfo programs obtained capability values from the
581 \fBTERMINAL\fP structure initialized by \fBsetupterm\fP.
582 .PP
583 SVr3 extended terminfo by adding functions to retrieve capability values
584 (like the termcap interface),
585 and reusing tgoto and tputs:
586 .TS
587 l l
588 _ _
589 l l.
590 \fBFunction\fP  \fBDescription\fP
591 tigetflag       get boolean entry for given \fIid\fP
592 tigetnum        get numeric entry for given \fIid\fP
593 tigetstr        get string entry for given \fIid\fP
594 .TE
595 .PP
596 SVr3 also replaced several of the SVr2 terminfo functions
597 which had no counterpart in the termcap interface,
598 documenting them as obsolete:
599 .TS
600 l l
601 _ _
602 l l.
603 \fBFunction\fP  \fBReplaced by\fP
604 crmode  cbreak
605 fixterm reset_prog_mode
606 gettmode        N/A
607 nocrmode        nocbreak
608 resetterm       reset_shell_mode
609 saveterm        def_prog_mode
610 setterm setupterm
611 .TE
612 .PP
613 SVr3 kept the \fBmvcur\fP, \fBvidattr\fP and \fBvidputs\fP functions,
614 along with \fBputp\fP, \fBtparm\fP and \fBtputs\fP.
615 The latter were needed to support padding,
616 and handling functions such as \fBvidattr\fP
617 (which used more than the two parameters supported by \fBtgoto\fP).
618 .PP
619 SVr3 introduced the functions for switching between terminal
620 descriptions, e.g., \fBset_curterm\fP.
621 Some of that was incremental improvements to the SVr2 library:
622 .bP
623 The \fBTERMINAL\fP type definition was introduced in SVr3.01,
624 for the \fBterm\fP structure provided in SVr2.
625 .bP
626 The various global variables such as \fBboolnames\fP were mentioned
627 in the programming manual at this point,
628 though the variables were provided in SVr2.
629 .PP
630 SVr4 added the \fBvid_attr\fP and \fBvid_puts\fP functions.
631 .PP
632 There are other low-level functions declared in the curses header files
633 on Unix systems,
634 but none were documented.
635 The functions marked \*(``obsolete\*('' remained in use
636 by the Unix \fBvi\fP(1) editor.
637 .SH PORTABILITY
638 .SS Extensions
639 The functions marked as extensions were designed for \fBncurses\fP(3X),
640 and are not found in SVr4 curses, 4.4BSD curses,
641 or any other previous version of curses.
642 .SS Legacy functions
643 X/Open notes that \fBvidattr\fP and \fBvidputs\fP may be macros.
644 .PP
645 The function \fBsetterm\fP is not described by X/Open and must
646 be considered non-portable.
647 All other functions are as described by X/Open.
648 .SS Legacy data
649 \fBsetupterm\fP copies the terminal name to the array \fBttytype\fP.
650 This is not part of X/Open Curses, but is assumed by some applications.
651 .PP
652 Other implementions may not declare the capability name arrays.
653 Some provide them without declaring them.
654 X/Open does not specify them.
655 .PP
656 Extended terminal capability names, e.g., as defined by \fB@TIC@\ \-x\fP,
657 are not stored in the arrays described here.
658 .SS Output buffering
659 Older versions of \fBncurses\fP assumed that the file descriptor passed to
660 \fBsetupterm\fP from \fBinitscr\fP or \fBnewterm\fP uses buffered I/O,
661 and would write to the corresponding stream.
662 In addition to the limitation that the terminal was left in block-buffered
663 mode on exit (like System V curses),
664 it was problematic because \fBncurses\fP
665 did not allow a reliable way to cleanup on receiving SIGTSTP.
666 .PP
667 The current version (ncurses6)
668 uses output buffers managed directly by \fBncurses\fP.
669 Some of the low-level functions described in this manual page write
670 to the standard output.
671 They are not signal-safe.
672 The high-level functions in \fBncurses\fP use
673 alternate versions of these functions
674 using the more reliable buffering scheme.
675 .SS Function prototypes
676 The X/Open Curses prototypes are based on the SVr4 curses header declarations,
677 which were defined at the same time the C language was first standardized in
678 the late 1980s.
679 .bP
680 X/Open Curses uses \fBconst\fP less effectively than a later design might,
681 in some cases applying it needlessly to values are already constant,
682 and in most cases overlooking parameters which normally would use \fBconst\fP.
683 Using constant parameters for functions which do not use \fBconst\fP
684 may prevent the program from compiling.
685 On the other hand, \fIwritable strings\fP are an obsolescent feature.
686 .IP
687 As an extension, this implementation can be configured to change the
688 function prototypes to use the \fBconst\fP keyword.
689 The ncurses ABI 6 enables this feature by default.
690 .bP
691 X/Open Curses prototypes \fBtparm\fP with a fixed number of parameters,
692 rather than a variable argument list.
693 .IP
694 This implementation uses a variable argument list, but can be
695 configured to use the fixed-parameter list.
696 Portable applications should provide 9 parameters after the format;
697 zeroes are fine for this purpose.
698 .IP
699 In response to review comments by Thomas E. Dickey,
700 X/Open Curses Issue 7 proposed the \fBtiparm\fP function in mid-2009.
701 .IP
702 While \fBtiparm\fP is always provided in ncurses,
703 the older form is only available as a build-time configuration option.
704 If not specially configured, \fBtparm\fP is the same as \fBtiparm\fP.
705 .PP
706 Both forms of \fBtparm\fP have drawbacks:
707 .bP
708 Most of the calls to \fBtparm\fP use only one or two parameters.
709 Passing nine on each call is awkward.
710 .IP
711 Using \fBlong\fP for the numeric parameter type is a workaround
712 to make the parameter use the same amount of stack as a pointer.
713 That approach dates back to the mid-1980s, before C was standardized.
714 Since then, there is a standard
715 (and pointers are not required to fit in a long).
716 .bP
717 Providing the right number of parameters for a variadic function
718 such as \fBtiparm\fP can be a problem, in particular for string parameters.
719 However, only a few terminfo capabilities use string parameters
720 (e.g., the ones used for programmable function keys).
721 .IP
722 The ncurses library checks usage of these capabilities,
723 and returns an error if the capability mishandles string parameters.
724 But it cannot check if a calling program provides strings in the right
725 places for the \fBtparm\fP calls.
726 .IP
727 The \fB@TPUT@\fR(1) program checks its use of these capabilities with a table,
728 so that it calls \fBtparm\fP correctly.
729 .SS Special TERM treatment
730 If configured to use the terminal-driver,
731 e.g., for the MinGW port,
732 .bP
733 \fBsetupterm\fP interprets a missing/empty TERM variable as the
734 special value \*(``unknown\*(''.
735 .IP
736 SVr4 curses uses the
737 special value \*(``dumb\*(''.
738 .IP
739 The difference between the two is that
740 the former uses the \fBgn\fP (\fBgeneric_type\fR) terminfo capability,
741 while the latter does not.
742 A generic terminal is unsuitable for full-screen applications.
743 .bP
744 \fBsetupterm\fP allows explicit use of the
745 the windows console driver by checking if $TERM is set to
746 \*(``#win32con\*('' or an abbreviation of that string.
747 .SS Other portability issues
748 In System V Release 4, \fBset_curterm\fP has an \fBint\fP return type and
749 returns \fBOK\fP or \fBERR\fP.  We have chosen to implement the X/Open Curses
750 semantics.
751 .PP
752 In System V Release 4, the third argument of \fBtputs\fP has the type
753 \fBint (*putc)(char)\fP.
754 .PP
755 At least one implementation of X/Open Curses (Solaris) returns a value
756 other than \fBOK\fP/\fBERR\fP from \fBtputs\fP.
757 That returns the length of the string, and does no error-checking.
758 .PP
759 X/Open notes that after calling \fBmvcur\fP, the curses state may not match the
760 actual terminal state, and that an application should touch and refresh
761 the window before resuming normal curses calls.
762 Both \fBncurses\fP and System V Release 4 curses implement \fBmvcur\fP using
763 the SCREEN data allocated in either \fBinitscr\fP or \fBnewterm\fP.
764 So though it is documented as a terminfo function,
765 \fBmvcur\fP is really a curses function which is not well specified.
766 .PP
767 X/Open states that the old location must be given for \fBmvcur\fP.
768 This implementation allows the caller to use \-1's for the old ordinates.
769 In that case, the old location is unknown.
770 .SH SEE ALSO
771 \fBcurses\fP(3X),
772 \fBcurs_initscr\fP(3X),
773 \fBcurs_kernel\fP(3X),
774 \fBcurs_memleaks\fP(3X),
775 \fBcurs_termcap\fP(3X),
776 \fBcurs_variables\fP(3X),
777 \fBterm_variables\fP(3X),
778 \fBputc\fP(3),
779 \fBterminfo\fP(\*n)