1curs_terminfo(3X)                                            curs_terminfo(3X)
2
3
4

NAME

6       del_curterm, mvcur, putp, restartterm, set_curterm, setterm, setupterm,
7       tigetflag, tigetnum, tigetstr, tiparm, tparm, tputs, vid_attr,
8       vid_puts, vidattr, vidputs - curses interfaces to terminfo database
9

SYNOPSIS

11       #include <curses.h>
12       #include <term.h>
13
14       int setupterm(char *term, int fildes, int *errret);
15       int setterm(char *term);
16       TERMINAL *set_curterm(TERMINAL *nterm);
17       int del_curterm(TERMINAL *oterm);
18       int restartterm(char *term, int fildes, int *errret);
19       char *tparm(char *str, ...);
20       int tputs(const char *str, int affcnt, int (*putc)(int));
21       int putp(const char *str);
22       int vidputs(chtype attrs, int (*putc)(int));
23       int vidattr(chtype attrs);
24       int vid_puts(attr_t attrs, short pair, void *opts, int (*putc)(int));
25       int vid_attr(attr_t attrs, short pair, void *opts);
26       int mvcur(int oldrow, int oldcol, int newrow, int newcol);
27       int tigetflag(char *capname);
28       int tigetnum(char *capname);
29       char *tigetstr(char *capname);
30       char *tiparm(const char *str, ...);
31

DESCRIPTION

33       These  low-level  routines must be called by programs that have to deal
34       directly with the terminfo database to handle certain terminal capabil‐
35       ities, such as programming function keys.  For all other functionality,
36       curses routines are more suitable and their use is recommended.
37
38       Initially, setupterm should be called.  Note that setupterm is automat‐
39       ically  called  by initscr and newterm.  This defines the set of termi‐
40       nal-dependent variables [listed in terminfo(5)].   The  terminfo  vari‐
41       ables lines and columns are initialized by setupterm as follows:
42
43              If  use_env(FALSE) has been called, values for lines and columns
44              specified in terminfo are used.
45
46              Otherwise, if the environment variables LINES and COLUMNS exist,
47              their  values  are  used.  If these environment variables do not
48              exist and the program is running in a window, the current window
49              size  is  used.   Otherwise, if the environment variables do not
50              exist, the values for lines and columns specified in the termin‐
51              fo database are used.
52
53       The header files curses.h and term.h should be included (in this order)
54       to get the definitions for these strings, numbers, and flags.   Parame‐
55       terized  strings  should  be  passed through tparm to instantiate them.
56       All terminfo strings [including the output of tparm] should be  printed
57       with tputs or putp.  Call the reset_shell_mode to restore the tty modes
58       before exiting [see curs_kernel(3X)].  Programs which  use  cursor  ad‐
59       dressing should output enter_ca_mode upon startup and should output ex‐
60       it_ca_mode before exiting.  Programs desiring shell escapes should call
61
62       reset_shell_mode and output exit_ca_mode before the shell is called and
63       should  output  enter_ca_mode  and call reset_prog_mode after returning
64       from the shell.
65
66       The setupterm routine reads in the terminfo database, initializing  the
67       terminfo  structures,  but  does  not  set up the output virtualization
68       structures used by curses.  The terminal type is the  character  string
69       term; if term is null, the environment variable TERM is used.  All out‐
70       put is to file descriptor fildes which is initialized for  output.   If
71       errret  is not null, then setupterm returns OK or ERR and stores a sta‐
72       tus value in the integer pointed to by errret.  A return  value  of  OK
73       combined with status of 1 in errret is normal.  If ERR is returned, ex‐
74       amine errret:
75
76              1    means that the terminal is hardcopy,  cannot  be  used  for
77                   curses applications.
78
79              0    means that the terminal could not be found, or that it is a
80                   generic type, having too little information for curses  ap‐
81                   plications to run.
82
83              -1   means that the terminfo database could not be found.
84
85       If  errret  is  null, setupterm prints an error message upon finding an
86       error and exits.  Thus, the simplest call is:
87
88             setupterm((char *)0, 1, (int *)0);,
89
90       which uses all the defaults and sends the output to stdout.
91
92       The setterm routine is being replaced by setupterm.  The call:
93
94             setupterm(term, 1, (int *)0)
95
96       provides the same functionality as setterm(term).  The setterm  routine
97       is  included here for BSD compatibility, and is not recommended for new
98       programs.
99
100       The set_curterm routine sets the variable cur_term to nterm, and  makes
101       all of the terminfo boolean, numeric, and string variables use the val‐
102       ues from nterm.  It returns the old value of cur_term.
103
104       The del_curterm routine frees the space pointed to by oterm  and  makes
105       it available for further use.  If oterm is the same as cur_term, refer‐
106       ences to any of the terminfo boolean,  numeric,  and  string  variables
107       thereafter  may  refer  to  invalid  memory locations until another se‐
108       tupterm has been called.
109
110       The restartterm routine is similar to  setupterm  and  initscr,  except
111       that it is called after restoring memory to a previous state (for exam‐
112       ple, when reloading a game saved as a core  image  dump).   It  assumes
113       that  the windows and the input and output options are the same as when
114       memory was saved, but the terminal type and baud rate may be different.
115       Accordingly, it saves various tty state bits, calls setupterm, and then
116       restores the bits.
117
118       The tparm routine instantiates the string str with  parameters  pi.   A
119       pointer is returned to the result of str with the parameters applied.
120
121       tiparm  is  a  newer  form of tparm which uses <stdarg.h> rather than a
122       fixed-parameter list.  Its numeric parameters are integers (int) rather
123       than longs.
124
125       The  tputs  routine  applies  padding information to the string str and
126       outputs it.  The str must be a terminfo string variable or  the  return
127       value from tparm, tgetstr, or tgoto.  affcnt is the number of lines af‐
128       fected, or 1 if not applicable.  putc  is  a  putchar-like  routine  to
129       which the characters are passed, one at a time.
130
131       The putp routine calls tputs(str, 1, putchar).  Note that the output of
132       putp always goes to stdout, not to the fildes specified in setupterm.
133
134       The vidputs routine displays the string on the terminal  in  the  video
135       attribute mode attrs, which is any combination of the attributes listed
136       in curses(3X).  The characters are passed to the  putchar-like  routine
137       putc.
138
139       The vidattr routine is like the vidputs routine, except that it outputs
140       through putchar.
141
142       The vid_attr and vid_puts routines correspond to vidattr  and  vidputs,
143       respectively.   They  use a set of arguments for representing the video
144       attributes plus color, i.e., one of type attr_t for the attributes  and
145       one of short for the color_pair number.  The vid_attr and vid_puts rou‐
146       tines are designed to use the attribute constants with the WA_  prefix.
147       The  opts argument is reserved for future use.  Currently, applications
148       must provide a null pointer for that argument.
149
150       The mvcur routine provides low-level cursor motion.   It  takes  effect
151       immediately (rather than at the next refresh).
152
153       The  tigetflag,  tigetnum and tigetstr routines return the value of the
154       capability corresponding to the terminfo capname passed to  them,  such
155       as xenl.
156
157       The  tigetflag routine returns the value -1 if capname is not a boolean
158       capability, or 0 if it is canceled or absent from the terminal descrip‐
159       tion.
160
161       The  tigetnum  routine returns the value -2 if capname is not a numeric
162       capability, or -1 if it is canceled or absent  from  the  terminal  de‐
163       scription.
164
165       The  tigetstr  routine returns the value (char *)-1 if capname is not a
166       string capability, or 0 if it is canceled or absent from  the  terminal
167       description.
168
169       The  capname  for each capability is given in the table column entitled
170       capname code in the capabilities section of terminfo(5).
171
172              char *boolnames[], *boolcodes[], *boolfnames[]
173
174              char *numnames[], *numcodes[], *numfnames[]
175
176              char *strnames[], *strcodes[], *strfnames[]
177
178       These null-terminated arrays contain the capnames, the  termcap  codes,
179       and the full C names, for each of the terminfo variables.
180

