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