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