1curs_termcap(3X)                                              curs_termcap(3X)
2
3
4

NAME

6       PC, UP, BC, ospeed, tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs -
7       curses emulation of termcap
8

SYNOPSIS

10       #include <curses.h>
11       #include <term.h>
12
13       extern char PC;
14       extern char * UP;
15       extern char * BC;
16       extern unsigned ospeed;
17
18       int tgetent(char *bp, const char *name);
19       int tgetflag(const char *id);
20       int tgetnum(const char *id);
21       char *tgetstr(const char *id, char **area);
22       char *tgoto(const char *cap, int col, int row);
23       int tputs(const char *str, int affcnt, int (*putc)(int));
24

DESCRIPTION

26       These routines are included as a conversion aid for programs  that  use
27       the  termcap  library.  Their parameters are the same, but the routines
28       are emulated using the terminfo database.  Thus, they can only be  used
29       to  query  the  capabilities  of entries for which a terminfo entry has
30       been compiled.
31
32   INITIALIZATION
33       The tgetent routine loads the entry for name.  It returns:
34
35          1  on success,
36
37          0  if there is no such entry (or that it is a generic  type,  having
38             too little information for curses applications to run), and
39
40          -1 if the terminfo database could not be found.
41
42       This differs from the termcap library in two ways:
43
44          •   The  emulation  ignores  the buffer pointer bp.  The termcap li‐
45              brary would store a copy of the terminal description in the area
46              referenced  by this pointer.  However, ncurses stores its termi‐
47              nal descriptions in compiled binary form, which is not the  same
48              thing.
49
50          •   There is a difference in return codes.  The termcap library does
51              not check if the terminal description is marked with the generic
52              capability,  or  if the terminal description has cursor-address‐
53              ing.
54
55   CAPABILITY VALUES
56       The tgetflag routine gets the boolean entry for id, or zero  if  it  is
57       not available.
58
59       The  tgetnum  routine gets the numeric entry for id, or -1 if it is not
60       available.
61
62       The tgetstr routine returns the string entry for id, or zero if  it  is
63       not  available.  Use tputs to output the returned string.  The area pa‐
64       rameter is used as follows:
65
66          •   It is assumed to be the address of a pointer to a buffer managed
67              by the calling application.
68
69          •   However, ncurses checks to ensure that area is not NULL, and al‐
70              so that the resulting buffer pointer is  not  NULL.   If  either
71              check fails, the area parameter is ignored.
72
73          •   If  the  checks succeed, ncurses also copies the return value to
74              the buffer pointed to by area, and the area value will be updat‐
75              ed to point past the null ending this value.
76
77          •   The  return  value itself is an address in the terminal descrip‐
78              tion which is loaded into memory.
79
80       Only the first two characters of the id parameter of tgetflag,  tgetnum
81       and tgetstr are compared in lookups.
82
83   FORMATTING CAPABILITIES
84       The tgoto routine expands the given capability using the parameters.
85
86       •   Because  the  capability may have padding characters, the output of
87           tgoto should be passed to tputs rather than some other output func‐
88           tion such as printf.
89
90       •   While  tgoto is assumed to be used for the two-parameter cursor po‐
91           sitioning capability, termcap applications also use it for  single-
92           parameter capabilities.
93
94           Doing this shows a quirk in tgoto: most hardware terminals use cur‐
95           sor addressing with row first, but the original developers  of  the
96           termcap  interface  chose  to  put the column parameter first.  The
97           tgoto function swaps the order of parameters.  It  does  this  also
98           for  calls  requiring  only  a single parameter.  In that case, the
99           first parameter is merely a placeholder.
100
101       •   Normally the ncurses library is compiled with terminfo support.  In
102           that case, tgoto uses tparm(3X) (a more capable formatter).
103
104           However,  tparm  is not a termcap feature, and portable termcap ap‐
105           plications should not rely upon its availability.
106
107       The tputs routine is described on the  curs_terminfo(3X)  manual  page.
108       It can retrieve capabilities by either termcap or terminfo name.
109
110   GLOBAL VARIABLES
111       The  variables PC, UP and BC are set by tgetent to the terminfo entry's
112       data for pad_char, cursor_up and backspace_if_not_bs, respectively.  UP
113       is  not used by ncurses.  PC is used in the tdelay_output function.  BC
114       is used in the tgoto emulation.  The variable ospeed is set by  ncurses
115       in a system-specific coding to reflect the terminal speed.
116

RETURN VALUE

