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