Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 2 | .\" Copyright (c) 1998-2013,2015 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 29 | .\" $Id: curs_termcap.3x,v 1.31 2015/04/26 00:49:10 tom Exp $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 30 | .TH curs_termcap 3X "" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 31 | .de bP |
| 32 | .IP \(bu 4 |
| 33 | .. |
| 34 | .na |
| 35 | .hy 0 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 36 | .ds n 5 |
| 37 | .SH NAME |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 38 | \fBPC\fR, |
| 39 | \fBUP\fR, |
| 40 | \fBBC\fR, |
| 41 | \fBospeed\fR, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 42 | \fBtgetent\fR, |
| 43 | \fBtgetflag\fR, |
| 44 | \fBtgetnum\fR, |
| 45 | \fBtgetstr\fR, |
| 46 | \fBtgoto\fR, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 47 | \fBtputs\fR \- direct \fBcurses\fR interface to the terminfo capability database |
| 48 | .ad |
| 49 | .hy |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 50 | .SH SYNOPSIS |
| 51 | \fB#include <curses.h>\fR |
| 52 | .br |
| 53 | \fB#include <term.h>\fR |
| 54 | .sp |
| 55 | \fBextern char PC;\fR |
| 56 | .br |
| 57 | \fBextern char * UP;\fR |
| 58 | .br |
| 59 | \fBextern char * BC;\fR |
| 60 | .br |
| 61 | \fBextern @NCURSES_OSPEED@ ospeed;\fR |
| 62 | .sp |
| 63 | \fBint tgetent(char *bp, const char *name);\fR |
| 64 | .br |
| 65 | \fBint tgetflag(char *id);\fR |
| 66 | .br |
| 67 | \fBint tgetnum(char *id);\fR |
| 68 | .br |
| 69 | \fBchar *tgetstr(char *id, char **area);\fR |
| 70 | .br |
| 71 | \fBchar *tgoto(const char *cap, int col, int row);\fR |
| 72 | .br |
| 73 | \fBint tputs(const char *str, int affcnt, int (*putc)(int));\fR |
| 74 | .br |
| 75 | .SH DESCRIPTION |
| 76 | These routines are included as a conversion aid for programs that use |
| 77 | the \fItermcap\fR library. Their parameters are the same and the |
| 78 | routines are emulated using the \fIterminfo\fR database. Thus, they |
| 79 | can only be used to query the capabilities of entries for which a |
| 80 | terminfo entry has been compiled. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 81 | .SS INITIALIZATION |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 82 | .PP |
| 83 | The \fBtgetent\fR routine loads the entry for \fIname\fR. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 84 | It returns: |
| 85 | .RS 3 |
| 86 | .TP 3 |
| 87 | 1 |
| 88 | on success, |
| 89 | .TP 3 |
| 90 | 0 |
| 91 | if there is no such entry |
| 92 | (or that it is a generic type, having too little information for curses |
| 93 | applications to run), and |
| 94 | .TP 3 |
| 95 | \-1 |
| 96 | if the terminfo database could not be found. |
| 97 | .RE |
| 98 | .PP |
| 99 | This differs from the \fItermcap\fP library in two ways: |
| 100 | .RS 3 |
| 101 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 102 | The emulation ignores the buffer pointer \fIbp\fR. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 103 | The \fItermcap\fP library would store a copy of the terminal |
| 104 | description in the area referenced by this pointer. |
| 105 | However, ncurses stores its terminal descriptions in compiled |
| 106 | binary form, which is not the same thing. |
| 107 | .bP |
| 108 | There is a difference in return codes. |
| 109 | The \fItermcap\fP library does not check if the terminal |
| 110 | description is marked with the \fIgeneric\fP capability, |
| 111 | or if the terminal description has cursor-addressing. |
| 112 | .RE |
| 113 | .SS CAPABILITY VALUES |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 114 | .PP |
| 115 | The \fBtgetflag\fR routine gets the boolean entry for \fIid\fR, |
| 116 | or zero if it is not available. |
| 117 | .PP |
| 118 | The \fBtgetnum\fR routine gets the numeric entry for \fIid\fR, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 119 | or \-1 if it is not available. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 120 | .PP |
| 121 | The \fBtgetstr\fR routine returns the string entry for \fIid\fR, |
| 122 | or zero if it is not available. |
| 123 | Use \fBtputs\fR to output the returned string. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 124 | The \fIarea\fP parameter is used as follows: |
| 125 | .RS 3 |
| 126 | .bP |
| 127 | It is assumed to be the address of a pointer to a buffer managed by the |
| 128 | calling application. |
| 129 | .bP |
| 130 | However, ncurses checks to ensure that \fBarea\fP is not NULL, |
| 131 | and also that the resulting buffer pointer is not NULL. |
| 132 | If either check fails, the \fIarea\fP parameter is ignored. |
| 133 | .bP |
| 134 | If the checks succeed, ncurses also copies the return value to |
| 135 | the buffer pointed to by \fIarea\fR, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 136 | and the \fIarea\fR value will be updated to point past the null ending |
| 137 | this value. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 138 | .bP |
| 139 | The return value itself is an address in the terminal description which |
| 140 | is loaded into memory. |
| 141 | .RE |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 142 | .PP |
| 143 | Only the first two characters of the \fBid\fR parameter of |
| 144 | \fBtgetflag\fR, |
| 145 | \fBtgetnum\fR and |
| 146 | \fBtgetstr\fR are compared in lookups. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 147 | .SS FORMATTING CAPABILITIES |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 148 | .PP |
| 149 | The \fBtgoto\fR routine instantiates the parameters into the given capability. |
| 150 | The output from this routine is to be passed to \fBtputs\fR. |
| 151 | .PP |
| 152 | The \fBtputs\fR routine is described on the \fBcurs_terminfo\fR(3X) manual |
| 153 | page. It can retrieve capabilities by either termcap or terminfo name. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 154 | .SS GLOBAL VARIABLES |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 155 | .PP |
| 156 | The variables |
| 157 | \fBPC\fR, |
| 158 | \fBUP\fR and |
| 159 | \fBBC\fR |
| 160 | are set by \fBtgetent\fR to the terminfo entry's data for |
| 161 | \fBpad_char\fR, |
| 162 | \fBcursor_up\fR and |
| 163 | \fBbackspace_if_not_bs\fR, |
| 164 | respectively. |
| 165 | \fBUP\fR is not used by ncurses. |
| 166 | \fBPC\fR is used in the \fBtdelay_output\fR function. |
| 167 | \fBBC\fR is used in the \fBtgoto\fR emulation. |
| 168 | The variable \fBospeed\fR is set by ncurses in a system-specific coding |
| 169 | to reflect the terminal speed. |
| 170 | . |
| 171 | .SH RETURN VALUE |
| 172 | Except where explicitly noted, |
| 173 | routines that return an integer return \fBERR\fR upon failure and \fBOK\fR |
| 174 | (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful |
| 175 | completion. |
| 176 | .PP |
| 177 | Routines that return pointers return \fBNULL\fR on error. |
| 178 | .SH BUGS |
| 179 | If you call \fBtgetstr\fR to fetch \fBca\fR or any other parameterized string, |
| 180 | be aware that it will be returned in terminfo notation, not the older and |
| 181 | not-quite-compatible termcap notation. This will not cause problems if all |
| 182 | you do with it is call \fBtgoto\fR or \fBtparm\fR, which both expand |
| 183 | terminfo-style strings as terminfo. |
| 184 | (The \fBtgoto\fR function, if configured to support termcap, will check |
| 185 | if the string is indeed terminfo-style by looking for "%p" parameters or |
| 186 | "$<..>" delays, and invoke a termcap-style parser if the string does not |
| 187 | appear to be terminfo). |
| 188 | .PP |
| 189 | Because terminfo conventions for representing padding in string capabilities |
| 190 | differ from termcap's, \fBtputs("50");\fR will put out a literal "50" rather |
| 191 | than busy-waiting for 50 milliseconds. Cope with it. |
| 192 | .PP |
| 193 | Note that termcap has nothing analogous to terminfo's \fBsgr\fR string. |
| 194 | One consequence of this is that termcap applications assume \fRme\fR |
| 195 | (terminfo \fBsgr0\fR) does not reset the alternate character set. |
| 196 | This implementation checks for, and modifies the data shown to the |
| 197 | termcap interface to accommodate termcap's limitation in this respect. |
| 198 | .SH PORTABILITY |
| 199 | The XSI Curses standard, Issue 4 describes these functions. However, they |
| 200 | are marked TO BE WITHDRAWN and may be removed in future versions. |
| 201 | .PP |
| 202 | Neither the XSI Curses standard nor the SVr4 man pages documented the return |
| 203 | values of \fBtgetent\fR correctly, though all three were in fact returned ever |
| 204 | since SVr1. |
| 205 | In particular, an omission in the XSI Curses documentation has been |
| 206 | misinterpreted to mean that \fBtgetent\fR returns \fBOK\fR or \fBERR\fR. |
| 207 | Because the purpose of these functions is to provide compatibility with |
| 208 | the \fItermcap\fR library, that is a defect in XCurses, Issue 4, Version 2 |
| 209 | rather than in ncurses. |
| 210 | .PP |
| 211 | External variables are provided for support of certain termcap applications. |
| 212 | However, termcap applications' use of those variables is poorly documented, |
| 213 | e.g., not distinguishing between input and output. |
| 214 | In particular, some applications are reported to declare and/or |
| 215 | modify \fBospeed\fR. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 216 | .PP |
| 217 | The comment that only the first two characters of the \fBid\fR parameter |
| 218 | are used escapes many application developers. |
| 219 | The original BSD 4.2 termcap library (and historical relics thereof) |
| 220 | did not require a trailing null NUL on the parameter name passed |
| 221 | to \fBtgetstr\fP, \fBtgetnum\fP and \fBtgetflag\fP. |
| 222 | Some applications assume that the termcap interface does not require |
| 223 | the trailing NUL for the parameter name. |
| 224 | Taking into account these issues: |
| 225 | .bP |
| 226 | As a special case, |
| 227 | \fBtgetflag\fP matched against a single-character identifier |
| 228 | provided that was at the end of the terminal description. |
| 229 | You should not rely upon this behavior in portable programs. |
| 230 | This implementation disallows matches against single-character capability names. |
| 231 | .bP |
| 232 | This implementation disallows matches by the termcap interface against |
| 233 | extended capability names which are longer than two characters. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 234 | .SH SEE ALSO |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 235 | \fBcurses\fR(3X), |
| 236 | \fBterminfo\fR(\*n), |
| 237 | \fBterm_variables\fR(3X), |
| 238 | \fBputc\fR(3). |
| 239 | .sp |
| 240 | http://invisible-island.net/ncurses/tctest.html |