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

NAME

6       PC, UP, BC, ospeed, tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs -
7       direct curses interface to the terminfo capability database
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(char *id);
20       int tgetnum(char *id);
21       char *tgetstr(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 and 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,  tputs("50"); will put out a literal
136       "50" rather than busy-waiting for 50 milliseconds.  Cope with it.
137
138       Note that termcap has nothing analogous to terminfo's sgr string.   One
139       consequence  of  this  is that termcap applications assume me (terminfo
140       sgr0) does not reset the alternate character set.  This  implementation
141       checks for, and modifies the data shown to the termcap interface to ac‐
142       commodate termcap's limitation in this respect.
143

PORTABILITY

145       The XSI Curses standard, Issue 4 describes these  functions.   However,
146       they are marked TO BE WITHDRAWN and may be removed in future versions.
147
148       Neither  the  XSI Curses standard nor the SVr4 man pages documented the
149       return values of tgetent correctly, though all three were in  fact  re‐
150       turned  ever  since SVr1.  In particular, an omission in the XSI Curses
151       documentation has been misinterpreted to mean that tgetent  returns  OK
152       or  ERR.  Because the purpose of these functions is to provide compati‐
153       bility with the termcap library, that is a defect in XCurses, Issue  4,
154       Version 2 rather than in ncurses.
155
156       External variables are provided for support of certain termcap applica‐
157       tions.  However, termcap applications' use of those variables is poorly
158       documented, e.g., not distinguishing between input and output.  In par‐
159       ticular, some applications are reported to declare  and/or  modify  os‐
160       peed.
161
162       The  comment that only the first two characters of the id parameter are
163       used escapes many application developers.  The original BSD 4.2 termcap
164       library (and historical relics thereof) did not require a trailing null
165       NUL on the parameter name passed  to  tgetstr,  tgetnum  and  tgetflag.
166       Some  applications  assume  that the termcap interface does not require
167       the trailing NUL for the parameter name.  Taking into account these is‐
168       sues:
169
170       ·   As  a  special  case,  tgetflag  matched against a single-character
171           identifier provided that was at the end of  the  terminal  descrip‐
172           tion.  You should not rely upon this behavior in portable programs.
173           This implementation disallows matches against single-character  ca‐
174           pability names.
175
176       ·   This  implementation  disallows  matches  by  the termcap interface
177           against extended capability names which are longer than two charac‐
178           ters.
179

SEE ALSO

181       curses(3X), terminfo(5), term_variables(3X), putc(3).
182
183       https://invisible-island.net/ncurses/tctest.html
184
185
186
187                                                              curs_termcap(3X)
Impressum