blob: 4412a6a69c354b29f8faf30c8d6d612b340a0ab1 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
2.\" Copyright (c) 1999-2007,2008 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.30 2008/08/16 20:53:27 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
93These low-level routines must be called by programs that have to deal
94directly with the \fBterminfo\fR database to handle certain terminal
95capabilities, such as programming function keys. For all other
96functionality, \fBcurses\fR routines are more suitable and their use is
97recommended.
98.PP
99Initially, \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)].
103The \fBterminfo\fR variables
104\fBlines\fR and \fBcolumns\fR are initialized by \fBsetupterm\fR as
105follows:
106.RS
107.PP
108If \fBuse_env(FALSE)\fR has been called, values for
109\fBlines\fR and \fBcolumns\fR specified in \fBterminfo\fR are used.
110.PP
111Otherwise, if the environment variables \fBLINES\fR and \fBCOLUMNS\fR
112exist, their values are used. If these environment variables do not
113exist and the program is running in a window, the current window size
114is used. Otherwise, if the environment variables do not exist, the
115values for \fBlines\fR and \fBcolumns\fR specified in the
116\fBterminfo\fR database are used.
117.RE
118.PP
119The header files \fBcurses.h\fR and \fBterm.h\fR should be included (in this
120order) to get the definitions for these strings, numbers, and flags.
121Parameterized strings should be passed through \fBtparm\fR to instantiate them.
122All \fBterminfo\fR strings [including the output of \fBtparm\fR] should be printed
123with \fBtputs\fR or \fBputp\fR. Call the \fBreset_shell_mode\fR to restore the
124tty modes before exiting [see \fBcurs_kernel\fR(3X)]. Programs which use
125cursor addressing should output \fBenter_ca_mode\fR upon startup and should
126output \fBexit_ca_mode\fR before exiting. Programs desiring shell escapes
127should call
128.PP
129\fBreset_shell_mode\fR and output \fBexit_ca_mode\fR before the shell
130is called and should output \fBenter_ca_mode\fR and call
131\fBreset_prog_mode\fR after returning from the shell.
132.PP
133The \fBsetupterm\fR routine reads in the \fBterminfo\fR database,
134initializing the \fBterminfo\fR structures, but does not set up the
135output virtualization structures used by \fBcurses\fR. The terminal
136type is the character string \fIterm\fR; if \fIterm\fR is null, the
137environment variable \fBTERM\fR is used.
138All output is to file descriptor \fBfildes\fR which is initialized for output.
139If \fIerrret\fR is not null,
140then \fBsetupterm\fR returns \fBOK\fR or
141\fBERR\fR and stores a status value in the integer pointed to by
142\fIerrret\fR.
143A return value of \fBOK\fR combined with status of \fB1\fR in \fIerrret\fR
144is normal.
145If \fBERR\fR is returned, examine \fIerrret\fR:
146.RS
147.TP 5
148.B 1
149means that the terminal is hardcopy, cannot be used for curses applications.
150.TP 5
151.B 0
152means that the terminal could not be found,
153or that it is a generic type,
154having too little information for curses applications to run.
155.TP 5
156.B -1
157means that the \fBterminfo\fR database could not be found.
158.RE
159.PP
160If \fIerrret\fR is
161null, \fBsetupterm\fR prints an error message upon finding an error
162and exits. Thus, the simplest call is:
163.sp
164 \fBsetupterm((char *)0, 1, (int *)0);\fR,
165.sp
166which uses all the defaults and sends the output to \fBstdout\fR.
167.PP
168The \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
172provides the same functionality as \fBsetterm(\fR\fIterm\fR\fB)\fR.
173The \fBsetterm\fR routine is included here for BSD compatibility, and
174is not recommended for new programs.
175.PP
176The \fBset_curterm\fR routine sets the variable \fBcur_term\fR to
177\fInterm\fR, and makes all of the \fBterminfo\fR boolean, numeric, and
178string variables use the values from \fInterm\fR. It returns the old value
179of \fBcur_term\fR.
180.PP
181The \fBdel_curterm\fR routine frees the space pointed to by
182\fIoterm\fR and makes it available for further use. If \fIoterm\fR is
183the same as \fBcur_term\fR, references to any of the \fBterminfo\fR
184boolean, numeric, and string variables thereafter may refer to invalid
185memory locations until another \fBsetupterm\fR has been called.
186.PP
187The \fBrestartterm\fR routine is similar to \fBsetupterm\fR and \fBinitscr\fR,
188except that it is called after restoring memory to a previous state (for
189example, when reloading a game saved as a core image dump). It assumes that
190the windows and the input and output options are the same as when memory was
191saved, but the terminal type and baud rate may be different. Accordingly,
192it saves various tty state bits, calls \fBsetupterm\fP,
193and then restores the bits.
194.PP
195The \fBtparm\fR routine instantiates the string \fIstr\fR with
196parameters \fIpi\fR. A pointer is returned to the result of \fIstr\fR
197with the parameters applied.
198.PP
199The \fBtputs\fR routine applies padding information to the string
200\fIstr\fR and outputs it. The \fIstr\fR must be a terminfo string
201variable or the return value from \fBtparm\fR, \fBtgetstr\fR, or
202\fBtgoto\fR. \fIaffcnt\fR is the number of lines affected, or 1 if
203not applicable. \fIputc\fR is a \fBputchar\fR-like routine to which
204the characters are passed, one at a time.
205.PP
206The \fBputp\fR routine calls \fBtputs(\fR\fIstr\fR\fB, 1, putchar)\fR.
207Note that the output of \fBputp\fR always goes to \fBstdout\fR, not to
208the \fIfildes\fR specified in \fBsetupterm\fR.
209.PP
210The \fBvidputs\fR routine displays the string on the terminal in the
211video attribute mode \fIattrs\fR, which is any combination of the
212attributes listed in \fBcurses\fR(3X). The characters are passed to
213the \fBputchar\fR-like routine \fIputc\fR.
214.PP
215The \fBvidattr\fR routine is like the \fBvidputs\fR routine, except
216that it outputs through \fBputchar\fR.
217.PP
218The \fBvid_attr\fR and \fBvid_puts\fR routines correspond to vidattr and vidputs,
219respectively.
220They use a set of arguments for representing the video attributes plus color,
221i.e.,
222one of type attr_t for the attributes and one of short for
223the color_pair number.
224The \fBvid_attr\fR and \fBvid_puts\fR routines
225are designed to use the attribute constants with the \fIWA_\fR prefix.
226The opts argument is reserved for future use.
227Currently, applications must provide a null pointer for that argument.
228.PP
229The \fBmvcur\fR routine provides low-level cursor motion. It takes
230effect immediately (rather than at the next refresh).
231.PP
232The \fBtigetflag\fR, \fBtigetnum\fR and \fBtigetstr\fR routines return
233the value of the capability corresponding to the \fBterminfo\fR
234\fIcapname\fR passed to them, such as \fBxenl\fR.
235.PP
236The \fBtigetflag\fR routine returns the value \fB-1\fR if
237\fIcapname\fR is not a boolean capability,
238or \fB0\fR if it is canceled or absent from the terminal description.
239.PP
240The \fBtigetnum\fR routine returns the value \fB-2\fR if
241\fIcapname\fR is not a numeric capability,
242or \fB-1\fR if it is canceled or absent from the terminal description.
243.PP
244The \fBtigetstr\fR routine returns the value \fB(char *)-1\fR
245if \fIcapname\fR is not a string capability,
246or \fB0\fR if it is canceled or absent from the terminal description.
247.PP
248The \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
259These 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
263Routines 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
265completion, unless otherwise noted in the preceding routine descriptions.
266.PP
267Routines that return pointers always return \fBNULL\fR on error.
268.PP
269X/Open defines no error conditions.
270In this implementation
271.RS
272.TP 5
273\fBdel_curterm\fP
274returns an error
275if its terminal parameter is null.
276.TP 5
277\fBputp\fP
278calls \fBtputs\fP, returning the same error-codes.
279.TP 5
280\fBrestartterm\fP
281returns an error
282if the associated call to \fBsetupterm\fP returns an error.
283.TP 5
284\fBsetupterm\fP
285returns an error
286if it cannot allocate enough memory, or
287create the initial windows (stdscr, curscr, newscr).
288Other error conditions are documented above.
289.TP 5
290\fBtputs\fP
291returns an error if the string parameter is null.
292It does not detect I/O errors:
293X/Open states that \fBtputs\fP ignores the return value
294of the output function \fIputc\fP.
295.RE
296.SH NOTES
297The \fBsetupterm\fR routine should be used in place of \fBsetterm\fR.
298It may be useful when you want to test for terminal capabilities without
299committing to the allocation of storage involved in \fBinitscr\fR.
300.PP
301Note that \fBvidattr\fR and \fBvidputs\fR may be macros.
302.SH PORTABILITY
303The function \fBsetterm\fR is not described by X/Open and must
304be considered non-portable. All other functions are as described by X/Open.
305.PP
306\fBsetupterm\fP copies the terminal name to the array \fBttytype\fP.
307This is not part of X/Open Curses, but is assumed by some applications.
308.PP
309In System V Release 4, \fBset_curterm\fR has an \fBint\fR return type and
310returns \fBOK\fR or \fBERR\fR. We have chosen to implement the X/Open Curses
311semantics.
312.PP
313In System V Release 4, the third argument of \fBtputs\fR has the type
314\fBint (*putc)(char)\fR.
315.PP
316At least one implementation of X/Open Curses (Solaris) returns a value
317other than OK/ERR from \fBtputs\fP.
318That returns the length of the string, and does no error-checking.
319.PP
320X/Open Curses prototypes \fBtparm\fR with a fixed number of parameters,
321rather than a variable argument list.
322This implementation uses a variable argument list.
323Portable applications should provide 9 parameters after the format;
324zeroes are fine for this purpose.
325.PP
326X/Open notes that after calling \fBmvcur\fR, the curses state may not match the
327actual terminal state, and that an application should touch and refresh
328the window before resuming normal curses calls.
329Both ncurses and System V Release 4 curses implement \fBmvcur\fR using
330the SCREEN data allocated in either \fBinitscr\fR or \fBnewterm\fR.
331So though it is documented as a terminfo function,
332\fBmvcur\fR is really a curses function which is not well specified.
333.PP
334X/Open states that the old location must be given for \fBmvcur\fP.
335This implementation allows the caller to use -1's for the old ordinates.
336In that case, the old location is unknown.
337.PP
338Extended terminal capability names, e.g., as defined by \fBtic\ -x\fP,
339are not stored in the arrays described in this section.
340.SH SEE ALSO
341\fBcurses\fR(3X),
342\fBcurs_initscr\fR(3X),
343\fBcurs_kernel\fR(3X),
344\fBcurs_termcap\fR(3X),
345\fBputc\fR(3),
346\fBterminfo\fR(\*n)
347.\"#
348.\"# The following sets edit modes for GNU EMACS
349.\"# Local Variables:
350.\"# mode:nroff
351.\"# fill-column:79
352.\"# End: