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