2 <BODY BGCOLOR="#99ccbb" TEXT="#000000" LINK="#4060b0" VLINK="#000080" ALINK="#ff4040">
4 <STRONG>setupterm</STRONG>, <STRONG>setterm</STRONG>, <STRONG>set_curterm</STRONG>, <STRONG>del_curterm</STRONG>, <STRONG>restartterm</STRONG>,
5 <STRONG>tparm</STRONG>, <STRONG>tputs</STRONG>, <STRONG>putp</STRONG>, <STRONG>vidputs</STRONG>, <STRONG>vidattr</STRONG>, <STRONG>mvcur</STRONG>, <STRONG>tigetflag</STRONG>,
6 <STRONG>tigetnum</STRONG>, <STRONG>tigetstr</STRONG> - <STRONG>curses</STRONG> interfaces to terminfo
11 <H2>SYNOPSIS</H2><PRE>
12 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
13 <STRONG>#include</STRONG> <STRONG><term.h></STRONG>
15 <STRONG>int</STRONG> <STRONG>setupterm(const</STRONG> <STRONG>char</STRONG> <STRONG>*term,</STRONG> <STRONG>int</STRONG> <STRONG>fildes,</STRONG> <STRONG>int</STRONG> <STRONG>*errret);</STRONG>
16 <STRONG>int</STRONG> <STRONG>setterm(const</STRONG> <STRONG>char</STRONG> <STRONG>*term);</STRONG>
17 <STRONG>TERMINAL</STRONG> <STRONG>*set_curterm(TERMINAL</STRONG> <STRONG>*nterm);</STRONG>
18 <STRONG>int</STRONG> <STRONG>del_curterm(TERMINAL</STRONG> <STRONG>*oterm);</STRONG>
19 <STRONG>int</STRONG> <STRONG>restartterm(const</STRONG> <STRONG>char</STRONG> <STRONG>*term,</STRONG> <STRONG>int</STRONG> <STRONG>fildes,</STRONG> <STRONG>int</STRONG>
20 <STRONG>*errret);</STRONG>
21 <STRONG>char</STRONG> <STRONG>*tparm(const</STRONG> <STRONG>char</STRONG> <STRONG>*str,</STRONG> <STRONG>...);</STRONG>
22 <STRONG>int</STRONG> <STRONG>tputs(const</STRONG> <STRONG>char</STRONG> <STRONG>*str,</STRONG> <STRONG>int</STRONG> <STRONG>affcnt,</STRONG> <STRONG>int</STRONG> <STRONG>(*putc)(int));</STRONG>
23 <STRONG>int</STRONG> <STRONG>putp(const</STRONG> <STRONG>char</STRONG> <STRONG>*str);</STRONG>
24 <STRONG>int</STRONG> <STRONG>vidputs(chtype</STRONG> <STRONG>attrs,</STRONG> <STRONG>int</STRONG> <STRONG>(*putc)(char));</STRONG>
25 <STRONG>int</STRONG> <STRONG>vidattr(chtype</STRONG> <STRONG>attrs);</STRONG>
26 <STRONG>int</STRONG> <STRONG>mvcur(int</STRONG> <STRONG>oldrow,</STRONG> <STRONG>int</STRONG> <STRONG>oldcol,</STRONG> <STRONG>int</STRONG> <STRONG>newrow,</STRONG> <STRONG>int</STRONG> <STRONG>newcol);</STRONG>
27 <STRONG>int</STRONG> <STRONG>tigetflag(const</STRONG> <STRONG>char</STRONG> <STRONG>*capname);</STRONG>
28 <STRONG>int</STRONG> <STRONG>tigetnum(const</STRONG> <STRONG>char</STRONG> <STRONG>*capname);</STRONG>
29 <STRONG>char</STRONG> <STRONG>*tigetstr(const</STRONG> <STRONG>char</STRONG> <STRONG>*capname);</STRONG>
33 <H2>DESCRIPTION</H2><PRE>
34 These low-level routines must be called by programs that
35 have to deal directly with the <STRONG>terminfo</STRONG> database to handle
36 certain terminal capabilities, such as programming func-
37 tion keys. For all other functionality, <STRONG>curses</STRONG> routines
38 are more suitable and their use is recommended.
40 Initially, <STRONG>setupterm</STRONG> should be called. Note that
41 <STRONG>setupterm</STRONG> is automatically called by <STRONG>initscr</STRONG> and <STRONG>newterm</STRONG>.
42 This defines the set of terminal-dependent variables
43 [listed in <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>]. The <STRONG>terminfo</STRONG> variables <STRONG>lines</STRONG> and
44 <STRONG>columns</STRONG> are initialized by <STRONG>setupterm</STRONG> as follows: If
45 <STRONG>use_env(FALSE)</STRONG> has been called, values for <STRONG>lines</STRONG> and
46 <STRONG>columns</STRONG> specified in <STRONG>terminfo</STRONG> are used. Otherwise, if the
47 environment variables <STRONG>LINES</STRONG> and <STRONG>COLUMNS</STRONG> exist, their val-
48 ues are used. If these environment variables do not exist
49 and the program is running in a window, the current window
50 size is used. Otherwise, if the environment variables do
51 not exist, the values for <STRONG>lines</STRONG> and <STRONG>columns</STRONG> specified in
52 the <STRONG>terminfo</STRONG> database are used.
54 The header files <STRONG>curses.h</STRONG> and <STRONG>term.h</STRONG> should be included
55 (in this order) to get the definitions for these strings,
56 numbers, and flags. Parameterized strings should be
57 passed through <STRONG>tparm</STRONG> to instantiate them. All <STRONG>terminfo</STRONG>
58 strings [including the output of <STRONG>tparm</STRONG>] should be printed
59 with <STRONG>tputs</STRONG> or <STRONG>putp</STRONG>. Call the <STRONG>reset_shell_mode</STRONG> to restore
60 <STRONG>enter_ca_mode</STRONG> upon startup and should output <STRONG>exit_ca_mode</STRONG>
61 before exiting. Programs desiring shell escapes should
64 <STRONG>reset_shell_mode</STRONG> and output <STRONG>exit_ca_mode</STRONG> before the shell
65 is called and should output <STRONG>enter_ca_mode</STRONG> and call
66 <STRONG>reset_prog_mode</STRONG> after returning from the shell.
68 The <STRONG>setupterm</STRONG> routine reads in the <STRONG>terminfo</STRONG> database, ini-
69 tializing the <STRONG>terminfo</STRONG> structures, but does not set up the
70 output virtualization structures used by <STRONG>curses</STRONG>. The ter-
71 minal type is the character string <EM>term</EM>; if <EM>term</EM> is null,
72 the environment variable <STRONG>TERM</STRONG> is used. All output is to
73 file descriptor <STRONG>fildes</STRONG> which is initialized for output.
74 If <EM>errret</EM> is not null, then <STRONG>setupterm</STRONG> returns <STRONG>OK</STRONG> or <STRONG>ERR</STRONG>
75 and stores a status value in the integer pointed to by
76 <EM>errret</EM>. A status of <STRONG>1</STRONG> in <EM>errret</EM> is normal, <STRONG>0</STRONG> means that
77 the terminal could not be found, and <STRONG>-1</STRONG> means that the
78 <STRONG>terminfo</STRONG> database could not be found. If <EM>errret</EM> is null,
79 <STRONG>setupterm</STRONG> prints an error message upon finding an error
80 and exits. Thus, the simplest call is:
82 <STRONG>setupterm((char</STRONG> <STRONG>*)0,</STRONG> <STRONG>1,</STRONG> <STRONG>(int</STRONG> <STRONG>*)0);</STRONG>,
84 which uses all the defaults and sends the output to <STRONG>std-</STRONG>
87 The <STRONG>setterm</STRONG> routine is being replaced by <STRONG>setupterm</STRONG>. The
90 <STRONG>setupterm(</STRONG><EM>term</EM><STRONG>,</STRONG> <STRONG>1,</STRONG> <STRONG>(int</STRONG> <STRONG>*)0)</STRONG>
92 provides the same functionality as <STRONG>setterm(</STRONG><EM>term</EM><STRONG>)</STRONG>. The
93 <STRONG>setterm</STRONG> routine is included here for BSD compatibility,
94 and is not recommended for new programs.
96 The <STRONG>set_curterm</STRONG> routine sets the variable <STRONG>cur_term</STRONG> to
97 <EM>nterm</EM>, and makes all of the <STRONG>terminfo</STRONG> boolean, numeric, and
98 string variables use the values from <EM>nterm</EM>. It returns
99 the old value of <STRONG>cur_term</STRONG>.
101 The <STRONG>del_curterm</STRONG> routine frees the space pointed to by
102 <EM>oterm</EM> and makes it available for further use. If <EM>oterm</EM> is
103 the same as <STRONG>cur_term</STRONG>, references to any of the <STRONG>terminfo</STRONG>
104 boolean, numeric, and string variables thereafter may
105 refer to invalid memory locations until another <STRONG>setupterm</STRONG>
108 The <STRONG>restartterm</STRONG> routine is similar to <STRONG>setupterm</STRONG> and
109 <STRONG>initscr</STRONG>, except that it is called after restoring memory
110 to a previous state (for example, when reloading a game
111 saved as a core image dump). It assumes that the windows
112 be different. Accordingly, it saves various tty state
113 bits, does a setupterm, and then restores the bits.
115 The <STRONG>tparm</STRONG> routine instantiates the string <EM>str</EM> with parame-
116 ters <EM>pi</EM>. A pointer is returned to the result of <EM>str</EM> with
117 the parameters applied.
119 The <STRONG>tputs</STRONG> routine applies padding information to the
120 string <EM>str</EM> and outputs it. The <EM>str</EM> must be a terminfo
121 string variable or the return value from <STRONG>tparm</STRONG>, <STRONG>tgetstr</STRONG>,
122 or <STRONG>tgoto</STRONG>. <EM>affcnt</EM> is the number of lines affected, or 1 if
123 not applicable. <EM>putc</EM> is a <STRONG>putchar</STRONG>-like routine to which
124 the characters are passed, one at a time.
126 The <STRONG>putp</STRONG> routine calls <STRONG>tputs(</STRONG><EM>str</EM><STRONG>,</STRONG> <STRONG>1,</STRONG> <STRONG>putchar)</STRONG>. Note that
127 the output of <STRONG>putp</STRONG> always goes to <STRONG>stdout</STRONG>, not to the
128 <EM>fildes</EM> specified in <STRONG>setupterm</STRONG>.
130 The <STRONG>vidputs</STRONG> routine displays the string on the terminal in
131 the video attribute mode <EM>attrs</EM>, which is any combination
132 of the attributes listed in <STRONG><A HREF="ncurses.3x.html">curses(3X)</A></STRONG>. The characters
133 are passed to the <STRONG>putchar</STRONG>-like routine <EM>putc</EM>.
135 The <STRONG>vidattr</STRONG> routine is like the <STRONG>vidputs</STRONG> routine, except
136 that it outputs through <STRONG>putchar</STRONG>.
138 The <STRONG>mvcur</STRONG> routine provides low-level cursor motion. It
139 takes effect immediately (rather than at the next
142 The <STRONG>tigetflag</STRONG>, <STRONG>tigetnum</STRONG> and <STRONG>tigetstr</STRONG> routines return the
143 value of the capability corresponding to the <STRONG>terminfo</STRONG> <EM>cap-</EM>
144 <EM>name</EM> passed to them, such as <STRONG>xenl</STRONG>.
146 The <STRONG>tigetflag</STRONG> routine returns the value <STRONG>-1</STRONG> if <EM>capname</EM> is
147 not a boolean capability.
149 The <STRONG>tigetnum</STRONG> routine returns the value <STRONG>-2</STRONG> if <EM>capname</EM> is
150 not a numeric capability.
152 The <STRONG>tigetstr</STRONG> routine returns the value <STRONG>(char</STRONG> <STRONG>*)-1</STRONG> if <EM>cap-</EM>
153 <EM>name</EM> is not a string capability.
155 The <EM>capname</EM> for each capability is given in the table col-
156 umn entitled <EM>capname</EM> code in the capabilities section of
157 <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
159 <STRONG>char</STRONG> <STRONG>*boolnames</STRONG>, <STRONG>*boolcodes</STRONG>, <STRONG>*boolfnames</STRONG>
161 <STRONG>char</STRONG> <STRONG>*numnames</STRONG>, <STRONG>*numcodes</STRONG>, <STRONG>*numfnames</STRONG>
163 <STRONG>char</STRONG> <STRONG>*strnames</STRONG>, <STRONG>*strcodes</STRONG>, <STRONG>*strfnames</STRONG>
164 <STRONG>termcap</STRONG> codes, and the full C names, for each of the <STRONG>ter-</STRONG>
165 <STRONG>minfo</STRONG> variables.
169 <H2>RETURN VALUE</H2><PRE>
170 Routines that return an integer return <STRONG>ERR</STRONG> upon failure
171 and <STRONG>OK</STRONG> (SVr4 only specifies "an integer value other than
172 <STRONG>ERR</STRONG>") upon successful completion, unless otherwise noted
173 in the preceding routine descriptions.
175 Routines that return pointers always return <STRONG>NULL</STRONG> on error.
180 The <STRONG>setupterm</STRONG> routine should be used in place of <STRONG>setterm</STRONG>.
181 It may be useful when you want to test for terminal capa-
182 bilities without committing to the allocation of storage
183 involved in <STRONG>initscr</STRONG>.
185 Note that <STRONG>vidattr</STRONG> and <STRONG>vidputs</STRONG> may be macros.
189 <H2>PORTABILITY</H2><PRE>
190 The function <STRONG>setterm</STRONG> is not described in the XSI Curses
191 standard and must be considered non-portable. All other
192 functions are as described in the XSI curses standard.
194 In System V Release 4, <STRONG>set_curterm</STRONG> has an <STRONG>int</STRONG> return type
195 and returns <STRONG>OK</STRONG> or <STRONG>ERR</STRONG>. We have chosen to implement the
196 XSI Curses semantics.
198 In System V Release 4, the third argument of <STRONG>tputs</STRONG> has the
199 type <STRONG>int</STRONG> <STRONG>(*putc)(char)</STRONG>.
201 The XSI Curses standard prototypes <STRONG>tparm</STRONG> with a fixed num-
202 ber of parameters, rather than a variable argument list.
206 <H2>SEE ALSO</H2><PRE>
207 <STRONG><A HREF="ncurses.3x.html">curses(3X)</A></STRONG>, <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3X)</A></STRONG>, <STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3X)</A></STRONG>, <STRONG>curs_term-</STRONG>
208 <STRONG><A HREF="cap.3x.html">cap(3X)</A></STRONG>, <STRONG><A HREF="putc.3s.html">putc(3S)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>