Update ncurses to version 5.4.
[dragonfly.git] / lib / libncurses / man / curs_terminfo.3
1 .\"***************************************************************************
2 .\" Copyright (c) 1999-2002,2003 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_terminfo.3x,v 1.18 2003/12/27 18:48:59 tom Exp $
30 .\" $DragonFly: src/lib/libncurses/man/curs_terminfo.3,v 1.1 2005/03/12 19:13:54 eirikn Exp $
31 .TH curs_terminfo 3X ""
32 .ds n 5
33 .SH NAME
34 \fBdel_curterm\fR,
35 \fBmvcur\fR,
36 \fBputp\fR,
37 \fBrestartterm\fR,
38 \fBset_curterm\fR,
39 \fBsetterm\fR,
40 \fBsetupterm\fR,
41 \fBtigetflag\fR,
42 \fBtigetnum\fR,
43 \fBtigetstr\fR,
44 \fBtparm\fR,
45 \fBtputs\fR,
46 \fBvid_attr\fR,
47 \fBvid_puts\fR,
48 \fBvidattr\fR,
49 \fBvidputs\fR - \fBcurses\fR interfaces to terminfo database
50 .SH SYNOPSIS
51 .nf
52 \fB#include <curses.h>\fR
53 .br
54 \fB#include <term.h>\fR
55 .PP
56 \fBint setupterm(char *\fR\fIterm\fR\fB, int \fR\fIfildes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
57 .br
58 \fBint setterm(char *\fR\fIterm\fR\fB);\fR
59 .br
60 \fBTERMINAL *set_curterm(TERMINAL *\fR\fInterm\fR\fB);\fR
61 .br
62 \fBint del_curterm(TERMINAL *\fR\fIoterm\fR\fB);\fR
63 .br
64 \fBint restartterm(const char *\fR\fIterm\fR\fB, int \fR\fIfildes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
65 .br
66 \fBchar *tparm(char *\fR\fIstr\fR\fB, ...);\fR
67 .br
68 \fBint tputs(const char *\fR\fIstr\fR\fB, int \fR\fIaffcnt\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
69 .br
70 \fBint putp(const char *\fR\fIstr\fR\fB);\fR
71 .br
72 \fBint vidputs(chtype \fR\fIattrs\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
73 .br
74 \fBint vidattr(chtype \fR\fIattrs\fR\fB);\fR
75 .br
76 \fBint vid_puts(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB, int (*\fR\fIputc\fR\fB)(char));\fR
77 .br
78 \fBint vid_attr(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB);\fR
79 .br
80 \fBint mvcur(int \fR\fIoldrow\fR\fB, int \fR\fIoldcol\fR\fB, int \fR\fInewrow\fR, int \fR\fInewcol\fR\fB);\fR
81 .br
82 \fBint tigetflag(char *\fR\fIcapname\fR\fB);\fR
83 .br
84 \fBint tigetnum(char *\fR\fIcapname\fR\fB);\fR
85 .br
86 \fBchar *tigetstr(char *\fR\fIcapname\fR\fB);\fR
87 .br
88 .fi
89 .SH DESCRIPTION
90 These low-level routines must be called by programs that have to deal
91 directly with the \fBterminfo\fR database to handle certain terminal
92 capabilities, such as programming function keys.  For all other
93 functionality, \fBcurses\fR routines are more suitable and their use is
94 recommended.
95 .PP
96 Initially, \fBsetupterm\fR should be called.  Note that
97 \fBsetupterm\fR is automatically called by \fBinitscr\fR and
98 \fBnewterm\fR.  This defines the set of terminal-dependent variables
99 [listed in \fBterminfo\fR(\*n)].  The \fBterminfo\fR variables
100 \fBlines\fR and \fBcolumns\fR are initialized by \fBsetupterm\fR as
101 follows: If \fBuse_env(FALSE)\fR has been called, values for
102 \fBlines\fR and \fBcolumns\fR specified in \fBterminfo\fR are used.
103 Otherwise, if the environment variables \fBLINES\fR and \fBCOLUMNS\fR
104 exist, their values are used.  If these environment variables do not
105 exist and the program is running in a window, the current window size
106 is used.  Otherwise, if the environment variables do not exist, the
107 values for \fBlines\fR and \fBcolumns\fR specified in the
108 \fBterminfo\fR database are used.
109 .PP
110 The header files \fBcurses.h\fR and \fBterm.h\fR should be included (in this
111 order) to get the definitions for these strings, numbers, and flags.
112 Parameterized strings should be passed through \fBtparm\fR to instantiate them. 
113 All \fBterminfo\fR strings [including the output of \fBtparm\fR] should be printed
114 with \fBtputs\fR or \fBputp\fR.  Call the \fBreset_shell_mode\fR to restore the
115 tty modes before exiting [see \fBcurs_kernel\fR(3X)].  Programs which use
116 cursor addressing should output \fBenter_ca_mode\fR upon startup and should
117 output \fBexit_ca_mode\fR before exiting.  Programs desiring shell escapes
118 should call
119 .PP
120 \fBreset_shell_mode\fR and output \fBexit_ca_mode\fR before the shell
121 is called and should output \fBenter_ca_mode\fR and call
122 \fBreset_prog_mode\fR after returning from the shell.
123 .PP
124 The \fBsetupterm\fR routine reads in the \fBterminfo\fR database,
125 initializing the \fBterminfo\fR structures, but does not set up the
126 output virtualization structures used by \fBcurses\fR.  The terminal
127 type is the character string \fIterm\fR; if \fIterm\fR is null, the
128 environment variable \fBTERM\fR is used.
129 All output is to file descriptor \fBfildes\fR which is initialized for output.
130 If \fIerrret\fR is not null,
131 then \fBsetupterm\fR returns \fBOK\fR or
132 \fBERR\fR and stores a status value in the integer pointed to by
133 \fIerrret\fR.
134 A return value of \fBOK\fR combined with status of \fB1\fR in \fIerrret\fR
135 is normal.
136 If \fBERR\fR is returned, examine \fIerrret\fR:
137 .RS
138 .TP 5
139 .B 1
140 means that the terminal is hardcopy, cannot be used for curses applications.
141 .TP 5
142 .B 0
143 means that the terminal could not be found,
144 or that it is a generic type,
145 having too little information for curses applications to run.
146 .TP 5
147 .B -1
148 means that the \fBterminfo\fR database could not be found.
149 .RE
150 .PP
151 If \fIerrret\fR is
152 null, \fBsetupterm\fR prints an error message upon finding an error
153 and exits.  Thus, the simplest call is:
154
155       \fBsetupterm((char *)0, 1, (int *)0);\fR,
156
157 which uses all the defaults and sends the output to \fBstdout\fR.
158 .PP
159 The \fBsetterm\fR routine is being replaced by \fBsetupterm\fR.  The call:
160
161       \fBsetupterm(\fR\fIterm\fR\fB, 1, (int *)0)\fR
162
163 provides the same functionality as \fBsetterm(\fR\fIterm\fR\fB)\fR.
164 The \fBsetterm\fR routine is included here for BSD compatibility, and
165 is not recommended for new programs.
166 .PP
167 The \fBset_curterm\fR routine sets the variable \fBcur_term\fR to
168 \fInterm\fR, and makes all of the \fBterminfo\fR boolean, numeric, and
169 string variables use the values from \fInterm\fR.  It returns the old value
170 of \fBcur_term\fR.
171 .PP
172 The \fBdel_curterm\fR routine frees the space pointed to by
173 \fIoterm\fR and makes it available for further use.  If \fIoterm\fR is
174 the same as \fBcur_term\fR, references to any of the \fBterminfo\fR
175 boolean, numeric, and string variables thereafter may refer to invalid
176 memory locations until another \fBsetupterm\fR has been called.
177 .PP
178 The \fBrestartterm\fR routine is similar to \fBsetupterm\fR and \fBinitscr\fR,
179 except that it is called after restoring memory to a previous state (for
180 example, when reloading a game saved as a core image dump).  It assumes that
181 the windows and the input and output options are the same as when memory was
182 saved, but the terminal type and baud rate may be different.  Accordingly,
183 it saves various tty state bits, does a setupterm, and then restores the bits.
184 .PP
185 The \fBtparm\fR routine instantiates the string \fIstr\fR with
186 parameters \fIpi\fR.  A pointer is returned to the result of \fIstr\fR
187 with the parameters applied.
188 .PP
189 The \fBtputs\fR routine applies padding information to the string
190 \fIstr\fR and outputs it.  The \fIstr\fR must be a terminfo string
191 variable or the return value from \fBtparm\fR, \fBtgetstr\fR, or
192 \fBtgoto\fR.  \fIaffcnt\fR is the number of lines affected, or 1 if
193 not applicable.  \fIputc\fR is a \fBputchar\fR-like routine to which
194 the characters are passed, one at a time.
195 .PP
196 The \fBputp\fR routine calls \fBtputs(\fR\fIstr\fR\fB, 1, putchar)\fR.
197 Note that the output of \fBputp\fR always goes to \fBstdout\fR, not to
198 the \fIfildes\fR specified in \fBsetupterm\fR.
199 .PP
200 The \fBvidputs\fR routine displays the string on the terminal in the
201 video attribute mode \fIattrs\fR, which is any combination of the
202 attributes listed in \fBcurses\fR(3X).  The characters are passed to
203 the \fBputchar\fR-like routine \fIputc\fR.
204 .PP
205 The \fBvidattr\fR routine is like the \fBvidputs\fR routine, except
206 that it outputs through \fBputchar\fR.
207 .PP
208 The \fBvid_attr\fR and \fBvid_puts\fR routines correspond to vidattr and vidputs,
209 respectively.
210 They use a set of arguments for representing the video attributes plus color,
211 i.e.,
212 one of type attr_t for the attributes and one of short for
213 the color_pair number.
214 The \fBvid_attr\fR and \fBvid_puts\fR routines
215 are designed to use the attribute constants with the \fIWA_\fR prefix.
216 The opts argument is reserved for future use.
217 Currently, applications must provide a null pointer for that argument.
218 .PP
219 The \fBmvcur\fR routine provides low-level cursor motion.  It takes
220 effect immediately (rather than at the next refresh).
221 .PP
222 The \fBtigetflag\fR, \fBtigetnum\fR and \fBtigetstr\fR routines return
223 the value of the capability corresponding to the \fBterminfo\fR
224 \fIcapname\fR passed to them, such as \fBxenl\fR.
225 .PP
226 The \fBtigetflag\fR routine returns the value \fB-1\fR if
227 \fIcapname\fR is not a boolean capability,
228 or \fB0\fR if it is canceled or absent from the terminal description.
229 .PP
230 The \fBtigetnum\fR routine returns the value \fB-2\fR if
231 \fIcapname\fR is not a numeric capability,
232 or \fB-1\fR if it is canceled or absent from the terminal description.
233 .PP
234 The \fBtigetstr\fR routine returns the value \fB(char *)-1\fR
235 if \fIcapname\fR is not a string capability,
236 or \fB0\fR if it is canceled or absent from the terminal description.
237 .PP
238 The \fIcapname\fR for each capability is given in the table column entitled
239 \fIcapname\fR code in the capabilities section of \fBterminfo\fR(\*n).
240
241 \fBchar *boolnames\fR, \fB*boolcodes\fR, \fB*boolfnames\fR
242
243 \fBchar *numnames\fR, \fB*numcodes\fR, \fB*numfnames\fR
244
245 \fBchar *strnames\fR, \fB*strcodes\fR, \fB*strfnames\fR
246
247 These null-terminated arrays contain the \fIcapnames\fR, the
248 \fBtermcap\fR codes, and the full C names, for each of the
249 \fBterminfo\fR variables.
250 .SH RETURN VALUE
251 Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
252 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
253 completion, unless otherwise noted in the preceding routine descriptions.
254 .PP
255 Routines that return pointers always return \fBNULL\fR on error.
256 .SH NOTES
257 The \fBsetupterm\fR routine should be used in place of \fBsetterm\fR.
258 It may be useful when you want to test for terminal capabilities without
259 committing to the allocation of storage involved in \fBinitscr\fR.
260 .PP
261 Note that \fBvidattr\fR and \fBvidputs\fR may be macros.
262 .SH PORTABILITY
263 The function \fBsetterm\fR is not described in the XSI Curses standard and must
264 be considered non-portable.  All other functions are as described in the XSI
265 curses standard.
266 .PP
267 In System V Release 4, \fBset_curterm\fR has an \fBint\fR return type and
268 returns \fBOK\fR or \fBERR\fR.  We have chosen to implement the XSI Curses
269 semantics.
270 .PP
271 In System V Release 4, the third argument of \fBtputs\fR has the type
272 \fBint (*putc)(char)\fR.
273 .PP
274 The XSI Curses standard prototypes \fBtparm\fR with a fixed number of parameters,
275 rather than a variable argument list.
276 This implementation uses a variable argument list.
277 Portable applications should provide 9 parameters after the format;
278 zeroes are fine for this purpose.
279 .PP
280 XSI notes that after calling \fBmvcur\fR, the curses state may not match the
281 actual terminal state, and that an application should touch and refresh
282 the window before resuming normal curses calls.
283 Both ncurses and System V Release 4 curses implement \fBmvcur\fR using
284 the SCREEN data allocated in either \fBinitscr\fR or \fBnewterm\fR.
285 So though it is documented as a terminfo function,
286 \fBmvcur\fR is really a curses function which is not well specified.
287 .SH SEE ALSO
288 \fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_kernel\fR(3X), \fBcurs_termcap\fR(3X),
289 \fBputc\fR(3S), \fBterminfo\fR(\*n)
290 .\"#
291 .\"# The following sets edit modes for GNU EMACS
292 .\"# Local Variables:
293 .\"# mode:nroff
294 .\"# fill-column:79
295 .\"# End: