]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_terminfo.3x
bd418951454c91881acd26a07e59534e731a4e43
[ncurses.git] / man / curs_terminfo.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
4 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
5 .\"                                                                          *
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:                 *
13 .\"                                                                          *
14 .\" The above copyright notice and this permission notice shall be included  *
15 .\" in all copies or substantial portions of the Software.                   *
16 .\"                                                                          *
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.                               *
24 .\"                                                                          *
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       *
28 .\" authorization.                                                           *
29 .\"***************************************************************************
30 .\"
31 .\" $Id: curs_terminfo.3x,v 1.99 2023/09/16 23:37:03 tom Exp $
32 .TH curs_terminfo 3X 2023-09-16 "ncurses 6.4" "Library calls"
33 .ie \n(.g .ds `` \(lq
34 .el       .ds `` ``
35 .ie \n(.g .ds '' \(rq
36 .el       .ds '' ''
37 .de bP
38 .ie n  .IP \(bu 4
39 .el    .IP \(bu 2
40 ..
41 .ds n 5
42 .SH NAME
43 \fB\%del_curterm\fP,
44 \fB\%mvcur\fP,
45 \fB\%putp\fP,
46 \fB\%restartterm\fP,
47 \fB\%set_curterm\fP,
48 \fB\%setupterm\fP,
49 \fB\%tigetflag\fP,
50 \fB\%tigetnum\fP,
51 \fB\%tigetstr\fP,
52 \fB\%tiparm\fP,
53 \fB\%tiparm_s\fP,
54 \fB\%tiscan_s\fP,
55 \fB\%tparm\fP,
56 \fB\%tputs\fP,
57 \fB\%vid_attr\fP,
58 \fB\%vid_puts\fP,
59 \fB\%vidattr\fP,
60 \fB\%vidputs\fP \-
61 \fIcurses\fR interfaces to \fIterminfo\fR database
62 .SH SYNOPSIS
63 .nf
64 \fB#include <curses.h>\fP
65 \fB#include <term.h>\fP
66 .sp
67 \fBTERMINAL *cur_term;\fP
68 .sp
69 \fBconst char * const boolnames[];\fP
70 \fBconst char * const boolcodes[];\fP
71 \fBconst char * const boolfnames[];\fP
72 \fBconst char * const numnames[];\fP
73 \fBconst char * const numcodes[];\fP
74 \fBconst char * const numfnames[];\fP
75 \fBconst char * const strnames[];\fP
76 \fBconst char * const strcodes[];\fP
77 \fBconst char * const strfnames[];\fP
78 .sp
79 \fBint setupterm(const char *\fIterm\fB, int \fIfiledes\fB, int *\fIerrret\fB);\fR
80 .br
81 \fBTERMINAL *set_curterm(TERMINAL *\fInterm\fB);\fR
82 .br
83 \fBint del_curterm(TERMINAL *\fIoterm\fB);\fR
84 .br
85 \fBint restartterm(const char *\fIterm\fB, int \fIfiledes\fB, int *\fIerrret\fB);\fR
86 .sp
87 \fBchar *tparm(const char *\fIstr\fB, ...);\fR
88 .br
89         \fIor\fP
90 .br
91 \fBchar *tparm(const char *\fIstr\fB, long \fIp1 ... \fBlong \fIp9\fB);\fR
92 .sp
93 \fBint tputs(const char *\fIstr\fB, int \fIaffcnt\fB, int (*\fIputc\fB)(int));\fR
94 .br
95 \fBint putp(const char *\fIstr\fB);\fR
96 .sp
97 \fBint vidputs(chtype \fIattrs\fB, int (*\fIputc\fB)(int));\fR
98 .br
99 \fBint vidattr(chtype \fIattrs\fB);\fR
100 .br
101 \fBint vid_puts(attr_t \fIattrs\fB, short \fIpair\fB, void *\fIopts\fB, int (*\fIputc\fB)(int));\fR
102 .br
103 \fBint vid_attr(attr_t \fIattrs\fB, short \fIpair\fB, void *\fIopts\fB);\fR
104 .sp
105 \fBint mvcur(int \fIoldrow\fB, int \fIoldcol\fB, int \fInewrow\fR, int \fInewcol\fB);\fR
106 .sp
107 \fBint tigetflag(const char *\fIcapname\fB);\fR
108 .br
109 \fBint tigetnum(const char *\fIcapname\fB);\fR
110 .br
111 \fBchar *tigetstr(const char *\fIcapname\fB);\fR
112 .sp
113 \fBchar *tiparm(const char *\fIstr\fB, ...);\fR
114 .sp
115 /* extensions */
116 .br
117 \fBchar *tiparm_s(int \fIexpected\fB, int \fImask\fB, const char *\fIstr\fB, ...);\fR
118 .br
119 \fBint tiscan_s(int *\fIexpected\fB, int *\fImask\fB, const char *\fIstr\fB);\fR
120 .br
121 .fi
122 .SH DESCRIPTION
123 These low-level routines must be called by programs that have to deal
124 directly with the \fBterminfo\fP database to handle certain terminal
125 capabilities, such as programming function keys.
126 For all other
127 functionality, \fBcurses\fP routines are more suitable and their use is
128 recommended.
129 .PP
130 None of these functions use (or are aware of) multibyte character strings
131 such as UTF-8:
132 .bP
133 capability names use the POSIX portable character set
134 .bP
135 capability string values have no associated encoding;
136 they are strings of 8-bit characters.
137 .SS Initialization
138 Initially, \fBsetupterm\fP should be called.
139 The high-level curses functions \fBinitscr\fP and
140 \fBnewterm\fP call \fBsetupterm\fP to initialize the
141 low-level set of terminal-dependent variables
142 [listed in \fBterminfo\fP(\*n)].
143 .PP
144 Applications can use the
145 terminal capabilities either directly (via header definitions),
146 or by special functions.
147 The header files \fBcurses.h\fP and \fBterm.h\fP should be included (in this
148 order) to get the definitions for these strings, numbers, and flags.
149 .PP
150 The \fBterminfo\fP variables
151 \fBlines\fP and \fBcolumns\fP are initialized by \fBsetupterm\fP as
152 follows:
153 .bP
154 If \fBuse_env(FALSE)\fP has been called, values for
155 \fBlines\fP and \fBcolumns\fP specified in \fBterminfo\fP are used.
156 .bP
157 Otherwise, if the environment variables \fBLINES\fP and \fBCOLUMNS\fP
158 exist, their values are used.
159 If these environment variables do not
160 exist and the program is running in a window, the current window size
161 is used.
162 Otherwise, if the environment variables do not exist, the
163 values for \fBlines\fP and \fBcolumns\fP specified in the
164 \fBterminfo\fP database are used.
165 .PP
166 Parameterized strings should be passed through \fBtparm\fP to instantiate them.
167 All \fBterminfo\fP strings
168 (including the output of \fBtparm\fP)
169 should be printed
170 with \fBtputs\fP or \fBputp\fP.
171 Call \fBreset_shell_mode\fP to restore the
172 tty modes before exiting [see \fBcurs_kernel\fP(3X)].
173 .PP
174 Programs which use
175 cursor addressing should
176 .bP
177 output \fBenter_ca_mode\fP upon startup and
178 .bP
179 output \fBexit_ca_mode\fP before exiting.
180 .PP
181 Programs which execute shell subprocesses should
182 .bP
183 call \fBreset_shell_mode\fP and
184 output \fBexit_ca_mode\fP before the shell
185 is called and
186 .bP
187 output \fBenter_ca_mode\fP and
188 call \fBreset_prog_mode\fP after returning from the shell.
189 .PP
190 The \fBsetupterm\fP routine reads in the \fBterminfo\fP database,
191 initializing the \fBterminfo\fP structures, but does not set up the
192 output virtualization structures used by \fBcurses\fP.
193 These are its parameters:
194 .RS 3
195 .TP 5
196 \fIterm\fP
197 is the terminal type, a character string.
198 If \fIterm\fP is null, the environment variable \fBTERM\fP is used.
199 .TP 5
200 \fIfiledes\fP
201 is the file descriptor used for getting and setting terminal I/O modes.
202 .IP
203 Higher-level applications use \fBnewterm\fP(3X) for initializing the terminal,
204 passing an output \fIstream\fP rather than a \fIdescriptor\fP.
205 In curses, the two are the same because \fBnewterm\fP calls \fBsetupterm\fP,
206 passing the file descriptor derived from its output stream parameter.
207 .TP 5
208 \fIerrret\fP
209 points to an optional location where an error status can be returned to
210 the caller.
211 If \fIerrret\fP is not null,
212 then \fBsetupterm\fP returns \fBOK\fP or
213 \fBERR\fP and stores a status value in the integer pointed to by
214 \fIerrret\fP.
215 A return value of \fBOK\fP combined with status of \fB1\fP in \fIerrret\fP
216 is normal.
217 .IP
218 If \fBERR\fP is returned, examine \fIerrret\fP:
219 .RS
220 .TP 5
221 .B 1
222 means that the terminal is hardcopy, cannot be used for curses applications.
223 .IP
224 \fBsetupterm\fP determines if the entry is a hardcopy type by
225 checking the \fBhc\fP (\fBhardcopy\fP) capability.
226 .TP 5
227 .B 0
228 means that the terminal could not be found,
229 or that it is a generic type,
230 having too little information for curses applications to run.
231 .IP
232 \fBsetupterm\fP determines if the entry is a generic type by
233 checking the \fBgn\fP (\fBgeneric_type\fP) capability.
234 .TP 5
235 .B \-1
236 means that the \fBterminfo\fP database could not be found.
237 .RE
238 .IP
239 If \fIerrret\fP is
240 null, \fBsetupterm\fP prints an error message upon finding an error
241 and exits.
242 Thus, the simplest call is:
243 .sp
244       \fBsetupterm((char *)0, 1, (int *)0);\fP,
245 .sp
246 which uses all the defaults and sends the output to \fBstdout\fP.
247 .RE
248 .\" ***************************************************************************
249 .SS The Terminal State
250 The \fBsetupterm\fP routine stores its information about the terminal
251 in a \fBTERMINAL\fP structure pointed to by the global variable \fBcur_term\fP.
252 If it detects an error,
253 or decides that the terminal is unsuitable (hardcopy or generic),
254 it discards this information,
255 making it not available to applications.
256 .PP
257 If \fBsetupterm\fP is called repeatedly for the same terminal type,
258 it will reuse the information.
259 It maintains only one copy of a given terminal's capabilities in memory.
260 If it is called for different terminal types,
261 \fBsetupterm\fP allocates new storage for each set of terminal capabilities.
262 .PP
263 The \fBset_curterm\fP routine sets \fBcur_term\fP to
264 \fInterm\fP, and makes all of the \fBterminfo\fP boolean, numeric, and
265 string variables use the values from \fInterm\fP.
266 It returns the old value of \fBcur_term\fP.
267 .PP
268 The \fBdel_curterm\fP routine frees the space pointed to by
269 \fIoterm\fP and makes it available for further use.
270 If \fIoterm\fP is
271 the same as \fBcur_term\fP, references to any of the \fBterminfo\fP
272 boolean, numeric, and string variables thereafter may refer to invalid
273 memory locations until another \fBsetupterm\fP has been called.
274 .PP
275 The \fBrestartterm\fP routine is similar to \fBsetupterm\fP and \fBinitscr\fP,
276 except that it is called after restoring memory to a previous state (for
277 example, when reloading a game saved as a core image dump).
278 \fBrestartterm\fP assumes that the windows and the input and output options
279 are the same as when memory was saved,
280 but the terminal type and baud rate may be different.
281 Accordingly, \fBrestartterm\fP saves various tty state bits,
282 calls \fBsetupterm\fP, and then restores the bits.
283 .\" ***************************************************************************
284 .SS Formatting Output
285 The \fBtparm\fP routine instantiates the string \fIstr\fP with
286 parameters \fIpi\fP.  A pointer is returned to the result of \fIstr\fP
287 with the parameters applied.
288 Application developers should keep in mind these quirks of the interface:
289 .bP
290 Although \fBtparm\fP's actual parameters may be integers or strings,
291 the prototype expects \fBlong\fP (integer) values.
292 .bP
293 Aside from the \fBset_attributes\fP (\fBsgr\fP) capability,
294 most terminal capabilities require no more than one or two parameters.
295 .bP
296 Padding information is ignored by \fBtparm\fP;
297 it is interpreted by \fBtputs\fP.
298 .bP
299 The capability string is null-terminated.
300 Use \*(``\\200\*('' where an ASCII NUL is needed in the output.
301 .PP
302 \fBtiparm\fP is a newer form of \fBtparm\fP which uses \fI<stdarg.h>\fP
303 rather than a fixed-parameter list.
304 Its numeric parameters are integers (int) rather than longs.
305 .PP
306 Both \fBtparm\fP and \fBtiparm\fP assume that the application passes
307 parameters consistent with the terminal description.
308 Two extensions are provided as alternatives to deal with untrusted data:
309 .bP
310 \fBtiparm_s\fP is an extension which is a safer formatting function
311 than \fBtparm\fR or \fBtiparm\fR,
312 because it allows the developer to tell the curses
313 library how many parameters to expect in the parameter list,
314 and which may be string parameters.
315 .IP
316 The \fImask\fP parameter has one bit set for each of the parameters
317 (up to 9) which will be passed as char* rather than numbers.
318 .bP
319 The extension \fBtiscan_s\fP allows the application
320 to inspect a formatting capability to see what the curses library would assume.
321 .\" ***************************************************************************
322 .SS Output Functions
323 The \fBtputs\fP routine applies padding information
324 (i.e., by interpreting marker embedded in the terminfo capability
325 such as \*(``$<5>\*('' as 5 milliseconds)
326 to the string
327 \fIstr\fP and outputs it:
328 .bP
329 The \fIstr\fP parameter must be a terminfo string
330 variable or the return value from
331 \fBtparm\fP, \fBtiparm\fP, \fBtgetstr\fP, or \fBtgoto\fP.
332 .IP
333 The \fBtgetstr\fP and \fBtgoto\fP functions are part of the \fItermcap\fP
334 interface,
335 which happens to share this function name with the \fIterminfo\fP interface.
336 .bP
337 \fIaffcnt\fP is the number of lines affected, or 1 if
338 not applicable.
339 .bP
340 \fIputc\fP is a \fBputchar\fP-like routine to which
341 the characters are passed, one at a time.
342 .PP
343 The \fBputp\fR routine calls \fBtputs(\fIstr\fB, 1, putchar)\fR.
344 The output of \fBputp\fP always goes to \fBstdout\fP, rather than
345 the \fIfiledes\fP specified in \fBsetupterm\fP.
346 .PP
347 The \fBvidputs\fP routine displays the string on the terminal in the
348 video attribute mode \fIattrs\fP, which is any combination of the
349 attributes listed in \fBcurses\fP(3X).
350 The characters are passed to
351 the \fBputchar\fP-like routine \fIputc\fP.
352 .PP
353 The \fBvidattr\fP routine is like the \fBvidputs\fP routine, except
354 that it outputs through \fBputchar\fP.
355 .PP
356 The \fBvid_attr\fP and \fBvid_puts\fP routines correspond
357 to vidattr and vidputs, respectively.
358 They use a set of arguments for representing the video attributes plus color,
359 i.e.,
360 .bP
361 \fIattrs\fP of type \fBattr_t\fP for the attributes and
362 .bP
363 \fIpair\fP of type \fBshort\fP for the color-pair number.
364 .PP
365 The \fBvid_attr\fP and \fBvid_puts\fP routines
366 are designed to use the attribute constants with the \fBWA_\fP prefix.
367 .PP
368 X/Open Curses reserves the \fIopts\fP argument for future use,
369 saying that applications must provide a null pointer for that argument.
370 As an extension,
371 this implementation allows \fIopts\fP to be used as a pointer to \fBint\fP,
372 which overrides the \fIpair\fP (\fBshort\fP) argument.
373 .PP
374 The \fBmvcur\fP routine provides low-level cursor motion.
375 It takes effect immediately (rather than at the next refresh).
376 Unlike the other low-level output functions,
377 which either write to the standard output or pass an output function parameter,
378 \fBmvcur\fP uses an output file descriptor derived from
379 the output stream parameter of \fBnewterm\fP(3X).
380 .PP
381 While \fBputp\fP and \fBmvcur\fP are low-level functions which
382 do not use the high-level curses state,
383 they are declared in \fB<curses.h>\fP because SystemV did this
384 (see \fIHISTORY\fP).
385 .\" ***************************************************************************
386 .SS Terminal Capability Functions
387 The \fBtigetflag\fP, \fBtigetnum\fP and \fBtigetstr\fP routines return
388 the value of the capability corresponding to the \fBterminfo\fP
389 \fIcapname\fP passed to them, such as \fBxenl\fP.
390 The \fIcapname\fP for each capability is given in the table column entitled
391 \fIcapname\fP code in the capabilities section of \fBterminfo\fP(\*n).
392 .PP
393 These routines return special values to denote errors.
394 .PP
395 The \fBtigetflag\fP routine returns
396 .TP
397 \fB\-1\fP
398 if \fIcapname\fP is not a boolean capability,
399 or
400 .TP
401 \fB0\fP
402 if it is canceled or absent from the terminal description.
403 .PP
404 The \fBtigetnum\fP routine returns
405 .TP
406 \fB\-2\fP
407 if \fIcapname\fP is not a numeric capability, or
408 .TP
409 \fB\-1\fP
410 if it is canceled or absent from the terminal description.
411 .PP
412 The \fBtigetstr\fP routine returns
413 .TP
414 \fB(char *)\-1\fP
415 if \fIcapname\fP is not a string capability,
416 or
417 .TP
418 \fB0\fP
419 if it is canceled or absent from the terminal description.
420 .\" ***************************************************************************
421 .SS Terminal Capability Names
422 These null-terminated arrays contain
423 .bP
424 the short terminfo names (\*(``codes\*(''),
425 .bP
426 the \fBtermcap\fP names (\*(``names\*(''), and
427 .bP
428 the long terminfo names (\*(``fnames\*('')
429 .PP
430 for each of the predefined \fBterminfo\fP variables:
431 .sp
432 .RS
433 \fBconst char *boolnames[]\fP, \fB*boolcodes[]\fP, \fB*boolfnames[]\fP
434 .br
435 \fBconst char *numnames[]\fP, \fB*numcodes[]\fP, \fB*numfnames[]\fP
436 .br
437 \fBconst char *strnames[]\fP, \fB*strcodes[]\fP, \fB*strfnames[]\fP
438 .RE
439 .\" ***************************************************************************
440 .SS Releasing Memory
441 Each successful call to \fBsetupterm\fP allocates memory to hold the terminal
442 description.
443 As a side-effect, it sets \fBcur_term\fP to point to this memory.
444 If an application calls
445 .sp
446         \fBdel_curterm(cur_term);\fP
447 .sp
448 the memory will be freed.
449 .PP
450 The formatting functions \fBtparm\fP and \fBtiparm\fP extend the storage
451 allocated by \fBsetupterm\fP:
452 .bP
453 the \*(``static\*('' terminfo variables [a-z].
454 Before ncurses 6.3, those were shared by all screens.
455 With ncurses 6.3, those are allocated per screen.
456 See \fBterminfo\fP(\*n) for details.
457 .bP
458 to improve performance, ncurses 6.3 caches the result of analyzing terminfo
459 strings for their parameter types.
460 That is stored as a binary tree referenced from the \fBTERMINAL\fP structure.
461 .PP
462 The higher-level \fBinitscr\fP and \fBnewterm\fP functions use \fBsetupterm\fP.
463 Normally they do not free this memory, but it is possible to do that using
464 the \fBdelscreen\fP(3X) function.
465 .\" ***************************************************************************
466 .SH RETURN VALUE
467 Routines that return an integer return \fBERR\fP upon failure and \fBOK\fP
468 (SVr4 only specifies \*(``an integer value other than \fBERR\fP\*('')
469 upon successful completion,
470 unless otherwise noted in the preceding routine descriptions.
471 .PP
472 Routines that return pointers always return \fBNULL\fP on error.
473 .PP
474 X/Open defines no error conditions.
475 In this implementation
476 .RS 3
477 .TP 5
478 \fBdel_curterm\fP
479 returns an error
480 if its terminal parameter is null.
481 .TP 5
482 \fBputp\fP
483 calls \fBtputs\fP, returning the same error-codes.
484 .TP 5
485 \fBrestartterm\fP
486 returns an error
487 if the associated call to \fBsetupterm\fP returns an error.
488 .TP 5
489 \fBsetupterm\fP
490 returns an error
491 if it cannot allocate enough memory, or
492 create the initial windows (stdscr, curscr, newscr).
493 Other error conditions are documented above.
494 .TP 5
495 \fBtparm\fP
496 returns a null if the capability would require unexpected parameters,
497 e.g., too many, too few, or incorrect types
498 (strings where integers are expected, or vice versa).
499 .TP 5
500 \fBtputs\fP
501 returns an error if the string parameter is null.
502 It does not detect I/O errors:
503 X/Open states that \fBtputs\fP ignores the return value
504 of the output function \fIputc\fP.
505 .RE
506 .\" ***************************************************************************
507 .SS Compatibility macros
508 This implementation provides a few macros for compatibility with systems
509 before SVr4 (see \fIHISTORY\fP).
510 Those include
511 \fBcrmode\fP,
512 \fBfixterm\fP,
513 \fBgettmode\fP,
514 \fBnocrmode\fP,
515 \fBresetterm\fP,
516 \fBsaveterm\fP, and
517 \fBsetterm\fP.
518 .PP
519 In SVr4, those are found in \fB<curses.h>\fP,
520 but except for \fBsetterm\fP, are likewise macros.
521 The one function, \fBsetterm\fP, is mentioned in the manual page.
522 The manual page notes that the \fBsetterm\fP routine
523 was replaced by \fBsetupterm\fP, stating that the call:
524 .sp
525       \fBsetupterm(\fIterm\fB, 1, (int *)0)\fR
526 .sp
527 provides the same functionality as \fBsetterm(\fIterm\fB)\fR,
528 and is not recommended for new programs.
529 This implementation provides each of those symbols
530 as macros for BSD compatibility,
531 .\" ***************************************************************************
532 .SH HISTORY
533 SVr2 introduced the terminfo feature.
534 Its programming manual mentioned these low-level functions:
535 .PP
536 .TS
537 l l.
538 \fBFunction\fP  \fBDescription\fP
539 _
540 fixterm restore tty to \*(``in curses\*('' state
541 gettmode        establish current tty modes
542 mvcur   low level cursor motion
543 putp    T{
544 utility function that uses \fBtputs\fP to send characters via \fBputchar\fP.
545 T}
546 resetterm       set tty modes to \*(``out of curses\*('' state
547 resetty reset tty flags to stored value
548 saveterm        save current modes as \*(``in curses\*('' state
549 savetty store current tty flags
550 setterm establish terminal with given type
551 setupterm       establish terminal with given type
552 tparm   instantiate a string expression with parameters
553 tputs   apply padding information to a string
554 vidattr like \fBvidputs\fP, but outputs through \fBputchar\fP
555 vidputs T{
556 output a string to put terminal in a specified video attribute mode
557 T}
558 .TE
559 .PP
560 The programming manual also mentioned
561 functions provided for termcap compatibility
562 (commenting that they \*(``may go away at a later date\*(''):
563 .PP
564 .TS
565 l l
566 _ _
567 l l.
568 \fBFunction\fP  \fBDescription\fP
569 tgetent look up termcap entry for given \fIname\fP
570 tgetflag        get boolean entry for given \fIid\fP
571 tgetnum get numeric entry for given \fIid\fP
572 tgetstr get string entry for given \fIid\fP
573 tgoto   apply parameters to given capability
574 tputs   T{
575 apply padding to capability, calling a function to put characters
576 T}
577 .TE
578 .PP
579 Early terminfo programs obtained capability values from the
580 \fBTERMINAL\fP structure initialized by \fBsetupterm\fP.
581 .PP
582 SVr3 extended terminfo by adding functions to retrieve capability values
583 (like the termcap interface),
584 and reusing tgoto and tputs:
585 .PP
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)