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