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