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