1curs_termcap(3X) curs_termcap(3X)
2
3
4
6 tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs - direct curses
7 interface to the terminfo capability database
8
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
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 The tgetent routine loads the entry for name. It returns 1 on success,
33 0 if there is no such entry, and -1 if the terminfo database could not
34 be found. The emulation ignores the buffer pointer bp.
35
36 The tgetflag routine gets the boolean entry for id, or zero if it is
37 not available.
38
39 The tgetnum routine gets the numeric entry for id, or -1 if it is not
40 available.
41
42 The tgetstr routine returns the string entry for id, or zero if it is
43 not available. Use tputs to output the returned string. The return
44 value will also be copied to the buffer pointed to by area, and the
45 area value will be updated to point past the null ending this value.
46
47 Only the first two characters of the id parameter of tgetflag, tgetnum
48 and tgetstr are compared in lookups.
49
50 The tgoto routine instantiates the parameters into the given capabil‐
51 ity. The output from this routine is to be passed to tputs.
52
53 The tputs routine is described on the curs_terminfo(3X) manual page.
54 It can retrieve capabilities by either termcap or terminfo name.
55
56 The variables PC, UP and BC are set by tgetent to the terminfo entry's
57 data for pad_char, cursor_up and backspace_if_not_bs, respectively. UP
58 is not used by ncurses. PC is used in the tdelay_output function. BC
59 is used in the tgoto emulation. The variable ospeed is set by ncurses
60 in a system-specific coding to reflect the terminal speed.
61
63 Except where explicitly noted, routines that return an integer return
64 ERR upon failure and OK (SVr4 only specifies "an integer value other
65 than ERR") upon successful completion.
66
67 Routines that return pointers return NULL on error.
68
70 If you call tgetstr to fetch ca or any other parameterized string, be
71 aware that it will be returned in terminfo notation, not the older and
72 not-quite-compatible termcap notation. This will not cause problems if
73 all you do with it is call tgoto or tparm, which both expand terminfo-
74 style strings as terminfo. (The tgoto function, if configured to sup‐
75 port termcap, will check if the string is indeed terminfo-style by
76 looking for "%p" parameters or "$<..>" delays, and invoke a termcap-
77 style parser if the string does not appear to be terminfo).
78
79 Because terminfo conventions for representing padding in string capa‐
80 bilities differ from termcap's, tputs("50"); will put out a literal
81 "50" rather than busy-waiting for 50 milliseconds. Cope with it.
82
83 Note that termcap has nothing analogous to terminfo's sgr string. One
84 consequence of this is that termcap applications assume me (terminfo
85 sgr0) does not reset the alternate character set. This implementation
86 checks for, and modifies the data shown to the termcap interface to
87 accommodate termcap's limitation in this respect.
88
90 The XSI Curses standard, Issue 4 describes these functions. However,
91 they are marked TO BE WITHDRAWN and may be removed in future versions.
92
93 Neither the XSI Curses standard nor the SVr4 man pages documented the
94 return values of tgetent correctly, though all three were in fact
95 returned ever since SVr1. In particular, an omission in the XSI Curses
96 documentation has been misinterpreted to mean that tgetent returns OK
97 or ERR. Because the purpose of these functions is to provide compati‐
98 bility with the termcap library, that is a defect in XCurses, Issue 4,
99 Version 2 rather than in ncurses.
100
101 External variables are provided for support of certain termcap applica‐
102 tions. However, termcap applications' use of those variables is poorly
103 documented, e.g., not distinguishing between input and output. In par‐
104 ticular, some applications are reported to declare and/or modify
105 ospeed.
106
108 curses(3X), terminfo(5), putc(3).
109
110
111
112 curs_termcap(3X)