Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 1998-2017,2018 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | .\" * |
| 5 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | .\" copy of this software and associated documentation files (the * |
| 7 | .\" "Software"), to deal in the Software without restriction, including * |
| 8 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 11 | .\" furnished to do so, subject to the following conditions: * |
| 12 | .\" * |
| 13 | .\" The above copyright notice and this permission notice shall be included * |
| 14 | .\" in all copies or substantial portions of the Software. * |
| 15 | .\" * |
| 16 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | .\" * |
| 24 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 25 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 26 | .\" sale, use or other dealings in this Software without prior written * |
| 27 | .\" authorization. * |
| 28 | .\"*************************************************************************** |
| 29 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $Id: curs_termcap.3x,v 1.85 2024/04/20 19:13:12 tom Exp $ |
| 31 | .TH curs_termcap 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
| 32 | .ie \n(.g \{\ |
| 33 | .ds `` \(lq |
| 34 | .ds '' \(rq |
| 35 | .\} |
| 36 | .el \{\ |
| 37 | .ie t .ds `` `` |
| 38 | .el .ds `` "" |
| 39 | .ie t .ds '' '' |
| 40 | .el .ds '' "" |
| 41 | .\} |
| 42 | . |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 43 | .de bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 44 | .ie n .IP \(bu 4 |
| 45 | .el .IP \(bu 2 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 46 | .. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 47 | . |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 48 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 49 | \fB\%PC\fP, |
| 50 | \fB\%UP\fP, |
| 51 | \fB\%BC\fP, |
| 52 | \fB\%ospeed\fP, |
| 53 | \fB\%tgetent\fP, |
| 54 | \fB\%tgetflag\fP, |
| 55 | \fB\%tgetnum\fP, |
| 56 | \fB\%tgetstr\fP, |
| 57 | \fB\%tgoto\fP, |
| 58 | \fB\%tputs\fP \- |
| 59 | \fIcurses\fR emulation of \fItermcap\fR |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 60 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 61 | .nf |
| 62 | \fB#include <curses.h> |
| 63 | \fB#include <term.h> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 64 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 65 | \fBchar PC; |
| 66 | \fBchar * UP; |
| 67 | \fBchar * BC; |
| 68 | \fB@NCURSES_OSPEED@ ospeed; |
| 69 | .PP |
| 70 | \fBint tgetent(char *\fIbp\fP, const char *\fIname\fP); |
| 71 | \fBint tgetflag(const char *\fIid\fP); |
| 72 | \fBint tgetnum(const char *\fIid\fP); |
| 73 | \fBchar *tgetstr(const char *\fIid\fP, char **\fIarea\fP); |
| 74 | \fBchar *tgoto(const char *\fIcap\fP, int \fIcol\fP, int \fIrow\fP); |
| 75 | \fBint tputs(const char *\fIstr\fP, int \fIaffcnt\fP, int (*\fIputc\fP)(int)); |
| 76 | .fi |
| 77 | .SH DESCRIPTION |
| 78 | .I \%ncurses |
| 79 | provides the foregoing variables and functions as a compatibility layer |
| 80 | for programs that use the \fItermcap\fP library. |
| 81 | The API is the same, |
| 82 | but behavior is emulated using the \fI\%term\%info\fP database. |
| 83 | Thus, |
| 84 | it can be used only to query the capabilities of terminal database |
| 85 | entries for which a \fI\%term\%info\fP entry has been compiled. |
| 86 | .SS Initialization |
| 87 | \fB\%tgetent\fP loads the terminal database entry for \fIname\fP; |
| 88 | see \fBterm\fP(7). |
| 89 | This must be done before calling any of the other functions. |
| 90 | It returns |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 91 | .RS 3 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 92 | .TP 5 \" "-1" + 2n + adjust for PDF |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 93 | 1 |
| 94 | on success, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 95 | .TP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 96 | 0 |
| 97 | if there is no such entry |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 98 | (or if the matching entry describes a generic terminal, |
| 99 | having too little information for |
| 100 | .I curses |
| 101 | applications to run), |
| 102 | and |
| 103 | .TP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 104 | \-1 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 105 | if the \fI\%term\%info\fP database could not be found. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 106 | .RE |
| 107 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 108 | This implementation differs from those of historical \fItermcap\fP |
| 109 | libraries. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 110 | .RS 3 |
| 111 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 112 | .I \%ncurses |
| 113 | ignores the buffer pointer \fIbp\fP, |
| 114 | as do other \fItermcap\fP implementations conforming to portions of |
| 115 | X/Open Curses now withdrawn. |
| 116 | The BSD \fItermcap\fP library would store a copy of the terminal type |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 117 | description in the area referenced by this pointer. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 118 | \fI\%term\%info\fP stores terminal type descriptions in compiled form, |
| 119 | which is not the same thing. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 120 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 121 | The meanings of the return values differ. |
| 122 | The BSD \fItermcap\fP library does not check whether the terminal type |
| 123 | description includes the |
| 124 | .B \%generic |
| 125 | .RB ( gn ) |
| 126 | capability, |
| 127 | nor whether the terminal type description supports an addressable |
| 128 | cursor, |
| 129 | a property essential for any \fIcurses\fP implementation to operate. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 130 | .RE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 131 | .SS "Retrieving Capability Values" |
| 132 | \fB\%tgetflag\fP reports the Boolean entry for \fIid\fP, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 133 | or zero if it is not available. |
| 134 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 135 | \fB\%tgetnum\fP obtains the numeric entry for \fIid\fP, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 136 | or \-1 if it is not available. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 137 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 138 | \fB\%tgetstr\fP returns the string entry for \fIid\fP, |
| 139 | or |
| 140 | .B NULL |
| 141 | if it is not available. |
| 142 | Use \fB\%tputs\fP to output the string returned. |
| 143 | The |
| 144 | .I area |
| 145 | parameter is used as follows. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 146 | .RS 3 |
| 147 | .bP |
| 148 | It is assumed to be the address of a pointer to a buffer managed by the |
| 149 | calling application. |
| 150 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 151 | However, |
| 152 | \fI\%ncurses\fP checks to ensure that |
| 153 | .I area |
| 154 | is not |
| 155 | .BR NULL , |
| 156 | and also that the resulting buffer pointer is not |
| 157 | .BR NULL . |
| 158 | If either check fails, |
| 159 | .I area |
| 160 | is ignored. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 161 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 162 | If the checks succeed, |
| 163 | \fI\%ncurses\fP also copies the return value to the buffer pointed to by |
| 164 | \fIarea\fP, |
| 165 | and the library updates |
| 166 | .I area |
| 167 | to point past the null character terminating this value. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 168 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 169 | The return value itself is an address in the terminal type description |
| 170 | loaded into memory. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 171 | .RE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 172 | .SS "Applying String Capabilities" |
| 173 | String capabilities can be parameterized; |
| 174 | see subsection \*(``Parameterized Strings\*('' in \fB\%terminfo\fP(5). |
| 175 | \fB\%tgoto\fP applies its second and third arguments to the parametric |
| 176 | placeholders in the capability stored in the first argument. |
| 177 | .bP |
| 178 | The capability may contain padding specifications; |
| 179 | see subsection \*(``Delays and Padding\*('' of \fB\%terminfo\fP(5). |
| 180 | The output of \fB\%tgoto\fP should thus be passed to \fB\%tputs\fP |
| 181 | rather than some other output function such as \fI\%printf\fP(3). |
| 182 | .bP |
| 183 | While \fB\%tgoto\fP is assumed to be used for the two-parameter |
| 184 | cursor positioning capability, |
| 185 | \fItermcap\fP applications also use it for single-parameter |
| 186 | capabilities. |
| 187 | .IP |
| 188 | Doing so reveals a quirk in \fB\%tgoto\fP: |
| 189 | most hardware terminals use cursor addressing with \fIrow\fP first, |
| 190 | but the original developers of the \fItermcap\fP interface chose to |
| 191 | put the \fIcol\fP (column) parameter first. |
| 192 | The \fB\%tgoto\fP function swaps the order of its parameters. |
| 193 | It does this even for calls requiring only a single parameter. |
| 194 | In that case, |
| 195 | the first parameter is merely a placeholder. |
| 196 | .bP |
| 197 | Normally the \fI\%ncurses\fP library is compiled without |
| 198 | full \fI\%termcap\fP support. |
| 199 | In that case, |
| 200 | \fB\%tgoto\fP uses an internal version of \fB\%tparm\fP(3X) |
| 201 | (a more capable function). |
| 202 | .IP |
| 203 | Because it uses \fB\%tparm\fP internally, |
| 204 | \fB\%tgoto\fP is able to use some \fI\%term\%info\fP features, |
| 205 | but not all. |
| 206 | In particular, |
| 207 | it allows only numeric parameters; |
| 208 | \fB\%tparm\fP supports string parameters. |
| 209 | .IP |
| 210 | However, |
| 211 | \fB\%tparm\fP is not a \fItermcap\fP feature, |
| 212 | and portable \fItermcap\fP applications should not rely upon its |
| 213 | availability. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 214 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 215 | \fB\%tputs\fP is described in \fB\%curs_terminfo\fP(3X). |
| 216 | It can retrieve capabilities by either \fItermcap\fP or |
| 217 | \fI\%term\%info\fP code. |
| 218 | .SS "Global Variables" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 219 | The variables |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 220 | \fBPC\fP, |
| 221 | \fBUP\fP and |
| 222 | \fBBC\fP |
| 223 | are set by \fB\%tgetent\fP to the \fI\%term\%info\fP entry's data for |
| 224 | \fB\%pad_char\fP, |
| 225 | \fB\%cursor_up\fP and |
| 226 | \fB\%backspace_if_not_bs\fP, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 227 | respectively. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 228 | \fBUP\fP is not used by \fI\%ncurses\fP. |
| 229 | \fBPC\fP is used by \fB\%delay_output\fP(3X). |
| 230 | \fBBC\fP is used by \fB\%tgoto\fP emulation. |
| 231 | The variable \fB\%ospeed\fP is set by \fI\%ncurses\fP using a |
| 232 | system-specific encoding to indicate the terminal's data rate. |
| 233 | .SS "Releasing Memory" |
| 234 | The \fItermcap\fP functions provide no means of freeing memory, |
| 235 | because legacy \fItermcap\fP implementations used only the buffer |
| 236 | areas provided by the caller via \fB\%tgetent\fP and \fB\%tgetstr\fP. |
| 237 | Those buffers are unused in \fI\%term\%info\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 238 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 239 | By contrast, |
| 240 | \fI\%term\%info\fP allocates memory. |
| 241 | It uses \fB\%setupterm\fP(3X) to obtain the data used by \fB\%tgetent\fP |
| 242 | and the functions that retrieve capability values. |
| 243 | One could use |
| 244 | .RS |
| 245 | .EX |
| 246 | del_curterm(cur_term); |
| 247 | .EE |
| 248 | .RE |
| 249 | to free this memory, |
| 250 | but there is an additional complication with \fI\%ncurses\fP. |
| 251 | It uses a fixed-size pool of storage locations, |
| 252 | one per value of the terminal name parameter given to \fB\%tgetent\fP. |
| 253 | The \fIscreen\fP(1) program relies upon this arrangement to improve its |
| 254 | performance. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 255 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 256 | An application that uses only the \fItermcap\fP functions, |
| 257 | not the higher level |
| 258 | .I \%curses |
| 259 | API, |
| 260 | could release the memory using \fB\%del_curterm\fP(3X), |
| 261 | because the pool is freed using other functions; |
| 262 | see \fB\%curs_memleaks\fP(3X). |
| 263 | .SH "RETURN VALUE" |
| 264 | The return values of |
| 265 | \fB\%tgetent\fP, |
| 266 | \fB\%tgetflag\fP, |
| 267 | \fB\%tgetname\fP, |
| 268 | and |
| 269 | \fB\%tgetstr\fP |
| 270 | are documented above. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 271 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 272 | \fB\%tgoto\fP returns |
| 273 | .B NULL |
| 274 | on error. |
| 275 | Error conditions include: |
| 276 | .bP |
| 277 | uninitialized state |
| 278 | (\fB\%tgetent\fP was not called successfully), |
| 279 | .bP |
| 280 | .I cap |
| 281 | being a null pointer, |
| 282 | .bP |
| 283 | .I cap |
| 284 | referring to a canceled capability, |
| 285 | .bP |
| 286 | .I cap |
| 287 | being a capability with string-valued parameters |
| 288 | (a \fI\%term\%info\fP-only feature), |
| 289 | and |
| 290 | .bP |
| 291 | .I cap |
| 292 | being a capability with more than two parameters. |
| 293 | .PP |
| 294 | See \fB\%curs_terminfo\fP(3X) regarding \fB\%tputs\fP. |
| 295 | .SH NOTES |
| 296 | \fI\%ncurses\fP compares only the first two characters of the \fIid\fP |
| 297 | parameter of |
| 298 | \fB\%tgetflag\fP, |
| 299 | \fB\%tgetnum\fP, |
| 300 | and |
| 301 | \fB\%tgetstr\fP to the capability names in the database. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 302 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 303 | These functions are no longer standardized |
| 304 | (and the variables never were); |
| 305 | \fI\%ncurses\fP provides them to support legacy applications. |
| 306 | They should not be used in new programs. |
| 307 | .SS Standards |
| 308 | .bP |
| 309 | X/Open Curses, Issue 4, Version 2 (1996), |
| 310 | describes these functions, |
| 311 | marking them as |
| 312 | \*(``TO BE WITHDRAWN\*(''. |
| 313 | .bP |
| 314 | X/Open Curses, Issue 7 (2009) marks the \fItermcap\fP interface |
| 315 | (along with \fB\%vwprintw\fP and \fB\%vwscanw\fP) as withdrawn. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 316 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 317 | Neither X/Open Curses nor the SVr4 man pages documented the return |
| 318 | values of \fB\%tgetent\fP correctly, |
| 319 | though all three shown here were in fact returned ever since SVr1. |
| 320 | In particular, |
| 321 | an omission in the X/Open Curses specification has been misinterpreted |
| 322 | to mean that \fB\%tgetent\fP returns \fBOK\fP or \fBERR\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 323 | Because the purpose of these functions is to provide compatibility with |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 324 | the \fItermcap\fP library, |
| 325 | that is a defect in X/Open Curses, Issue 4, Version 2 |
| 326 | rather than in \fI\%ncurses\fP. |
| 327 | .SS "Compatibility with BSD \fItermcap\fP" |
| 328 | Externally visible variables are provided for support of certain |
| 329 | \fItermcap\fP applications. |
| 330 | However, |
| 331 | their correct usage is poorly documented; |
| 332 | for example, |
| 333 | it is unclear when reading and writing them is meaningful. |
| 334 | In particular, |
| 335 | some applications are reported to declare and/or modify \fB\%ospeed\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 336 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 337 | The constraint that only the first two characters of the \fIid\fP |
| 338 | parameter are used escapes many application developers. |
| 339 | The BSD \fItermcap\fP library did not require a trailing null character |
| 340 | on the capability identifier passed to \fB\%tgetstr\fP, |
| 341 | \fB\%tgetnum\fP, |
| 342 | and |
| 343 | \fB\%tgetflag\fP. |
| 344 | .\" See <https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/\ |
| 345 | .\" termlib/termcap.c>. |
| 346 | Some applications thus assume that the \fItermcap\fP interface does not |
| 347 | require the trailing null character for the capability identifier. |
| 348 | .bP |
| 349 | .I \%ncurses |
| 350 | disallows matches by the \fItermcap\fP interface against extended |
| 351 | capability names that are longer than two characters; |
| 352 | see \fB\%user_caps\fP(5). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 353 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 354 | The BSD \fItermcap\fP function \fB\%tgetent\fP returns the text of a |
| 355 | \fItermcap\fP entry in the buffer passed as an argument. |
| 356 | This library, |
| 357 | like other \fI\%term\%info\fP implementations, |
| 358 | does not store terminal type descriptions as text. |
| 359 | It sets the buffer contents to a null-terminated string. |
| 360 | .SS "Header File" |
| 361 | This library includes a \fI\%termcap.h\fP header for compatibility with |
| 362 | other implementations, |
| 363 | but the header is rarely used because the other implementations are not |
| 364 | strictly compatible. |
| 365 | .SH HISTORY |
| 366 | .\" See https://www.oreilly.com/openbook/opensources/book/kirkmck.html |
| 367 | .\" for much BSD release history. |
| 368 | Bill Joy originated a forerunner of \fItermcap\fP called |
| 369 | \*(``ttycap\*('', |
| 370 | dated September 1977, |
| 371 | and released in 1BSD |
| 372 | (March 1978). |
| 373 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s7/ttycap.c |
| 374 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/man7/ttycap.7 |
| 375 | It used many of the same function names as the later \fItermcap\fP, |
| 376 | such as |
| 377 | \fB\%tgetent\fP, |
| 378 | \fB\%tgetflag\fP, |
| 379 | \fB\%tgetnum\fP, |
| 380 | and |
| 381 | \fB\%tgetstr\fP. |
| 382 | .PP |
| 383 | A clear descendant, |
| 384 | the \fItermlib\fP library, |
| 385 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/termlib/ |
| 386 | followed in 2BSD |
| 387 | (May 1979), |
| 388 | adding \fB\%tgoto\fP and \fB\%tputs\fP. |
| 389 | The former applied at that time only to cursor positioning capabilities, |
| 390 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/bin/etc/termcap |
| 391 | thus the overly specific name. |
| 392 | Little changed in 3BSD |
| 393 | (late 1979) |
| 394 | except the addition of test programs and a \fI\%termlib\fP man page, |
| 395 | which documented the API shown in section \*(``SYNOPSIS\*('' above. |
| 396 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/lib/\ |
| 397 | .\" libtermlib/ |
| 398 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/man/man3/\ |
| 399 | .\" termlib.3 |
| 400 | .PP |
| 401 | 4BSD |
| 402 | (November 1980) |
| 403 | renamed \fItermlib\fP to \fItermcap\fP |
| 404 | .\" ...except in the source tree... |
| 405 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\ |
| 406 | .\" libtermlib/makefile |
| 407 | and added another test program. |
| 408 | The library remained much the same though 4.3BSD |
| 409 | (June 1986). |
| 410 | 4.4BSD-Lite |
| 411 | (June 1994) |
| 412 | refactored it, |
| 413 | .\" Observe the `tncktc()`, `tnamatch()`, `tskip()`, and `tdecode()` |
| 414 | .\" entry points disappearing from termcap.c. |
| 415 | leaving the API unchanged. |
| 416 | .PP |
| 417 | Function prototypes were a feature of ANSI C (1989). |
| 418 | The library long antedated the standard and thus provided no header file |
| 419 | declaring them. |
| 420 | Nevertheless, |
| 421 | the BSD sources included two different \fI\%termcap.h\fP header files |
| 422 | over time. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 423 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 424 | One was used internally by \fBjove\fP(1) from 4.3BSD onward. |
| 425 | .\" 2BSD became a branch retaining support for non-virtual memory |
| 426 | .\" systems (such as the PDP-11) whereas most BSD development focused on |
| 427 | .\" the VAX and other VM-enabled systems starting with 3BSD. |
| 428 | .\" |
| 429 | .\" This man page previously located a termcap.h in 2BSD, but that may |
| 430 | .\" be confusion arising from its backport to 2.9BSD (and still present |
| 431 | .\" in surviving sources for 2.11BSD, the "end of the line" for that |
| 432 | .\" branch's development). |
| 433 | .\" |
| 434 | .\" Observe the copyright notice in |
| 435 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD/usr/contrib/\ |
| 436 | .\" jove/Makefile |
| 437 | .\" --much too late for 2BSD (1979). |
| 438 | It declared global symbols for the \fItermcap\fP variables that it used. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 439 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 440 | The other appeared in 4.4BSD-Lite Release 2 |
| 441 | (June 1995) |
| 442 | as part of \fIlibedit\fP |
| 443 | (also known as the \fI\%edit\%line\fP library). |
| 444 | CSRG source history shows that this was added in mid-1992. |
| 445 | The \fIlibedit\fP header file was used internally as a convenience for |
| 446 | compiling the \fI\%edit\%line\fP library. |
| 447 | It declared function prototypes, |
| 448 | but no global variables. |
| 449 | This header file was added to NetBSD's \fItermcap\fP library in |
| 450 | mid-1994. |
| 451 | .PP |
| 452 | Meanwhile, |
| 453 | GNU \fItermcap\fP began development in 1990. |
| 454 | Its first release (1.0) in 1991 included a \fI\%termcap.h\fP header. |
| 455 | Its second (1.1) in September 1992 modified the header to use |
| 456 | \fIconst\fP for the function prototypes in the header where one would |
| 457 | expect the parameters to be read-only. |
| 458 | BSD \fItermcap\fP did not. |
| 459 | The prototype for \fB\%tputs\fP also differed, |
| 460 | but in that instance, |
| 461 | it was \fIlibedit\fP that differed from BSD \fItermcap\fP. |
| 462 | .PP |
| 463 | GNU \fItermcap\fP 1.3 was bundled with \fIbash\fP(1) in mid-1993 to |
| 464 | support the \fI\%readline\fP(3) library. |
| 465 | .PP |
| 466 | \fI\%ncurses\fP 1.8.1 |
| 467 | (November 1993) |
| 468 | provided a \fI\%termcap.h\fP file. |
| 469 | It reflected influence from GNU \fItermcap\fP and \fBemacs\fP(1) |
| 470 | (rather than \fBjove\fP(1)), |
| 471 | providing the following interface: |
| 472 | .bP |
| 473 | global symbols used by \fIemacs\fP, |
| 474 | .bP |
| 475 | \fIconst\fP-qualified function prototypes, |
| 476 | and |
| 477 | .bP |
| 478 | a prototype for \fBtparam\fP, |
| 479 | a GNU \fItermcap\fP feature. |
| 480 | .PP |
| 481 | Later |
| 482 | (in mid-1996) |
| 483 | the \fB\%tparam\fP function was removed from \fI\%ncurses\fP. |
| 484 | Any two of the four implementations thus differ, |
| 485 | and programs that intend to work with all \fItermcap\fP library |
| 486 | interfaces must account for that fact. |
| 487 | .SH BUGS |
| 488 | If you call \fB\%tgetstr\fP to fetch |
| 489 | .B \%column_address |
| 490 | .RB ( ch ) |
| 491 | or any other parameterized string capability, |
| 492 | be aware that it is returned in \fI\%term\%info\fP notation, |
| 493 | not the older and not-quite-compatible \fItermcap\fP notation. |
| 494 | This does not cause problems if all you do with it is call \fB\%tgoto\fP |
| 495 | or \fB\%tparm\fP, |
| 496 | which both parametrically expand \fI\%term\%info\fP-style string |
| 497 | capabilities as \fI\%term\%info\fP does. |
| 498 | (If |
| 499 | .I \%ncurses |
| 500 | is configured to support \fItermcap,\fP |
| 501 | \fB\%tgoto\fP checks whether the string is \fI\%term\%info\fP-style by |
| 502 | looking for \*(``\fB%p\fP\*('' parameters or |
| 503 | \*(``\fB<\fP.\|.\|.\fB>\fP\*('' delays, |
| 504 | and invokes a \fItermcap\fP-style parser if the string appears not to |
| 505 | use \fI\%term\%info\fP syntax.) |
| 506 | .PP |
| 507 | Because \fI\%term\%info\fP's syntax for padding in string capabilities |
| 508 | differs from \fItermcap\fP's, |
| 509 | users can be surprised. |
| 510 | .IP \(bu 4 |
| 511 | \fB\%tputs("50")\fP in a \fI\%term\%info\fP system transmits |
| 512 | \*(``50\*('' rather than busy-waiting for 50 milliseconds. |
| 513 | .IP \(bu 4 |
| 514 | However, |
| 515 | if \fI\%ncurses\fP is configured to support \fItermcap\fP, |
| 516 | it may also have been configured to support BSD-style padding. |
| 517 | .IP |
| 518 | In that case, |
| 519 | \fB\%tputs\fP inspects strings passed to it, |
| 520 | looking for digits at the beginning of the string. |
| 521 | .IP |
| 522 | \fB\%tputs("50")\fP in a \fItermcap\fP system may busy-wait for 50 |
| 523 | milliseconds rather than transmitting \*(``50\*(''. |
| 524 | .PP |
| 525 | \fItermcap\fP has nothing analogous to \fI\%term\%info\fP's |
| 526 | .B \%set_attributes |
| 527 | .RB ( sgr ) |
| 528 | capability. |
| 529 | One consequence is that \fItermcap\fP applications assume that |
| 530 | .RB \*(`` me \*('' |
| 531 | (equivalent to \fI\%term\%info\fP's |
| 532 | .B \%exit_attribute_mode |
| 533 | .RB ( sgr0 ) |
| 534 | capability) |
| 535 | does not reset the alternate character set. |
| 536 | \fI\%ncurses\fP checks for, |
| 537 | and modifies the data shared with, |
| 538 | the \fItermcap\fP interface to accommodate the latter's limitation in |
| 539 | this respect. |
| 540 | .SH "SEE ALSO" |
| 541 | \fB\%curses\fP(3X), |
| 542 | \fB\%curs_terminfo\fP(3X), |
| 543 | \fB\%putc\fP(3), |
| 544 | \fB\%term_variables\fP(3X), |
| 545 | \fB\%terminfo\fP(5) |
| 546 | .PP |
| 547 | https://invisible\-island.net/ncurses/tctest.html |