118       Except  where  explicitly noted, routines that return an integer return
119       ERR upon failure and OK (SVr4 only specifies "an  integer  value  other
120       than ERR") upon successful completion.
121
122       Routines that return pointers return NULL on error.
123

BUGS

125       If  you  call tgetstr to fetch ca or any other parameterized string, be
126       aware that it will be returned in terminfo notation, not the older  and
127       not-quite-compatible termcap notation.  This will not cause problems if
128       all you do with it is call tgoto or tparm, which both expand  terminfo-
129       style  strings as terminfo.  (The tgoto function, if configured to sup‐
130       port termcap, will check if the  string  is  indeed  terminfo-style  by
131       looking  for  "%p"  parameters or "$<..>" delays, and invoke a termcap-
132       style parser if the string does not appear to be terminfo).
133
134       Because terminfo conventions for representing padding in  string  capa‐
135       bilities differ from termcap's, users can be surprised:
136
137tputs("50") in a terminfo system will put out a literal “50” rather
138           than busy-waiting for 50 milliseconds.
139
140       •   However, if ncurses is configured to support termcap, it  may  also
141           have been configured to support the BSD-style padding.
142
143           In that case, tputs inspects strings passed to it, looking for dig‐
144           its at the beginning of the string.
145
146           tputs("50") in a termcap system may wait for 50 milliseconds rather
147           than put out a literal “50”
148
149       Note  that termcap has nothing analogous to terminfo's sgr string.  One
150       consequence of this is that termcap applications  assume  me  (terminfo
151       sgr0)  does not reset the alternate character set.  This implementation
152       checks for, and modifies the data shown to the termcap interface to ac‐
153       commodate termcap's limitation in this respect.
154

PORTABILITY

156   Standards
157       These  functions  are  provided for supporting legacy applications, and
158       should not be used in new programs:
159
160       •   The XSI Curses standard, Issue 4 describes these functions.  Howev‐
161           er,  they  are  marked TO BE WITHDRAWN and may be removed in future
162           versions.
163
164       •   X/Open Curses, Issue 5 (December 2007) marked the termcap interface
165           (along with vwprintw and vwscanw) as withdrawn.
166
167       Neither  the  XSI Curses standard nor the SVr4 man pages documented the
168       return values of tgetent correctly, though all three were in  fact  re‐
169       turned  ever  since SVr1.  In particular, an omission in the XSI Curses
170       documentation has been misinterpreted to mean that tgetent  returns  OK
171       or  ERR.  Because the purpose of these functions is to provide compati‐
172       bility with the termcap library, that is a defect in XCurses, Issue  4,
173       Version 2 rather than in ncurses.
174
175   Compatibility with BSD Termcap
176       External variables are provided for support of certain termcap applica‐
177       tions.  However, termcap applications' use of those variables is poorly
178       documented, e.g., not distinguishing between input and output.  In par‐
179       ticular, some applications are reported to declare  and/or  modify  os‐
180       peed.
181
182       The  comment that only the first two characters of the id parameter are
183       used escapes many application developers.  The original BSD 4.2 termcap
184       library (and historical relics thereof) did not require a trailing null
185       NUL on the parameter name passed  to  tgetstr,  tgetnum  and  tgetflag.
186       Some  applications  assume  that the termcap interface does not require
187       the trailing NUL for the parameter name.  Taking into account these is‐
188       sues:
189
190       •   As  a  special  case,  tgetflag  matched against a single-character
191           identifier provided that was at the end of  the  terminal  descrip‐
192           tion.  You should not rely upon this behavior in portable programs.
193           This implementation disallows matches against single-character  ca‐
194           pability names.
195
196       •   This  implementation  disallows  matches  by  the termcap interface
197           against extended capability names which are longer than two charac‐
198           ters.
199
200       The BSD termcap function tgetent returns the text of a termcap entry in
201       the buffer passed as an argument.  This library  (like  other  terminfo
202       implementations) does not store terminal descriptions as text.  It sets
203       the buffer contents to a null-terminated string.
204
205   Other Compatibility
206       This library includes a termcap.h header, for compatibility with  other
207       implementations.   But  the header is rarely used because the other im‐
208       plementations are not strictly compatible.
209
210       The original BSD termcap (through 4.3BSD) had no header file which gave
211       function prototypes, because that was a feature of ANSI C.  BSD termcap
212       was written several years before C was  standardized.   However,  there
213       were two different termcap.h header files in the BSD sources:
214
215       •   One  was used internally by the jove editor in 2BSD through 4.4BSD.
216           It defined global symbols for the termcap variables which it used.
217
218       •   The other appeared in 4.4BSD Lite Release 2 (mid-1993) as  part  of
219           libedit (also known as the editline library).  The CSRG source his‐
220           tory shows that this was added in  mid-1992.   The  libedit  header
221           file  was used internally, as a convenience for compiling the edit‐
222           line library.  It declared function prototypes, but no global vari‐
223           ables.
224
225       The  header  file from libedit was added to NetBSD's termcap library in
226       mid-1994.
227
228       Meanwhile, GNU termcap was under development, starting  in  1990.   The
229       first  release  (termcap 1.0) in 1991 included a termcap.h header.  The
230       second release (termcap 1.1) in September 1992 modified the  header  to
231       use const for the function prototypes in the header where one would ex‐
232       pect the parameters to be read-only.  This was a difference versus  the
233       original  BSD  termcap.   The prototype for tputs also differed, but in
234       that instance, it was libedit which differed from BSD termcap.
235
236       A copy of GNU termcap 1.3 was bundled with bash in mid-1993, to support
237       the readline library.
238
239       A  termcap.h  file was provided in ncurses 1.8.1 (November 1993).  That
240       reflected influence by emacs (rather than jove) and GNU termcap:
241
242       •   it provided declarations for a few global symbols used by emacs
243
244       •   it provided function prototypes (using const).
245
246       •   a prototype for tparam (a GNU termcap feature) was provided.
247
248       Later (in mid-1996) the tparam function was removed from ncurses.  As a
249       result,  there are differences between any of the four implementations,
250       which must be taken into account by programs which can  work  with  all
251       termcap library interfaces.
252

SEE ALSO

254       curses(3X), putc(3), term_variables(3X), terminfo(5).
255
256       https://invisible-island.net/ncurses/tctest.html
257
258
259
260                                                              curs_termcap(3X)
Impressum