]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tput.1
ncurses 5.4
[ncurses.git] / man / tput.1
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright (c) 1998-2002,2003 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: tput.1,v 1.20 2003/05/11 00:32:53 tom Exp $
31 .TH tput 1 ""
32 .ds d @TERMINFO@
33 .ds n 1
34 .SH NAME
35 \fBtput\fR, \fBreset\fR - initialize a terminal or query terminfo database
36 .SH SYNOPSIS
37 \fBtput\fR [\fB\-T\fR\fItype\fR] \fIcapname\fR [\fIparms\fR ... ]
38 .br
39 \fBtput\fR [\fB\-T\fR\fItype\fR] \fBinit\fR
40 .br
41 \fBtput\fR [\fB\-T\fR\fItype\fR] \fBreset\fR
42 .br
43 \fBtput\fR [\fB\-T\fR\fItype\fR] \fBlongname\fR
44 .br
45 \fBtput \-S\fR  \fB<<\fR
46 .br
47 \fBtput \-V\fR
48 .br
49 .SH DESCRIPTION
50 The \fBtput\fR utility uses the \fBterminfo\fR database to make the
51 values of terminal-dependent capabilities and information available to
52 the shell (see \fBsh\fR(1)), to initialize or reset the terminal, or
53 return the long name of the requested terminal type.  \fBtput\fR
54 outputs a string if the attribute (\fIcap\fRability \fIname\fR) is of
55 type string, or an integer if the attribute is of type integer.  If
56 the attribute is of type boolean, \fBtput\fR simply sets the exit code
57 (\fB0\fR for TRUE if the terminal has the capability, \fB1\fR for
58 FALSE if it does not), and produces no output.  Before using a value
59 returned on standard output, the user should test the exit code
60 [\fB$?\fR, see \fBsh\fR(1)] to be sure it is \fB0\fR.
61 (See the \fBEXIT CODES\fR and \fBDIAGNOSTICS\fR sections.)
62 For a complete list of capabilities
63 and the \fIcapname\fR associated with each, see \fBterminfo\fR(\*n).
64 .TP
65 \fB\-T\fR\fItype\fR
66 indicates the \fItype\fR of terminal.  Normally this option is
67 unnecessary, because the default is taken from the environment
68 variable \fBTERM\fR.  If \fB\-T\fR is specified, then the shell
69 variables \fBLINES\fR and \fBCOLUMNS\fR will be ignored,and the
70 operating system will not be queried for the actual screen size.
71 .TP
72 \fIcapname\fR
73 indicates the attribute from the \fBterminfo\fR database.  When
74 \fBtermcap\fR support is compiled in, the \fBtermcap\fR name for
75 the attribute is also accepted.
76 .TP
77 \fIparms\fR
78 If the attribute is a string that takes parameters, the arguments
79 \fIparms\fR will be instantiated into the string.
80 An all-numeric argument will be passed to the attribute as a number.
81 .IP
82 Only a few terminfo capabilities require string parameters;
83 \fBtput\fR uses a table to decide which to pass as strings.
84 Normally \fBtput\fR uses \fBtparm\fR (3X) to perform the substitution.
85 If no parameters are given for the attribute,
86 \fBtput\fR writes the string without performing the substitution.
87 .TP
88 \fB\-S\fR
89 allows more than one capability per invocation of \fBtput\fR.  The
90 capabilities must be passed to \fBtput\fR from the standard input
91 instead of from the command line (see example).
92 Only one \fIcapname\fR is allowed per line.
93 The \fB\-S\fR option changes the
94 meaning of the \fB0\fR and \fB1\fR boolean and string exit codes (see the
95 EXIT CODES section).
96 .IP
97 Again, \fBtput\fR uses a table and the presence of parameters in its input
98 to decide whether to use \fBtparm\fR (3X),
99 and how to interpret the parameters.
100 .TP
101 \fB\-V\fR
102 reports the version of ncurses which was used in this program, and exits.
103 .TP
104 \fBinit\fR
105 If the \fBterminfo\fR database is present and an entry for the user's
106 terminal exists (see \fB\-T\fR\fItype\fR, above), the following will
107 occur: (1) if present, the terminal's initialization strings will be
108 output (\fBis1\fR, \fBis2\fR, \fBis3\fR, \fBif\fR, \fBiprog\fR), (2)
109 any delays (e.g., newline) specified in the entry will be set in the
110 tty driver, (3) tabs expansion will be turned on or off according to
111 the specification in the entry, and (4) if tabs are not expanded,
112 standard tabs will be set (every 8 spaces).  If an entry does not
113 contain the information needed for any of the four above activities,
114 that activity will silently be skipped.
115 .TP
116 \fBreset\fR
117 Instead of putting out initialization strings, the terminal's
118 reset strings will be output if present (\fBrs1\fR, \fBrs2\fR, \fBrs3\fR, \fBrf\fR).
119 If the reset strings are not present, but initialization
120 strings are, the initialization strings will be output.
121 Otherwise, \fBreset\fR acts identically to \fBinit\fR.
122 .TP
123 \fBlongname\fR
124 If the \fBterminfo\fR database is present and an entry for the
125 user's terminal exists (see \fB\-T\fR\fItype\fR above), then the long name
126 of the terminal will be put out.  The long name is the last
127 name in the first line of the terminal's description in the
128 \fBterminfo\fR database [see \fBterm\fR(5)].
129 .PP
130 If \fBtput\fR is invoked by a link named \fBreset\fR, this has the
131 same effect as \fBtput reset\fR.
132 See \fBtset\fR for comparison, which has similar behavior.
133 .SH EXAMPLES
134 .TP 5
135 \fBtput init\fR
136 Initialize the terminal according to the type of
137 terminal in the environmental variable \fBTERM\fR.  This
138 command should be included in everyone's .profile after
139 the environmental variable \fBTERM\fR has been exported, as
140 illustrated on the \fBprofile\fR(5) manual page.
141 .TP 5
142 \fBtput \-T5620 reset\fR
143 Reset an AT&T 5620 terminal, overriding the type of
144 terminal in the environmental variable \fBTERM\fR.
145 .TP 5
146 \fBtput cup 0 0\fR
147 Send the sequence to move the cursor to row \fB0\fR, column \fB0\fR
148 (the upper left corner of the screen, usually known as the "home"
149 cursor position).
150 .TP 5
151 \fBtput clear\fR
152 Echo the clear-screen sequence for the current terminal.
153 .TP 5
154 \fBtput cols\fR
155 Print the number of columns for the current terminal.
156 .TP 5
157 \fBtput \-T450 cols\fR
158 Print the number of columns for the 450 terminal.
159 .TP 5
160 \fBbold=`tput smso` offbold=`tput rmso`\fR
161 Set the shell variables \fBbold\fR, to begin stand-out mode
162 sequence, and \fBoffbold\fR, to end standout mode sequence,
163 for the current terminal.  This might be followed by a
164 prompt: \fBecho "${bold}Please type in your name: ${offbold}\\c"\fR
165 .TP 5
166 \fBtput hc\fR
167 Set exit code to indicate if the current terminal is a hard copy terminal.
168 .TP 5
169 \fBtput cup 23 4\fR
170 Send the sequence to move the cursor to row 23, column 4.
171 .TP 5
172 \fBtput cup\fR
173 Send the terminfo string for cursor-movement, with no parameters substituted.
174 .TP 5
175 \fBtput longname\fR
176 Print the long name from the \fBterminfo\fR database for the
177 type of terminal specified in the environmental
178 variable \fBTERM\fR.
179 .PP
180 .RS 5
181 \fBtput \-S <<!\fR
182 .br
183 \fB> clear\fR
184 .br
185 \fB> cup 10 10\fR
186 .br
187 \fB> bold\fR
188 .br
189 \fB> !\fR
190 .RE
191 .TP 5
192 \&
193 This example shows \fBtput\fR processing several capabilities in one invocation.
194 It clears the screen,
195 moves the cursor to position 10, 10
196 and turns on bold (extra bright) mode.
197 The list is terminated by an exclamation mark (\fB!\fR) on a line by itself.
198 .SH FILES
199 .TP
200 \fB\*d\fR
201 compiled terminal description database
202 .TP
203 \fB/usr/include/curses.h\fR
204 \fBcurses\fR(3X) header file
205 .TP
206 \fB/usr/include/term.h\fR
207 \fBterminfo\fR header file
208 .TP
209 \fB@DATADIR@/tabset/*\fR
210 tab settings for some terminals, in a format
211 appropriate to be output to the terminal (escape
212 sequences that set margins and tabs); for more
213 information, see the "Tabs and Initialization"
214 section of \fBterminfo\fR(5)
215 .SH EXIT CODES
216 If the \fB\-S\fR option is used,
217 \fBtput\fR checks for errors from each line,
218 and if any errors are found, will set the exit code to 4 plus the
219 number of lines with errors.
220 If no errors are found, the exit code is \fB0\fR.
221 No indication of which line failed can be given so
222 exit code \fB1\fR will never appear.  Exit codes \fB2\fR, \fB3\fR, and
223 \fB4\fR retain their usual interpretation.
224 If the \fB\-S\fR option is not used,
225 the exit code depends on the type of \fIcapname\fR:
226 .RS 5
227 .TP
228 .I boolean
229 a value of \fB0\fR is set for TRUE and \fB1\fR for FALSE.
230 .TP
231 .I string
232 a value of \fB0\fR is set if the
233 \fIcapname\fR is defined for this terminal \fItype\fR (the value of
234 \fIcapname\fR is returned on standard output);
235 a value of \fB1\fR is set if \fIcapname\fR
236 is not defined for this terminal \fItype\fR
237 (nothing is written to standard output).
238 .TP
239 .I integer
240 a value of \fB0\fR is always set,
241 whether or not \fIcapname\fR is defined for this terminal \fItype\fR.
242 To determine if \fIcapname\fR is defined for this terminal \fItype\fR,
243 the user must test the value written to standard output.
244 A value of \fB\-1\fR
245 means that \fIcapname\fR is not defined for this terminal \fItype\fR.
246 .TP
247 .I other
248 \fBreset\fR or \fBinit\fR may fail to find their respective files.
249 In that case, the exit code is set to 4 + \fBerrno\fR.
250 .RE
251 .PP
252 Any other exit code indicates an error; see the DIAGNOSTICS section.
253 .SH DIAGNOSTICS
254 \fBtput\fR prints the following error messages and sets the corresponding exit
255 codes.
256 .PP
257 .ne 15
258 .TS
259 l l.
260 exit code       error message
261 =
262 \fB0\fR T{
263 (\fIcapname\fR is a numeric variable that is not specified in the
264 \fBterminfo\fR(\*n) database for this terminal type, e.g.
265 \fBtput \-T450 lines\fR and \fBtput \-T2621 xmc\fR)
266 T}
267 \fB1\fR no error message is printed, see the \fBEXIT CODES\fR section.
268 \fB2\fR usage error
269 \fB3\fR unknown terminal \fItype\fR or no \fBterminfo\fR database
270 \fB4\fR unknown \fBterminfo\fR capability \fIcapname\fR
271 \fB>4\fR        error occurred in \-S
272 =
273 .TE
274 .SH PORTABILITY
275 The \fBlongname\fR and \fB\-S\fR options, and the parameter-substitution
276 features used in the \fBcup\fR example, are not supported in BSD curses or in
277 AT&T/USL curses before SVr4.
278 .SH SEE ALSO
279 \fB@CLEAR@\fR(1),
280 \fBstty\fR(1),
281 \fBtabs\fR(\*n),
282 \fBterminfo\fR(5).
283 .\"#
284 .\"# The following sets edit modes for GNU EMACS
285 .\"# Local Variables:
286 .\"# mode:nroff
287 .\"# fill-column:79
288 .\"# End: