| 1 |
.\"*************************************************************************** |
| 2 |
.\" Copyright 2018-2024,2025 Thomas E. Dickey * |
| 3 |
.\" Copyright 1998-2017,2018 Free Software Foundation, Inc. * |
| 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 |
.\" |
| 30 |
.\" $Id: curs_termcap.3x,v 1.107 2025/08/16 19:09:12 tom Exp $ |
| 31 |
.TH termcap 3NCURSES 2025-08-16 "ncurses 6.6" "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 |
. |
| 43 |
.ie \n(.g .ds : \: |
| 44 |
.el .ds : \" empty |
| 45 |
. |
| 46 |
.de bP |
| 47 |
.ie n .IP \(bu 4 |
| 48 |
.el .IP \(bu 2 |
| 49 |
.. |
| 50 |
. |
| 51 |
.\" URL hyperlink support macros from groff's "an-ext.tmac" |
| 52 |
. |
| 53 |
.\" Save the automatic hyphenation mode. |
| 54 |
.\" |
| 55 |
.\" In AT&T troff, there was no register exposing the hyphenation mode, |
| 56 |
.\" and no way to save and restore it. Set `mH` to a reasonable value |
| 57 |
.\" for your implementation and preference. |
| 58 |
.de mY |
| 59 |
. ie !\\n(.g \ |
| 60 |
. nr mH 14 |
| 61 |
. el \ |
| 62 |
. do nr mH \\n[.hy] \" groff extension register |
| 63 |
.. |
| 64 |
. |
| 65 |
.\" Prepare link text for mail/web hyperlinks. `MT` and `UR` call this. |
| 66 |
.de mV |
| 67 |
. ds mU \\$1\" |
| 68 |
.. |
| 69 |
. |
| 70 |
.\" Emit hyperlink. The optional argument supplies trailing punctuation |
| 71 |
.\" after link text. `ME` and `UE` call this. |
| 72 |
.de mQ |
| 73 |
. mY |
| 74 |
. nh |
| 75 |
<\\*(mU>\\$1 |
| 76 |
. hy \\n(mH |
| 77 |
. rm mU |
| 78 |
.. |
| 79 |
. |
| 80 |
.\" Start URL. |
| 81 |
.\" .UR url |
| 82 |
.if !\n(.g \{\ |
| 83 |
.de UR |
| 84 |
. mV \\$1 |
| 85 |
.. |
| 86 |
.\} |
| 87 |
. |
| 88 |
.\" End URL. |
| 89 |
.\" .UE [punctuation] |
| 90 |
.if !\n(.g \{\ |
| 91 |
.de UE |
| 92 |
. mQ \\$1 |
| 93 |
.. |
| 94 |
.\} |
| 95 |
. |
| 96 |
.SH NAME |
| 97 |
\fB\%PC\fP, |
| 98 |
\fB\%UP\fP, |
| 99 |
\fB\%BC\fP, |
| 100 |
\fB\%ospeed\fP, |
| 101 |
\fB\%tgetent\fP, |
| 102 |
\fB\%tgetflag\fP, |
| 103 |
\fB\%tgetnum\fP, |
| 104 |
\fB\%tgetstr\fP, |
| 105 |
\fB\%tgoto\fP, |
| 106 |
\fB\%tputs\fP \- |
| 107 |
\fIcurses\fR emulation of \fItermcap\fR |
| 108 |
.SH SYNOPSIS |
| 109 |
.nf |
| 110 |
\fB#include <curses.h> |
| 111 |
\fB#include <term.h> |
| 112 |
.PP |
| 113 |
\fBchar PC; |
| 114 |
\fBchar * UP; |
| 115 |
\fBchar * BC; |
| 116 |
\fBshort ospeed; |
| 117 |
.PP |
| 118 |
\fBint tgetent(char * \fIbp\fP, const char * \fIname\fP); |
| 119 |
\fBint tgetflag(const char * \fIid\fP); |
| 120 |
\fBint tgetnum(const char * \fIid\fP); |
| 121 |
\fBchar * tgetstr(const char * \fIid\fP, char ** \fIsbuf\fP); |
| 122 |
\fBchar * tgoto(const char * \fIcap\fP, int \fIcol\fP, int \fIrow\fP); |
| 123 |
\fBint tputs(const char * \fIstr\fP, int \fIaffcnt\fP, int (* \fIputc\fP)(int)); |
| 124 |
.fi |
| 125 |
.SH DESCRIPTION |
| 126 |
.I \%ncurses |
| 127 |
provides the foregoing variables and functions as a compatibility layer |
| 128 |
for programs that use the \fItermcap\fP library. |
| 129 |
The API is the same, |
| 130 |
but behavior is emulated using the \fI\%term\%info\fP database. |
| 131 |
Thus, |
| 132 |
it can be used only to query the capabilities of terminal database |
| 133 |
entries for which a \fI\%term\%info\fP entry has been compiled. |
| 134 |
.SS Initialization |
| 135 |
\fB\%tgetent\fP loads the terminal database entry for \fIname\fP; |
| 136 |
see \fBterm\fP(7). |
| 137 |
This must be done before calling any of the other functions. |
| 138 |
It returns |
| 139 |
.RS 3 |
| 140 |
.TP 5 \" "-1" + 2n + adjust for PDF |
| 141 |
.B 1 |
| 142 |
on success, |
| 143 |
.TP |
| 144 |
.B 0 |
| 145 |
if there is no such entry |
| 146 |
(or if the matching entry describes a generic terminal, |
| 147 |
having too little information for |
| 148 |
.I curses |
| 149 |
applications to run), |
| 150 |
and |
| 151 |
.TP |
| 152 |
.B \-1 |
| 153 |
if the |
| 154 |
.I \%term\%info |
| 155 |
database could not be found. |
| 156 |
.RE |
| 157 |
.PP |
| 158 |
This implementation differs from those of historical \fItermcap\fP |
| 159 |
libraries. |
| 160 |
.bP |
| 161 |
.I \%ncurses |
| 162 |
ignores the buffer pointer \fIbp\fP, |
| 163 |
as do other \fItermcap\fP implementations conforming to portions of |
| 164 |
X/Open Curses now withdrawn. |
| 165 |
The BSD \fItermcap\fP library would store a copy of the terminal type |
| 166 |
description in the buffer referenced by this pointer. |
| 167 |
\fI\%term\%info\fP stores terminal type descriptions in compiled form, |
| 168 |
which is not the same thing. |
| 169 |
.bP |
| 170 |
The meanings of the return values differ. |
| 171 |
The BSD \fItermcap\fP library does not check whether the terminal type |
| 172 |
description includes the |
| 173 |
.B \%generic |
| 174 |
.RB ( gn ) |
| 175 |
capability, |
| 176 |
nor whether the terminal type description supports an addressable |
| 177 |
cursor, |
| 178 |
a property essential for any \fIcurses\fP implementation to operate. |
| 179 |
.SS "Retrieving Capability Values" |
| 180 |
\fB\%tgetflag\fP reports the Boolean entry for \fIid\fP, |
| 181 |
or zero if it is not available. |
| 182 |
.PP |
| 183 |
\fB\%tgetnum\fP obtains the numeric entry for \fIid\fP, |
| 184 |
or \-1 if it is not available. |
| 185 |
.PP |
| 186 |
\fB\%tgetstr\fP returns the string entry for \fIid\fP, |
| 187 |
or |
| 188 |
.I NULL |
| 189 |
if it is not available. |
| 190 |
Use \fB\%tputs\fP to output the string returned. |
| 191 |
The |
| 192 |
.I sbuf |
| 193 |
parameter is used as follows. |
| 194 |
.bP |
| 195 |
It is assumed to be the address of a pointer to a buffer managed by the |
| 196 |
calling application. |
| 197 |
.bP |
| 198 |
However, |
| 199 |
.I \%ncurses |
| 200 |
checks to ensure that |
| 201 |
.I sbuf |
| 202 |
is not |
| 203 |
.IR NULL "," |
| 204 |
and that the pointer obtained by dereferencing |
| 205 |
.I sbuf |
| 206 |
is also not |
| 207 |
.IR NULL "." |
| 208 |
If either check fails, |
| 209 |
.I \%ncurses |
| 210 |
ignores |
| 211 |
.IR sbuf . |
| 212 |
.bP |
| 213 |
If the checks succeed, |
| 214 |
\fI\%ncurses\fP also copies the return value to the buffer pointed to by |
| 215 |
\fIsbuf\fP, |
| 216 |
and the library updates |
| 217 |
.I sbuf |
| 218 |
to point past the null character terminating this value. |
| 219 |
.bP |
| 220 |
The return value itself is an address in the terminal type description |
| 221 |
loaded into memory. |
| 222 |
.SS "Applying String Capabilities" |
| 223 |
String capabilities can be parameterized; |
| 224 |
see subsection \*(``Parameterized Strings\*('' in \fB\%terminfo\fP(5). |
| 225 |
\fB\%tgoto\fP applies its second and third arguments to the parametric |
| 226 |
placeholders in the capability stored in the first argument. |
| 227 |
.bP |
| 228 |
The capability may contain padding specifications; |
| 229 |
see subsection \*(``Delays and Padding\*('' of \fB\%terminfo\fP(5). |
| 230 |
The output of \fB\%tgoto\fP should thus be passed to \fB\%tputs\fP |
| 231 |
rather than some other output function such as \fI\%printf\fP(3). |
| 232 |
.bP |
| 233 |
While \fB\%tgoto\fP is assumed to be used for the two-parameter |
| 234 |
cursor positioning capability, |
| 235 |
\fItermcap\fP applications also use it for single-parameter |
| 236 |
capabilities. |
| 237 |
.IP |
| 238 |
Doing so reveals a quirk in \fB\%tgoto\fP: |
| 239 |
most hardware terminals use cursor addressing with \fIrow\fP first, |
| 240 |
but the original developers of the \fItermcap\fP interface chose to |
| 241 |
put the \fIcol\fP (column) parameter first. |
| 242 |
The \fB\%tgoto\fP function swaps the order of its parameters. |
| 243 |
It does this even for calls requiring only a single parameter. |
| 244 |
In that case, |
| 245 |
the first parameter is merely a placeholder. |
| 246 |
.bP |
| 247 |
Normally the \fI\%ncurses\fP library is compiled without |
| 248 |
full \fI\%termcap\fP support. |
| 249 |
In that case, |
| 250 |
\fB\%tgoto\fP uses an internal version of \fB\%tparm\fP(3NCURSES) |
| 251 |
(a more capable function). |
| 252 |
.IP |
| 253 |
Because it uses \fB\%tparm\fP internally, |
| 254 |
\fB\%tgoto\fP is able to use some \fI\%term\%info\fP features, |
| 255 |
but not all. |
| 256 |
In particular, |
| 257 |
it allows only numeric parameters; |
| 258 |
\fB\%tparm\fP supports string parameters. |
| 259 |
.IP |
| 260 |
However, |
| 261 |
\fB\%tparm\fP is not a \fItermcap\fP feature, |
| 262 |
and portable \fItermcap\fP applications should not rely upon its |
| 263 |
availability. |
| 264 |
.PP |
| 265 |
\fB\%tputs\fP is described in \fB\%terminfo\fP(3NCURSES). |
| 266 |
It can retrieve capabilities by either \fItermcap\fP or |
| 267 |
\fI\%term\%info\fP code. |
| 268 |
.SS "Global Variables" |
| 269 |
.B \%tgetent |
| 270 |
sets the variables |
| 271 |
.BR PC "," |
| 272 |
.BR UP "," |
| 273 |
and |
| 274 |
.B BC |
| 275 |
to the |
| 276 |
.I \%term\%info |
| 277 |
entry's data for |
| 278 |
.B \%pad_char |
| 279 |
.RB ( pad ), |
| 280 |
.B \%cursor_up |
| 281 |
.RB ( cuu1 ), |
| 282 |
and |
| 283 |
.B \%backspace_if_not_bs |
| 284 |
.RB ( OTbs ), |
| 285 |
respectively. |
| 286 |
.I \%ncurses |
| 287 |
does not employ |
| 288 |
.B cuu1 |
| 289 |
internally. |
| 290 |
\fB\%delay_output\fP(3NCURSES) |
| 291 |
uses |
| 292 |
.BR pad "," |
| 293 |
while |
| 294 |
.B \%tgoto |
| 295 |
emulation uses the obsolete |
| 296 |
.I termcap |
| 297 |
capability |
| 298 |
.BR bs "," |
| 299 |
represented in |
| 300 |
.I \%ncurses |
| 301 |
.I \%term\%info |
| 302 |
as \*(``OTbs\*(''. |
| 303 |
.I \%ncurses |
| 304 |
assigns the variable |
| 305 |
.B \%ospeed |
| 306 |
a system-specific value to encode the terminal's data rate. |
| 307 |
.SS "Releasing Memory" |
| 308 |
The \fItermcap\fP functions provide no means of freeing memory, |
| 309 |
because legacy \fItermcap\fP implementations used only the storage |
| 310 |
provided by the caller via \fB\%tgetent\fP and \fB\%tgetstr\fP. |
| 311 |
Those buffers are unused in \fI\%term\%info\fP. |
| 312 |
.PP |
| 313 |
By contrast, |
| 314 |
\fI\%term\%info\fP allocates memory. |
| 315 |
It uses \fB\%setupterm\fP(3NCURSES) to obtain the data used by \fB\%tgetent\fP |
| 316 |
and the functions that retrieve capability values. |
| 317 |
One could use |
| 318 |
.RS |
| 319 |
.EX |
| 320 |
del_curterm(cur_term); |
| 321 |
.EE |
| 322 |
.RE |
| 323 |
to free this memory, |
| 324 |
but there is an additional complication with \fI\%ncurses\fP. |
| 325 |
It uses a fixed-size pool of storage locations, |
| 326 |
one per value of the terminal name parameter given to \fB\%tgetent\fP. |
| 327 |
The \fIscreen\fP(1) program relies upon this arrangement to improve its |
| 328 |
performance. |
| 329 |
.PP |
| 330 |
An application that uses only the \fItermcap\fP functions, |
| 331 |
not the higher-level |
| 332 |
.I \%curses |
| 333 |
API, |
| 334 |
could release the memory using \fB\%del_curterm\fP(3NCURSES), |
| 335 |
because the pool is freed using other functions; |
| 336 |
see \fB\%memleaks\fP(3NCURSES). |
| 337 |
.SH "RETURN VALUE" |
| 338 |
The return values of |
| 339 |
\fB\%tgetent\fP, |
| 340 |
\fB\%tgetflag\fP, |
| 341 |
\fB\%tgetname\fP, |
| 342 |
and |
| 343 |
\fB\%tgetstr\fP |
| 344 |
are documented above. |
| 345 |
.PP |
| 346 |
\fB\%tgoto\fP returns |
| 347 |
.I NULL |
| 348 |
on error. |
| 349 |
Error conditions include: |
| 350 |
.bP |
| 351 |
uninitialized state |
| 352 |
\%(\fBtgetent\fP was not called successfully), |
| 353 |
.bP |
| 354 |
.I cap |
| 355 |
being a null pointer, |
| 356 |
.bP |
| 357 |
.I cap |
| 358 |
referring to a canceled capability, |
| 359 |
.bP |
| 360 |
.I cap |
| 361 |
being a capability with string-valued parameters |
| 362 |
(a \fI\%term\%info\fP-only feature), |
| 363 |
and |
| 364 |
.bP |
| 365 |
.I cap |
| 366 |
being a capability with more than two parameters. |
| 367 |
.PP |
| 368 |
See \fB\%terminfo\fP(3NCURSES) regarding \fB\%tputs\fP. |
| 369 |
.SH NOTES |
| 370 |
\fI\%ncurses\fP compares only the first two characters of the \fIid\fP |
| 371 |
parameter of |
| 372 |
\fB\%tgetflag\fP, |
| 373 |
\fB\%tgetnum\fP, |
| 374 |
and |
| 375 |
\fB\%tgetstr\fP to the capability names in the database. |
| 376 |
.SH PORTABILITY |
| 377 |
These functions are no longer standardized |
| 378 |
(and the variables never were); |
| 379 |
see section \*(``HISTORY\*('' below. |
| 380 |
.I \%ncurses |
| 381 |
provides them to support legacy applications; |
| 382 |
they should not be used in new programs. |
| 383 |
.PP |
| 384 |
SVr4 describes a successful return value only as |
| 385 |
\*(``an integer value other than |
| 386 |
.IR ERR \*(''. \" Courier roman in source; SVID 4, vol. 3, p. 536 |
| 387 |
.PP |
| 388 |
Neither X/Open Curses nor the SVr4 man pages documented the return |
| 389 |
values of |
| 390 |
.I \%tgetent |
| 391 |
correctly, |
| 392 |
though all three shown here were in fact returned ever since SVr1. |
| 393 |
In particular, |
| 394 |
an omission in the X/Open Curses specification has been misinterpreted |
| 395 |
to mean that |
| 396 |
.I \%tgetent |
| 397 |
returns |
| 398 |
.I OK |
| 399 |
or |
| 400 |
.IR ERR "." |
| 401 |
Because the purpose of these functions is to provide compatibility with |
| 402 |
the |
| 403 |
.I termcap |
| 404 |
library, |
| 405 |
that is a defect in X/Open Curses Issue\ 4 Version\ 2 |
| 406 |
rather than in |
| 407 |
.IR \%ncurses "." |
| 408 |
.SS "Compatibility with BSD \fItermcap\fP" |
| 409 |
.I \%ncurses |
| 410 |
provides externally visible variables to support certain |
| 411 |
.I termcap |
| 412 |
applications. |
| 413 |
However, |
| 414 |
their correct usage is poorly documented; |
| 415 |
for example, |
| 416 |
it is unclear when reading and writing them is meaningful. |
| 417 |
In particular, |
| 418 |
some applications are reported to declare and/or modify |
| 419 |
.IR \%ospeed "." |
| 420 |
.PP |
| 421 |
The constraint that only the first two characters of the |
| 422 |
.I id |
| 423 |
parameter are looked up in the terminal database |
| 424 |
escapes many application developers. |
| 425 |
The BSD |
| 426 |
.I termcap |
| 427 |
library did not require a trailing null character |
| 428 |
after the capability identifier passed to |
| 429 |
.IR \%tgetstr "," |
| 430 |
.IR \%tgetnum "," |
| 431 |
and |
| 432 |
.IR \%tgetflag "." |
| 433 |
.\" See <https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/\ |
| 434 |
.\" termlib/termcap.c>. |
| 435 |
Some applications thus assume that the |
| 436 |
.I termcap |
| 437 |
interface does not require the trailing null character |
| 438 |
for the capability identifier. |
| 439 |
.I \%ncurses |
| 440 |
disallows matches by the |
| 441 |
.I termcap |
| 442 |
interface against extended capability names |
| 443 |
that are longer than two characters; |
| 444 |
see \fB\%user_caps\fP(5). |
| 445 |
.PP |
| 446 |
The BSD |
| 447 |
.I termcap |
| 448 |
function |
| 449 |
.I \%tgetent |
| 450 |
returns the text of a |
| 451 |
.I termcap |
| 452 |
entry in the buffer passed as an argument. |
| 453 |
.IR \%ncurses "," |
| 454 |
like other |
| 455 |
.I \%term\%info |
| 456 |
implementations, |
| 457 |
does not store terminal type descriptions as text. |
| 458 |
It sets the buffer contents to a null-terminated string. |
| 459 |
.SS "Header File" |
| 460 |
.I \%ncurses |
| 461 |
includes a |
| 462 |
.I \%termcap.h |
| 463 |
header file for compatibility with other implementations, |
| 464 |
but it is rarely used because the other implementations |
| 465 |
are not mutually compatible; |
| 466 |
see below. |
| 467 |
.SH HISTORY |
| 468 |
.\" See https://www.oreilly.com/openbook/opensources/book/kirkmck.html |
| 469 |
.\" for much BSD release history. |
| 470 |
Bill Joy originated a forerunner of |
| 471 |
.I termcap |
| 472 |
called \*(``ttycap\*('', |
| 473 |
dated September 1977, |
| 474 |
and released in 1BSD |
| 475 |
(March 1978). |
| 476 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s7/ttycap.c |
| 477 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/man7/ttycap.7 |
| 478 |
It used many of the same function names as the later |
| 479 |
.IR termcap "," |
| 480 |
such as |
| 481 |
.IR \%tgetent "," |
| 482 |
.IR \%tgetflag "," |
| 483 |
.IR \%tgetnum "," |
| 484 |
and |
| 485 |
.IR \%tgetstr "." |
| 486 |
.PP |
| 487 |
A clear descendant, |
| 488 |
the |
| 489 |
.I termlib |
| 490 |
library, |
| 491 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/termlib/ |
| 492 |
followed in 2BSD |
| 493 |
(May 1979), |
| 494 |
adding |
| 495 |
.I \%tgoto |
| 496 |
and |
| 497 |
.IR \%tputs "." |
| 498 |
The former applied at that time only to cursor positioning capabilities, |
| 499 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/bin/etc/termcap |
| 500 |
thus the overly specific name. |
| 501 |
Little changed in 3BSD |
| 502 |
(late 1979) |
| 503 |
except the addition of test programs and a |
| 504 |
.I termlib |
| 505 |
man page, |
| 506 |
which documented the API shown in section \*(``SYNOPSIS\*('' above. |
| 507 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/lib/\ |
| 508 |
.\" libtermlib/ |
| 509 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/man/man3/\ |
| 510 |
.\" termlib.3 |
| 511 |
.PP |
| 512 |
4BSD (November 1980) |
| 513 |
renamed |
| 514 |
.I termlib |
| 515 |
to |
| 516 |
.I termcap |
| 517 |
.\" ...except in the source tree... |
| 518 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\ |
| 519 |
.\" libtermlib/makefile |
| 520 |
and added another test program. |
| 521 |
The library remained much the same through 4.3BSD |
| 522 |
(June 1986). |
| 523 |
4.4BSD-Lite |
| 524 |
(June 1994) |
| 525 |
refactored it, |
| 526 |
.\" Observe the `tncktc()`, `tnamatch()`, `tskip()`, and `tdecode()` |
| 527 |
.\" entry points disappearing from termcap.c. |
| 528 |
leaving the API unchanged. |
| 529 |
.PP |
| 530 |
Function prototypes were a feature of ANSI C (1989). |
| 531 |
The library long antedated the standard and thus provided no header file |
| 532 |
declaring them. |
| 533 |
Nevertheless, |
| 534 |
the BSD sources included two different |
| 535 |
.I \%termcap.h |
| 536 |
header files over time. |
| 537 |
.bP |
| 538 |
One was used internally by \fIjove\fP(1) from 4.3BSD onward. |
| 539 |
.\" 2BSD became a branch retaining support for non-virtual memory |
| 540 |
.\" systems (such as the PDP-11) whereas most BSD development focused on |
| 541 |
.\" the VAX and other VM-enabled systems starting with 3BSD. |
| 542 |
.\" |
| 543 |
.\" This man page previously located a termcap.h in 2BSD, but that may |
| 544 |
.\" be confusion arising from its backport to 2.9BSD (and still present |
| 545 |
.\" in surviving sources for 2.11BSD, the "end of the line" for that |
| 546 |
.\" branch's development). |
| 547 |
.\" |
| 548 |
.\" Observe the copyright notice in |
| 549 |
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD/usr/contrib/\ |
| 550 |
.\" jove/Makefile |
| 551 |
.\" --much too late for 2BSD (1979). |
| 552 |
It declared global symbols for the |
| 553 |
.I termcap |
| 554 |
variables that it used. |
| 555 |
.bP |
| 556 |
The other appeared in 4.4BSD-Lite Release 2 |
| 557 |
(June 1995) |
| 558 |
as part of |
| 559 |
.I libedit |
| 560 |
(also known as the |
| 561 |
.I \%edit\%line |
| 562 |
library). |
| 563 |
CSRG source history shows that this was added in mid-1992. |
| 564 |
The |
| 565 |
.I libedit |
| 566 |
header file was used internally as a convenience |
| 567 |
for compiling the |
| 568 |
.I \%edit\%line |
| 569 |
library. |
| 570 |
It declared function prototypes, |
| 571 |
but no global variables. |
| 572 |
NetBSD's |
| 573 |
.I termcap |
| 574 |
library added this header file in mid-1994. |
| 575 |
.PP |
| 576 |
Meanwhile, |
| 577 |
GNU |
| 578 |
.I termcap |
| 579 |
began development in 1990. |
| 580 |
Its first release (1.0) in 1991 included a |
| 581 |
.I \%termcap.h |
| 582 |
header file. |
| 583 |
Its second (1.1) release in September 1992 modified the file to use |
| 584 |
.I const |
| 585 |
for the function prototypes in the header where one would |
| 586 |
expect parameters to be read-only. |
| 587 |
BSD |
| 588 |
.I termcap |
| 589 |
did not. |
| 590 |
The prototype for |
| 591 |
.I \%tputs |
| 592 |
also differed, |
| 593 |
but in that instance, |
| 594 |
it was |
| 595 |
.I libedit |
| 596 |
that differed from BSD |
| 597 |
.IR termcap "." |
| 598 |
.PP |
| 599 |
GNU \fIbash\fP(1) has bundled GNU |
| 600 |
.I termcap |
| 601 |
1.3 since mid-1993 to support its \fI\%readline\fP(3) library, |
| 602 |
and continues to use it if configured to do so. |
| 603 |
.PP |
| 604 |
.I \%ncurses |
| 605 |
1.8.1 |
| 606 |
(November 1993) |
| 607 |
provided a |
| 608 |
.I \%termcap.h |
| 609 |
file. |
| 610 |
It reflected influence from GNU |
| 611 |
.I termcap |
| 612 |
and \fI\%emacs\fP(1) |
| 613 |
(rather than \fIjove\fP(1)), |
| 614 |
providing the following interface: |
| 615 |
.bP |
| 616 |
global symbols used by |
| 617 |
.IR \%emacs "," |
| 618 |
.bP |
| 619 |
.IR const -qualified |
| 620 |
function prototypes, |
| 621 |
and |
| 622 |
.bP |
| 623 |
a prototype for |
| 624 |
.IR tparam "," |
| 625 |
a GNU |
| 626 |
.I termcap |
| 627 |
feature. |
| 628 |
.PP |
| 629 |
Later |
| 630 |
(in mid-1996) |
| 631 |
the |
| 632 |
.I tparam |
| 633 |
function was removed from |
| 634 |
.IR \%ncurses "." |
| 635 |
Any two of the four implementations thus differ, |
| 636 |
and programs that intend to work with all |
| 637 |
.I termcap |
| 638 |
library interfaces must account for that fact. |
| 639 |
.PP |
| 640 |
X/Open Curses Issue\ 4, |
| 641 |
Version\ 2 (1996), |
| 642 |
describes these functions, |
| 643 |
marking them as |
| 644 |
\*(``TO BE WITHDRAWN\*(''. |
| 645 |
.PP |
| 646 |
X/Open Curses Issue\ 7 (2009) withdrew the |
| 647 |
.I termcap |
| 648 |
interface |
| 649 |
(along with the |
| 650 |
.I \%vwprintw |
| 651 |
and |
| 652 |
.I \%vwscanw |
| 653 |
functions). |
| 654 |
.SH BUGS |
| 655 |
If you call \fB\%tgetstr\fP to fetch |
| 656 |
.B \%column_address |
| 657 |
.RB ( ch ) |
| 658 |
or any other parameterized string capability, |
| 659 |
be aware that it is returned in \fI\%term\%info\fP notation, |
| 660 |
not the older and not-quite-compatible \fItermcap\fP notation. |
| 661 |
This does not cause problems if all you do with it is call \fB\%tgoto\fP |
| 662 |
or \fB\%tparm\fP, |
| 663 |
which both parametrically expand \fI\%term\%info\fP-style string |
| 664 |
capabilities as \fI\%term\%info\fP does. |
| 665 |
(If |
| 666 |
.I \%ncurses |
| 667 |
is configured to support \fItermcap,\fP |
| 668 |
\fB\%tgoto\fP checks whether the string is \fI\%term\%info\fP-style by |
| 669 |
looking for \*(``\fB%p\fP\*('' parameters or |
| 670 |
\*(``\fB<\fP.\|.\|.\fB>\fP\*('' delays, |
| 671 |
and invokes a \fItermcap\fP-style parser if the string appears not to |
| 672 |
use \fI\%term\%info\fP syntax.) |
| 673 |
.PP |
| 674 |
Because \fI\%term\%info\fP's syntax for padding in string capabilities |
| 675 |
differs from \fItermcap\fP's, |
| 676 |
users can be surprised. |
| 677 |
.IP \(bu 4 |
| 678 |
\fB\%tputs("50")\fP in a \fI\%term\%info\fP system transmits |
| 679 |
\*(``50\*('' rather than busy-waiting for 50 milliseconds. |
| 680 |
.IP |
| 681 |
However, |
| 682 |
if \fI\%ncurses\fP is configured to support \fItermcap\fP, |
| 683 |
it may also have been configured to support BSD-style padding. |
| 684 |
In that case, |
| 685 |
\fB\%tputs\fP inspects strings passed to it, |
| 686 |
looking for digits at the beginning of the string. |
| 687 |
.IP \(bu 4 |
| 688 |
\fB\%tputs("50")\fP in a \fItermcap\fP system may busy-wait for 50 |
| 689 |
milliseconds rather than transmitting \*(``50\*(''. |
| 690 |
.PP |
| 691 |
\fItermcap\fP has nothing analogous to \fI\%term\%info\fP's |
| 692 |
.B \%set_attributes |
| 693 |
.RB ( sgr ) |
| 694 |
capability. |
| 695 |
One consequence is that \fItermcap\fP applications assume that |
| 696 |
.RB \*(`` me \*('' |
| 697 |
(equivalent to \fI\%term\%info\fP's |
| 698 |
.B \%exit_attribute_mode |
| 699 |
.RB ( sgr0 ) |
| 700 |
capability) |
| 701 |
does not reset the alternate character set. |
| 702 |
\fI\%ncurses\fP inspects the data shared with the |
| 703 |
.I termcap |
| 704 |
interface and modifies it as necessary |
| 705 |
to accommodate the latter's limitation in this respect. |
| 706 |
.SH "SEE ALSO" |
| 707 |
.UR https://\*:invisible\-\*:island\*:.net/\*:ncurses/\*:tctest\*:.html |
| 708 |
.I "TCTEST \(em A Termcap Test Utility" |
| 709 |
.UE |
| 710 |
.PP |
| 711 |
\fB\%ncurses\fP(3NCURSES), |
| 712 |
\fB\%terminfo\fP(3NCURSES), |
| 713 |
\fB\%putc\fP(3), |
| 714 |
\fB\%terminfo_variables\fP(3NCURSES), |
| 715 |
\fB\%terminfo\fP(5) |