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