BSD 3 development
[unix-history] / usr / man / man3 / termlib.3
CommitLineData
053b7e7b
BJ
1.TH TERMLIB 3 10/22/79 3
2.UC
3.SH NAME
4tgetent, tgetnum, tgetflag, tgetstr, tgoto, tputs \- terminal independent operation routines
5.SH SYNOPSIS
6.nf
7.DT
8\fBchar PC;
9char *BC;
10char *UP;
11short ospeed;
12
13tgetent(bp, name)
14char *bp, *name;
15
16tgetnum(id)
17char *id;
18
19tgetflag(id)
20char *id;
21
22char *
23tgetstr(id, area)
24char *id, **area;
25
26char *
27tgoto(cm, destcol, destline)
28char *cm;
29
30tputs(cp, affcnt, outc)
31register char *cp;
32int affcnt;
33int (*outc)();\fP
34.fi
35.SH DESCRIPTION
36These functions extract and use capabilities from the terminal capability data
37base
38.IR termcap (5).
39.PP
40.I Tgetent
41extracts the entry for terminal
42.I name
43into the buffer at
44.I bp.
45.I Bp
46should be a character buffer of size
471024 and must be retained through all subsequent calls
48to
49.I tgetnum,
50.I tgetflag,
51and
52.I tgetstr.
53.I Tgetent
54returns \-1 if it cannot open the
55.I termcap
56file, 0 if the terminal name given does not have an entry,
57and 1 if all goes well.
58It will look in the environment for a TERMCAP variable.
59If found, and the value does not begin with a slash,
60and the terminal type
61.B name
62is the same as the environment string TERM,
63the TERMCAP string is used instead of reading the termcap file.
64If it does begin with a slash, the string is used as a path name rather than
65.I /etc/termcap.
66This can speed up entry into programs that call
67.IR tgetent ,
68as well as to help debug new terminal descriptions
69or to make one for your terminal if you can't write the file
70.I /etc/termcap.
71.PP
72.I Tgetnum
73gets the numeric value of capability
74.I id,
75returning \-1 if is not given for the terminal.
76.I Tgetflag
77returns 1 if the specified capability is present in
78the terminal's entry, 0 if it is not.
79.I Tgetstr
80gets the string value of capability
81.I id,
82placing it in the buffer at
83.I area,
84advancing the
85.I area
86pointer.
87It decodes the abbreviations for this field described in
88.IR termcap (5),
89except for cursor addressing and padding information.
90.PP
91.I Tgoto
92returns a cursor addressing string decoded from
93.I cm
94to go to column
95.I destcol
96in line
97.I destline.
98It uses the external variables
99.B UP
100(from the \fBup\fR capability)
101and
102.B BC
103(if \fBbc\fR is given rather than \fBbs\fR)
104if necessary to avoid placing \fB\et\fR, \fB\en\fR, \fB^D\fR or \fB^@\fR in
105the returned string.
106If a \fB%\fR sequence is given which is not understood, then
107.I tgoto
108returns ``OOPS''.
109.PP
110.I Tputs
111decodes the leading padding information of the string
112.I cp;
113.I affcnt
114gives the number of lines affected by the operation, or 1 if this is
115not applicable,
116.I outc
117is a routine which is called with each character in turn.
118The external variable
119.I ospeed
120should contain the output speed of the terminal as encoded by
121.I stty (2).
122The external variable
123.B PC
124should contain a pad character to be used (from the \fBpc\fR capability)
125if a null (\fB^@\fR) is inappropriate.
126.SH FILES
127.DT
128/usr/lib/libtermlib.a \-ltermlib library
129.br
130/etc/termcap data base
131.SH SEE ALSO
132ex (1), termcap (5)
133.SH AUTHOR
134William Joy
135.br
136Mark Horton
137.SH BUGS
138The terminal independent cursor motion optimization routines of
139.I ex
140should be placed in the library also,
141as well as a more straightforward user interface.