RETURN VALUE

182       Routines  that  return  an integer return ERR upon failure and OK (SVr4
183       only specifies "an integer value other than ERR") upon successful  com‐
184       pletion, unless otherwise noted in the preceding routine descriptions.
185
186       Routines that return pointers always return NULL on error.
187
188       X/Open defines no error conditions.  In this implementation
189
190              del_curterm
191                   returns an error if its terminal parameter is null.
192
193              putp calls tputs, returning the same error-codes.
194
195              restartterm
196                   returns  an  error  if the associated call to setupterm re‐
197                   turns an error.
198
199              setupterm
200                   returns an error if it cannot allocate  enough  memory,  or
201                   create the initial windows (stdscr, curscr, newscr).  Other
202                   error conditions are documented above.
203
204              tputs
205                   returns an error if the string parameter is null.  It  does
206                   not detect I/O errors: X/Open states that tputs ignores the
207                   return value of the output function putc.
208

NOTES

210       The setupterm routine should be used in place of setterm.   It  may  be
211       useful  when you want to test for terminal capabilities without commit‐
212       ting to the allocation of storage involved in initscr.
213
214       Note that vidattr and vidputs may be macros.
215

PORTABILITY

217       The function setterm is not described by X/Open and must be  considered
218       non-portable.  All other functions are as described by X/Open.
219
220       setupterm  copies  the terminal name to the array ttytype.  This is not
221       part of X/Open Curses, but is assumed by some applications.
222
223       In System V Release 4, set_curterm has an int return type  and  returns
224       OK or ERR.  We have chosen to implement the X/Open Curses semantics.
225
226       In  System  V  Release  4, the third argument of tputs has the type int
227       (*putc)(char).
228
229       At least one implementation of X/Open Curses (Solaris) returns a  value
230       other  than  OK/ERR from tputs.  That returns the length of the string,
231       and does no error-checking.
232
233       X/Open Curses prototypes tparm  with  a  fixed  number  of  parameters,
234       rather than a variable argument list.  This implementation uses a vari‐
235       able argument list, but can be configured to  use  the  fixed-parameter
236       list.  Portable applications should provide 9 parameters after the for‐
237       mat; zeroes are fine for this purpose.
238
239       In response to comments by Thomas E. Dickey, X/Open Curses Issue 7 pro‐
240       posed the tiparam function in mid-2009.
241
242       X/Open  notes  that after calling mvcur, the curses state may not match
243       the actual terminal state, and that an application should touch and re‐
244       fresh the window before resuming normal curses calls.  Both ncurses and
245       System V Release 4 curses implement mvcur using the SCREEN  data  allo‐
246       cated  in  either  initscr or newterm.  So though it is documented as a
247       terminfo function, mvcur is really a curses function which is not  well
248       specified.
249
250       X/Open  states that the old location must be given for mvcur.  This im‐
251       plementation allows the caller to use -1's for the old  ordinates.   In
252       that case, the old location is unknown.
253
254       Extended terminal capability names, e.g., as defined by tic -x, are not
255       stored in the arrays described in this section.
256

SEE ALSO

258       curses(3X),   curs_initscr(3X),   curs_kernel(3X),    curs_termcap(3X),
259       curs_variables(3X), term_variables(3X), putc(3), terminfo(5)
260
261
262
263                                                             curs_terminfo(3X)
Impressum