]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_terminfo.3x
ncurses 5.9 - patch 20130713
[ncurses.git] / man / curs_terminfo.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1999-2011,2013 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.38 2013/07/13 23:12:13 tom Exp $
30 .TH curs_terminfo 3X ""
31 .de bP
32 .IP \(bu 4
33 ..
34 .ds n 5
35 .na
36 .hy 0
37 .SH NAME
38 \fBdel_curterm\fR,
39 \fBmvcur\fR,
40 \fBputp\fR,
41 \fBrestartterm\fR,
42 \fBset_curterm\fR,
43 \fBsetterm\fR,
44 \fBsetupterm\fR,
45 \fBtigetflag\fR,
46 \fBtigetnum\fR,
47 \fBtigetstr\fR,
48 \fBtiparm\fR,
49 \fBtparm\fR,
50 \fBtputs\fR,
51 \fBvid_attr\fR,
52 \fBvid_puts\fR,
53 \fBvidattr\fR,
54 \fBvidputs\fR \- \fBcurses\fR interfaces to terminfo database
55 .ad
56 .hy
57 .SH SYNOPSIS
58 .nf
59 \fB#include <curses.h>\fR
60 .br
61 \fB#include <term.h>\fR
62 .PP
63 \fBint setupterm(char *\fR\fIterm\fR\fB, int \fR\fIfildes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
64 .br
65 \fBint setterm(char *\fR\fIterm\fR\fB);\fR
66 .br
67 \fBTERMINAL *set_curterm(TERMINAL *\fR\fInterm\fR\fB);\fR
68 .br
69 \fBint del_curterm(TERMINAL *\fR\fIoterm\fR\fB);\fR
70 .br
71 \fBint restartterm(char *\fR\fIterm\fR\fB, int \fR\fIfildes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
72 .br
73 \fBchar *tparm(char *\fR\fIstr\fR\fB, ...);\fR
74 .br
75 \fBint tputs(const char *\fR\fIstr\fR\fB, int \fR\fIaffcnt\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
76 .br
77 \fBint putp(const char *\fR\fIstr\fR\fB);\fR
78 .br
79 \fBint vidputs(chtype \fR\fIattrs\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
80 .br
81 \fBint vidattr(chtype \fR\fIattrs\fR\fB);\fR
82 .br
83 \fBint vid_puts(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
84 .br
85 \fBint vid_attr(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB);\fR
86 .br
87 \fBint mvcur(int \fR\fIoldrow\fR\fB, int \fR\fIoldcol\fR\fB, int \fR\fInewrow\fR, int \fR\fInewcol\fR\fB);\fR
88 .br
89 \fBint tigetflag(char *\fR\fIcapname\fR\fB);\fR
90 .br
91 \fBint tigetnum(char *\fR\fIcapname\fR\fB);\fR
92 .br
93 \fBchar *tigetstr(char *\fR\fIcapname\fR\fB);\fR
94 .br
95 \fBchar *tiparm(const char *\fR\fIstr\fR\fB, ...);\fR
96 .br
97 .fi
98 .SH DESCRIPTION
99 These low-level routines must be called by programs that have to deal
100 directly with the \fBterminfo\fR database to handle certain terminal
101 capabilities, such as programming function keys.  For all other
102 functionality, \fBcurses\fR routines are more suitable and their use is
103 recommended.
104 .PP
105 Initially, \fBsetupterm\fR should be called.  Note that
106 \fBsetupterm\fR is automatically called by \fBinitscr\fR and
107 \fBnewterm\fR.  This defines the set of terminal-dependent variables
108 [listed in \fBterminfo\fR(\*n)].
109 The \fBterminfo\fR variables
110 \fBlines\fR and \fBcolumns\fR are initialized by \fBsetupterm\fR as
111 follows:
112 .RS
113 .PP
114 If \fBuse_env(FALSE)\fR has been called, values for
115 \fBlines\fR and \fBcolumns\fR specified in \fBterminfo\fR are used.
116 .PP
117 Otherwise, if the environment variables \fBLINES\fR and \fBCOLUMNS\fR
118 exist, their values are used.  If these environment variables do not
119 exist and the program is running in a window, the current window size
120 is used.  Otherwise, if the environment variables do not exist, the
121 values for \fBlines\fR and \fBcolumns\fR specified in the
122 \fBterminfo\fR database are used.
123 .RE
124 .PP
125 The header files \fBcurses.h\fR and \fBterm.h\fR should be included (in this
126 order) to get the definitions for these strings, numbers, and flags.
127 Parameterized strings should be passed through \fBtparm\fR to instantiate them. 
128 All \fBterminfo\fR strings [including the output of \fBtparm\fR] should be printed
129 with \fBtputs\fR or \fBputp\fR.  Call the \fBreset_shell_mode\fR to restore the
130 tty modes before exiting [see \fBcurs_kernel\fR(3X)].  Programs which use
131 cursor addressing should output \fBenter_ca_mode\fR upon startup and should
132 output \fBexit_ca_mode\fR before exiting.  Programs desiring shell escapes
133 should call
134 .PP
135 \fBreset_shell_mode\fR and output \fBexit_ca_mode\fR before the shell
136 is called and should output \fBenter_ca_mode\fR and call
137 \fBreset_prog_mode\fR after returning from the shell.
138 .PP
139 The \fBsetupterm\fR routine reads in the \fBterminfo\fR database,
140 initializing the \fBterminfo\fR structures, but does not set up the
141 output virtualization structures used by \fBcurses\fR.  The terminal
142 type is the character string \fIterm\fR; if \fIterm\fR is null, the
143 environment variable \fBTERM\fR is used.
144 All output is to file descriptor \fBfildes\fR which is initialized for output.
145 If \fIerrret\fR is not null,
146 then \fBsetupterm\fR returns \fBOK\fR or
147 \fBERR\fR and stores a status value in the integer pointed to by
148 \fIerrret\fR.
149 A return value of \fBOK\fR combined with status of \fB1\fR in \fIerrret\fR
150 is normal.
151 If \fBERR\fR is returned, examine \fIerrret\fR:
152 .RS
153 .TP 5
154 .B 1
155 means that the terminal is hardcopy, cannot be used for curses applications.
156 .IP
157 \fBsetupterm\fP determines if the entry is a hardcopy type by
158 checking the \fIhc\fP (\fIhardcopy\fP) capability.
159 .TP 5
160 .B 0
161 means that the terminal could not be found,
162 or that it is a generic type,
163 having too little information for curses applications to run.
164 .IP
165 \fBsetupterm\fP determines if the entry is a generic type by
166 checking the \fIgn\fP (\fIgeneric\fP) capability.
167 .TP 5
168 .B \-1
169 means that the \fBterminfo\fR database could not be found.
170 .RE
171 .PP
172 If \fIerrret\fR is
173 null, \fBsetupterm\fR prints an error message upon finding an error
174 and exits.  Thus, the simplest call is:
175 .sp
176       \fBsetupterm((char *)0, 1, (int *)0);\fR,
177 .sp
178 which uses all the defaults and sends the output to \fBstdout\fR.
179 .PP
180 The \fBsetterm\fR routine is being replaced by \fBsetupterm\fR.  The call:
181 .sp
182       \fBsetupterm(\fR\fIterm\fR\fB, 1, (int *)0)\fR
183 .sp
184 provides the same functionality as \fBsetterm(\fR\fIterm\fR\fB)\fR.
185 The \fBsetterm\fR routine is included here for BSD compatibility, and
186 is not recommended for new programs.
187 .PP
188 The \fBset_curterm\fR routine sets the variable \fBcur_term\fR to
189 \fInterm\fR, and makes all of the \fBterminfo\fR boolean, numeric, and
190 string variables use the values from \fInterm\fR.  It returns the old value
191 of \fBcur_term\fR.
192 .PP
193 The \fBdel_curterm\fR routine frees the space pointed to by
194 \fIoterm\fR and makes it available for further use.  If \fIoterm\fR is
195 the same as \fBcur_term\fR, references to any of the \fBterminfo\fR
196 boolean, numeric, and string variables thereafter may refer to invalid
197 memory locations until another \fBsetupterm\fR has been called.
198 .PP
199 The \fBrestartterm\fR routine is similar to \fBsetupterm\fR and \fBinitscr\fR,
200 except that it is called after restoring memory to a previous state (for
201 example, when reloading a game saved as a core image dump).  It assumes that
202 the windows and the input and output options are the same as when memory was
203 saved, but the terminal type and baud rate may be different.  Accordingly,
204 it saves various tty state bits, calls \fBsetupterm\fP,
205 and then restores the bits.
206 .PP
207 The \fBtparm\fR routine instantiates the string \fIstr\fR with
208 parameters \fIpi\fR.  A pointer is returned to the result of \fIstr\fR
209 with the parameters applied.
210 .PP
211 \fBtiparm\fP is a newer form of \fBtparm\fP which uses \fI<stdarg.h>\fP
212 rather than a fixed-parameter list.
213 Its numeric parameters are integers (int) rather than longs.
214 .PP
215 The \fBtputs\fR routine applies padding information to the string
216 \fIstr\fR and outputs it.  The \fIstr\fR must be a terminfo string
217 variable or the return value from \fBtparm\fR, \fBtgetstr\fR, or
218 \fBtgoto\fR.  \fIaffcnt\fR is the number of lines affected, or 1 if
219 not applicable.  \fIputc\fR is a \fBputchar\fR-like routine to which
220 the characters are passed, one at a time.
221 .PP
222 The \fBputp\fR routine calls \fBtputs(\fR\fIstr\fR\fB, 1, putchar)\fR.
223 Note that the output of \fBputp\fR always goes to \fBstdout\fR, not to
224 the \fIfildes\fR specified in \fBsetupterm\fR.
225 .PP
226 The \fBvidputs\fR routine displays the string on the terminal in the
227 video attribute mode \fIattrs\fR, which is any combination of the
228 attributes listed in \fBcurses\fR(3X).  The characters are passed to
229 the \fBputchar\fR-like routine \fIputc\fR.
230 .PP
231 The \fBvidattr\fR routine is like the \fBvidputs\fR routine, except
232 that it outputs through \fBputchar\fR.
233 .PP
234 The \fBvid_attr\fR and \fBvid_puts\fR routines correspond to vidattr and vidputs,
235 respectively.
236 They use a set of arguments for representing the video attributes plus color,
237 i.e.,
238 one of type attr_t for the attributes and one of short for
239 the color_pair number.
240 The \fBvid_attr\fR and \fBvid_puts\fR routines
241 are designed to use the attribute constants with the \fIWA_\fR prefix.
242 The opts argument is reserved for future use.
243 Currently, applications must provide a null pointer for that argument.
244 .PP
245 The \fBmvcur\fR routine provides low-level cursor motion.  It takes
246 effect immediately (rather than at the next refresh).
247 .PP
248 The \fBtigetflag\fR, \fBtigetnum\fR and \fBtigetstr\fR routines return
249 the value of the capability corresponding to the \fBterminfo\fR
250 \fIcapname\fR passed to them, such as \fBxenl\fR.
251 .PP
252 The \fBtigetflag\fR routine returns the value \fB\-1\fR if
253 \fIcapname\fR is not a boolean capability,
254 or \fB0\fR if it is canceled or absent from the terminal description.
255 .PP
256 The \fBtigetnum\fR routine returns the value \fB\-2\fR if
257 \fIcapname\fR is not a numeric capability,
258 or \fB\-1\fR if it is canceled or absent from the terminal description.
259 .PP
260 The \fBtigetstr\fR routine returns the value \fB(char *)\-1\fR
261 if \fIcapname\fR is not a string capability,
262 or \fB0\fR if it is canceled or absent from the terminal description.
263 .PP
264 The \fIcapname\fR for each capability is given in the table column entitled
265 \fIcapname\fR code in the capabilities section of \fBterminfo\fR(\*n).
266 .sp
267 .RS
268 \fBchar *boolnames[]\fR, \fB*boolcodes[]\fR, \fB*boolfnames[]\fR
269 .sp
270 \fBchar *numnames[]\fR, \fB*numcodes[]\fR, \fB*numfnames[]\fR
271 .sp
272 \fBchar *strnames[]\fR, \fB*strcodes[]\fR, \fB*strfnames[]\fR
273 .RE
274 .PP
275 These null-terminated arrays contain the \fIcapnames\fR, the
276 \fBtermcap\fR codes, and the full C names, for each of the
277 \fBterminfo\fR variables.
278 .SH RETURN VALUE
279 Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
280 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
281 completion, unless otherwise noted in the preceding routine descriptions.
282 .PP
283 Routines that return pointers always return \fBNULL\fR on error.
284 .PP
285 X/Open defines no error conditions.
286 In this implementation
287 .RS 5
288 .TP 5
289 \fBdel_curterm\fP
290 returns an error
291 if its terminal parameter is null.
292 .TP 5
293 \fBputp\fP
294 calls \fBtputs\fP, returning the same error-codes.
295 .TP 5
296 \fBrestartterm\fP
297 returns an error
298 if the associated call to \fBsetupterm\fP returns an error.
299 .TP 5
300 \fBsetupterm\fP
301 returns an error
302 if it cannot allocate enough memory, or
303 create the initial windows (stdscr, curscr, newscr).
304 Other error conditions are documented above.
305 .TP 5
306 \fBtputs\fP
307 returns an error if the string parameter is null.
308 It does not detect I/O errors:
309 X/Open states that \fBtputs\fP ignores the return value
310 of the output function \fIputc\fP.
311 .RE
312 .SH NOTES
313 The \fBsetupterm\fR routine should be used in place of \fBsetterm\fR.
314 It may be useful when you want to test for terminal capabilities without
315 committing to the allocation of storage involved in \fBinitscr\fR.
316 .PP
317 Note that \fBvidattr\fR and \fBvidputs\fR may be macros.
318 .SH PORTABILITY
319 The function \fBsetterm\fR is not described by X/Open and must
320 be considered non-portable.  All other functions are as described by X/Open.
321 .PP
322 \fBsetupterm\fP copies the terminal name to the array \fBttytype\fP.
323 This is not part of X/Open Curses, but is assumed by some applications.
324 .PP
325 If configured to use the terminal-driver,
326 e.g., for the MinGW port,
327 .bP
328 \fBsetupterm\fP interprets a missing/empty TERM variable as the
329 special value ``unknown''.
330 .bP
331 \fBsetupterm\fP allows explicit use of the
332 the windows console driver by checking if $TERM is set to
333 ``#win32con'' or an abbreviation of that string.
334 .PP
335 Older versions of \fBncurses\fP assumed that the file descriptor passed to
336 \fBsetupterm\fP from \fBinitscr\fP or \fBnewterm\fP uses buffered I/O,
337 and would write to the corresponding stream.
338 In addition to the limitation that the terminal was left in block-buffered
339 mode on exit (like SystemV curses),
340 it was problematic because \fBncurses\fP
341 did not allow a reliable way to cleanup on receiving SIGTSTP.
342 The current version uses output buffers managed directly by \fBncurses\fP.
343 Some of the low-level functions described in this manual page write
344 to the standard output.
345 They are not signal-safe.
346 The high-level functions in \fBncurses\fP use
347 alternate versions of these functions
348 using the more reliable buffering scheme.
349 .PP
350 In System V Release 4, \fBset_curterm\fR has an \fBint\fR return type and
351 returns \fBOK\fR or \fBERR\fR.  We have chosen to implement the X/Open Curses
352 semantics.
353 .PP
354 In System V Release 4, the third argument of \fBtputs\fR has the type
355 \fBint (*putc)(char)\fR.
356 .PP
357 At least one implementation of X/Open Curses (Solaris) returns a value
358 other than OK/ERR from \fBtputs\fP.
359 That returns the length of the string, and does no error-checking.
360 .PP
361 X/Open Curses prototypes \fBtparm\fR with a fixed number of parameters,
362 rather than a variable argument list.
363 This implementation uses a variable argument list, but can be
364 configured to use the fixed-parameter list.
365 Portable applications should provide 9 parameters after the format;
366 zeroes are fine for this purpose.
367 .PP
368 In response to comments by Thomas E. Dickey,
369 X/Open Curses Issue 7 proposed the \fBtiparam\fP function in mid-2009.
370 .PP
371 X/Open notes that after calling \fBmvcur\fR, the curses state may not match the
372 actual terminal state, and that an application should touch and refresh
373 the window before resuming normal curses calls.
374 Both \fBncurses\fP and System V Release 4 curses implement \fBmvcur\fR using
375 the SCREEN data allocated in either \fBinitscr\fR or \fBnewterm\fR.
376 So though it is documented as a terminfo function,
377 \fBmvcur\fR is really a curses function which is not well specified.
378 .PP
379 X/Open states that the old location must be given for \fBmvcur\fP.
380 This implementation allows the caller to use \-1's for the old ordinates.
381 In that case, the old location is unknown.
382 .PP
383 Extended terminal capability names, e.g., as defined by \fB@TIC@\ \-x\fP,
384 are not stored in the arrays described in this section.
385 .SH SEE ALSO
386 \fBcurses\fR(3X),
387 \fBcurs_initscr\fR(3X),
388 \fBcurs_kernel\fR(3X),
389 \fBcurs_termcap\fR(3X),
390 \fBcurs_variables\fR(3X),
391 \fBterm_variables\fR(3X),
392 \fBputc\fR(3),
393 \fBterminfo\fR(\*n)