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