]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tput.1
750051ba840941a3172bf1fbb100b8d9861ecf86
[ncurses.git] / man / tput.1
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright (c) 1998-2012,2016 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.36 2016/04/02 23:41:08 tom Exp $
31 .TH @TPUT@ 1 ""
32 .ds d @TERMINFO@
33 .ds n 1
34 .de bP
35 .IP \(bu 4
36 ..
37 .SH NAME
38 \fB@TPUT@\fR, \fBreset\fR \- initialize a terminal or query terminfo database
39 .SH SYNOPSIS
40 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fIcapname\fR [\fIparameters\fR]
41 .br
42 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBinit\fR
43 .br
44 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBreset\fR
45 .br
46 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBlongname\fR
47 .br
48 \fB@TPUT@ \-S\fR  \fB<<\fR
49 .br
50 \fB@TPUT@ \-V\fR
51 .br
52 .SH DESCRIPTION
53 The \fB@TPUT@\fR utility uses the \fBterminfo\fR database to make the
54 values of terminal-dependent capabilities and information available to
55 the shell (see \fBsh\fR(1)), to initialize or reset the terminal, or
56 return the long name of the requested terminal type.
57 The result depends upon the capability's type:
58 .RS 3
59 .TP 5
60 string
61 \fB@TPUT@\fR writes the string to the standard output.
62 No trailing newline is supplied.
63 .TP
64 integer
65 \fB@TPUT@\fR writes the decimal value to the standard output,
66 with a trailing newline.
67 .TP
68 boolean
69 \fB@TPUT@\fR simply sets the exit code
70 (\fB0\fR for TRUE if the terminal has the capability,
71 \fB1\fR for FALSE if it does not),
72 and writes nothing to the standard output.
73 .RE
74 .PP
75 Before using a value returned on the standard output,
76 the application should test the exit code
77 (e.g., \fB$?\fR, see \fBsh\fR(1)) to be sure it is \fB0\fR.
78 (See the \fBEXIT CODES\fR and \fBDIAGNOSTICS\fR sections.)
79 For a complete list of capabilities
80 and the \fIcapname\fR associated with each, see \fBterminfo\fR(5).
81 .SS Options
82 .TP
83 \fB\-T\fR\fItype\fR
84 indicates the \fItype\fR of terminal.
85 Normally this option is
86 unnecessary, because the default is taken from the environment
87 variable \fBTERM\fR.
88 If \fB\-T\fR is specified, then the shell
89 variables \fBLINES\fR and \fBCOLUMNS\fR will also be ignored.
90 .TP
91 \fB\-S\fR
92 allows more than one capability per invocation of \fB@TPUT@\fR.  The
93 capabilities must be passed to \fB@TPUT@\fR from the standard input
94 instead of from the command line (see example).
95 Only one \fIcapname\fR is allowed per line.
96 The \fB\-S\fR option changes the
97 meaning of the \fB0\fR and \fB1\fR boolean and string exit codes (see the
98 EXIT CODES section).
99 .IP
100 Again, \fB@TPUT@\fR uses a table and the presence of parameters in its input
101 to decide whether to use \fBtparm\fR(3X),
102 and how to interpret the parameters.
103 .TP
104 \fB\-V\fR
105 reports the version of ncurses which was used in this program, and exits.
106 .SS Commands
107 .TP
108 \fIcapname\fR
109 indicates the capability from the \fBterminfo\fR database.  When
110 \fBtermcap\fR support is compiled in, the \fBtermcap\fR name for
111 the capability is also accepted.
112 .IP
113 If the capability is a string that takes parameters, the arguments
114 following the capability will be used as parameters for the string.
115 .IP
116 Most parameters are numbers.
117 Only a few terminfo capabilities require string parameters;
118 \fB@TPUT@\fR uses a table to decide which to pass as strings.
119 Normally \fB@TPUT@\fR uses \fBtparm\fR(3X) to perform the substitution.
120 If no parameters are given for the capability,
121 \fB@TPUT@\fR writes the string without performing the substitution.
122 .TP
123 \fBinit\fR
124 If the \fBterminfo\fR database is present and an entry for the user's
125 terminal exists (see \fB\-T\fR\fItype\fR, above), the following will
126 occur:
127 .RS
128 .TP 5
129 (1)
130 if present, the terminal's initialization strings will be
131 output as detailed in the \fBterminfo\fR(5) section on
132 .IR "Tabs and Initialization" ,
133 .TP
134 (2)
135 any delays (e.g., newline) specified in the entry will
136 be set in the tty driver,
137 .TP
138 (3)
139 tabs expansion will be turned on or off according to
140 the specification in the entry, and
141 .TP
142 (4)
143 if tabs are not expanded,
144 standard tabs will be set (every 8 spaces).
145 .RE
146 .IP
147 If an entry does not
148 contain the information needed for any of these activities,
149 that activity will silently be skipped.
150 .TP
151 \fBreset\fR
152 Instead of putting out initialization strings, the terminal's
153 reset strings will be output if present (\fBrs1\fR, \fBrs2\fR, \fBrs3\fR, \fBrf\fR).
154 If the reset strings are not present, but initialization
155 strings are, the initialization strings will be output.
156 Otherwise, \fBreset\fR acts identically to \fBinit\fR.
157 .TP
158 \fBlongname\fR
159 If the \fBterminfo\fR database is present and an entry for the
160 user's terminal exists (see \fB\-T\fR\fItype\fR above), then the long name
161 of the terminal will be put out.  The long name is the last
162 name in the first line of the terminal's description in the
163 \fBterminfo\fR database [see \fBterm\fR(5)].
164 .SS Aliases
165 \fB@TPUT@\fR handles the \fBinit\fP and \fBreset\fP commands specially:
166 it allows for the possibility that it is invoked by a link with those names.
167 .PP
168 If \fB@TPUT@\fR is invoked by a link named \fBreset\fR, this has the
169 same effect as \fB@TPUT@ reset\fR.
170 The \fB@TSET@\fR(\*n) utility also treats a link named \fBreset\fP specially:
171 .bP
172 That utility resets the terminal modes and special characters (not done here).
173 .bP
174 On the other hand, @TSET@'s repertoire of terminal capabilities for
175 resetting the terminal is more limited, i.e., only \fBreset_1string\fP, \fBreset_2string\fP and \fBreset_file\fP
176 in contrast to the tab-stops and margins which are set by this utility.
177 .bP
178 The \fBreset\fP program is usually an alias for @TSET@,
179 due to the resetting of terminal modes and special characters.
180 .PP
181 If \fB@TPUT@\fR is invoked by a link named \fBinit\fR, this has the
182 same effect as \fB@TPUT@ init\fR.
183 Again, you are less likely to use that link because another program
184 named \fBinit\fP has a more well-established use.
185 .SH EXAMPLES
186 .TP 5
187 \fB@TPUT@ init\fR
188 Initialize the terminal according to the type of
189 terminal in the environmental variable \fBTERM\fR.  This
190 command should be included in everyone's .profile after
191 the environmental variable \fBTERM\fR has been exported, as
192 illustrated on the \fBprofile\fR(5) manual page.
193 .TP 5
194 \fB@TPUT@ \-T5620 reset\fR
195 Reset an AT&T 5620 terminal, overriding the type of
196 terminal in the environmental variable \fBTERM\fR.
197 .TP 5
198 \fB@TPUT@ cup 0 0\fR
199 Send the sequence to move the cursor to row \fB0\fR, column \fB0\fR
200 (the upper left corner of the screen, usually known as the "home"
201 cursor position).
202 .TP 5
203 \fB@TPUT@ clear\fR
204 Echo the clear-screen sequence for the current terminal.
205 .TP 5
206 \fB@TPUT@ cols\fR
207 Print the number of columns for the current terminal.
208 .TP 5
209 \fB@TPUT@ \-T450 cols\fR
210 Print the number of columns for the 450 terminal.
211 .TP 5
212 \fBbold=`@TPUT@ smso` offbold=`@TPUT@ rmso`\fR
213 Set the shell variables \fBbold\fR, to begin stand-out mode
214 sequence, and \fBoffbold\fR, to end standout mode sequence,
215 for the current terminal.  This might be followed by a
216 prompt: \fBecho "${bold}Please type in your name: ${offbold}\\c"\fR
217 .TP 5
218 \fB@TPUT@ hc\fR
219 Set exit code to indicate if the current terminal is a hard copy terminal.
220 .TP 5
221 \fB@TPUT@ cup 23 4\fR
222 Send the sequence to move the cursor to row 23, column 4.
223 .TP 5
224 \fB@TPUT@ cup\fR
225 Send the terminfo string for cursor-movement, with no parameters substituted.
226 .TP 5
227 \fB@TPUT@ longname\fR
228 Print the long name from the \fBterminfo\fR database for the
229 type of terminal specified in the environmental
230 variable \fBTERM\fR.
231 .PP
232 .RS 5
233 \fB@TPUT@ \-S <<!\fR
234 .br
235 \fB> clear\fR
236 .br
237 \fB> cup 10 10\fR
238 .br
239 \fB> bold\fR
240 .br
241 \fB> !\fR
242 .RE
243 .TP 5
244 \&
245 This example shows \fB@TPUT@\fR processing several capabilities in one invocation.
246 It clears the screen,
247 moves the cursor to position 10, 10
248 and turns on bold (extra bright) mode.
249 The list is terminated by an exclamation mark (\fB!\fR) on a line by itself.
250 .SH FILES
251 .TP
252 \fB\*d\fR
253 compiled terminal description database
254 .TP
255 \fB@DATADIR@/tabset/*\fR
256 tab settings for some terminals, in a format
257 appropriate to be output to the terminal (escape
258 sequences that set margins and tabs); for more
259 information, see the "Tabs and Initialization"
260 section of \fBterminfo\fR(5)
261 .SH EXIT CODES
262 If the \fB\-S\fR option is used,
263 \fB@TPUT@\fR checks for errors from each line,
264 and if any errors are found, will set the exit code to 4 plus the
265 number of lines with errors.
266 If no errors are found, the exit code is \fB0\fR.
267 No indication of which line failed can be given so
268 exit code \fB1\fR will never appear.  Exit codes \fB2\fR, \fB3\fR, and
269 \fB4\fR retain their usual interpretation.
270 If the \fB\-S\fR option is not used,
271 the exit code depends on the type of \fIcapname\fR:
272 .RS 3
273 .TP
274 .I boolean
275 a value of \fB0\fR is set for TRUE and \fB1\fR for FALSE.
276 .TP
277 .I string
278 a value of \fB0\fR is set if the
279 \fIcapname\fR is defined for this terminal \fItype\fR (the value of
280 \fIcapname\fR is returned on standard output);
281 a value of \fB1\fR is set if \fIcapname\fR
282 is not defined for this terminal \fItype\fR
283 (nothing is written to standard output).
284 .TP
285 .I integer
286 a value of \fB0\fR is always set,
287 whether or not \fIcapname\fR is defined for this terminal \fItype\fR.
288 To determine if \fIcapname\fR is defined for this terminal \fItype\fR,
289 the user must test the value written to standard output.
290 A value of \fB\-1\fR
291 means that \fIcapname\fR is not defined for this terminal \fItype\fR.
292 .TP
293 .I other
294 \fBreset\fR or \fBinit\fR may fail to find their respective files.
295 In that case, the exit code is set to 4 + \fBerrno\fR.
296 .RE
297 .PP
298 Any other exit code indicates an error; see the DIAGNOSTICS section.
299 .SH DIAGNOSTICS
300 \fB@TPUT@\fR prints the following error messages and sets the corresponding exit
301 codes.
302 .PP
303 .ne 15
304 .TS
305 l l.
306 exit code       error message
307 =
308 \fB0\fR T{
309 (\fIcapname\fR is a numeric variable that is not specified in the
310 \fBterminfo\fR(5) database for this terminal type, e.g.
311 \fB@TPUT@ \-T450 lines\fR and \fB@TPUT@ \-T2621 xmc\fR)
312 T}
313 \fB1\fR no error message is printed, see the \fBEXIT CODES\fR section.
314 \fB2\fR usage error
315 \fB3\fR unknown terminal \fItype\fR or no \fBterminfo\fR database
316 \fB4\fR unknown \fBterminfo\fR capability \fIcapname\fR
317 \fB>4\fR        error occurred in \-S
318 =
319 .TE
320 .SH PORTABILITY
321 .PP
322 The \fBlongname\fR and \fB\-S\fR options, and the parameter-substitution
323 features used in the \fBcup\fR example, are not supported in BSD curses or in
324 AT&T/USL curses before SVr4.
325 .PP
326 IEEE Std 1003.1/The Open Group  Base Specifications Issue 7 (POSIX.1-2008) 
327 documents only the operands for \fBclear\fP, \fBinit\fP and \fBreset\fP.
328 There are a few interesting observations to make regarding that:
329 .bP
330 In this implementation, \fBclear\fP is part of the \fIcapname\fR support.
331 The others (\fBinit\fP and \fBlongname\fP) do not correspond to terminal
332 capabilities.
333 .bP
334 Other implementations of \fB@TPUT@\fP on
335 SVr4-based systems such as Solaris, IRIX64 and HPUX
336 as well as others such as AIX and Tru64
337 provide support for \fIcapname\fR operands.
338 .bP
339 A few platforms such as FreeBSD recognize termcap names rather
340 than terminfo capability names in their respective \fB@TPUT@\fP commands.
341 Since 2010, NetBSD's \fBtput\fP uses terminfo names.
342 Before that, it (like FreeBSD) recognized termcap names.
343 .PP
344 Because (apparently) \fIall\fP of the certified Unix systems
345 support the full set of capability names, the reasoning for documenting
346 only a few may not be apparent.
347 .bP
348 X/Open Curses Issue 7 documents \fBtput\fP differently, with \fIcapname\fP
349 and the other features used in this implementation.
350 .bP
351 That is, there are two standards for \fBtput\fP: POSIX (a subset) and X/Open Curses (the full implementation).
352 POSIX documents a subset to avoid the complication of including X/Open Curses
353 and the terminal capabilities database.
354 .bP
355 While it is certainly possible to write a \fBtput\fP program without using curses,
356 none of the systems which have a curses implementation provide
357 a \fBtput\fP utility which does not provide the \fIcapname\fP feature.
358 .PP
359 Most implementations which provide support for \fIcapname\fR operands
360 use the \fItparm\fP function to expand parameters in it.
361 That function expects a mixture of numeric and string parameters,
362 requiring \fB@TPUT@\fP to know which type to use.
363 This implementation uses a table to determine that for
364 the standard \fIcapname\fR operands, and an internal library
365 function to analyze nonstandard \fIcapname\fR operands.
366 Other implementations may simply guess that an operand containing only digits
367 is intended to be a number.
368 .SH SEE ALSO
369 \fB@CLEAR@\fR(\*n),
370 \fBstty\fR(1),
371 \fB@TABS@\fR(\*n),
372 \fB@TSET@\fR(\*n),
373 \fBterminfo\fR(5),
374 \fBcurs_termcap\fR(3X).
375 .PP
376 This describes \fBncurses\fR
377 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).