]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tput.1
ncurses 6.0 - patch 20161105
[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.46 2016/10/22 19:57:25 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 \fBclear\fP, \fBinit\fP and \fBreset\fP
172 commands specially:
173 it allows for the possibility that it is invoked by a link with those names.
174 .PP
175 If \fB@TPUT@\fR is invoked by a link named \fBreset\fR, this has the
176 same effect as \fB@TPUT@ reset\fR.
177 The \fB@TSET@\fR(\*n) utility also treats a link named \fBreset\fP specially.
178 .PP
179 Before ncurses 6.1, the two utilities were different from each other:
180 .bP
181 \fB@TSET@\fP utility reset the terminal modes and special characters
182 (not done with \fB@TPUT@\fP).
183 .bP
184 On the other hand, \fB@TSET@\fP's repertoire of terminal capabilities for
185 resetting the terminal was more limited, i.e., only \fBreset_1string\fP, \fBreset_2string\fP and \fBreset_file\fP
186 in contrast to the tab-stops and margins which are set by this utility.
187 .bP
188 The \fBreset\fP program is usually an alias for \fB@TSET@\fP,
189 because of this difference with resetting terminal modes and special characters.
190 .PP
191 If \fB@TPUT@\fR is invoked by a link named \fBinit\fR, this has the
192 same effect as \fB@TPUT@ init\fR.
193 Again, you are less likely to use that link because another program
194 named \fBinit\fP has a more well-established use.
195 .SH EXAMPLES
196 .TP 5
197 \fB@TPUT@ init\fR
198 Initialize the terminal according to the type of
199 terminal in the environmental variable \fBTERM\fR.  This
200 command should be included in everyone's .profile after
201 the environmental variable \fBTERM\fR has been exported, as
202 illustrated on the \fBprofile\fR(5) manual page.
203 .TP 5
204 \fB@TPUT@ \-T5620 reset\fR
205 Reset an AT&T 5620 terminal, overriding the type of
206 terminal in the environmental variable \fBTERM\fR.
207 .TP 5
208 \fB@TPUT@ cup 0 0\fR
209 Send the sequence to move the cursor to row \fB0\fR, column \fB0\fR
210 (the upper left corner of the screen, usually known as the \*(lqhome\*(rq
211 cursor position).
212 .TP 5
213 \fB@TPUT@ clear\fR
214 Echo the clear-screen sequence for the current terminal.
215 .TP 5
216 \fB@TPUT@ cols\fR
217 Print the number of columns for the current terminal.
218 .TP 5
219 \fB@TPUT@ \-T450 cols\fR
220 Print the number of columns for the 450 terminal.
221 .TP 5
222 \fBbold=`@TPUT@ smso` offbold=`@TPUT@ rmso`\fR
223 Set the shell variables \fBbold\fR, to begin stand-out mode
224 sequence, and \fBoffbold\fR, to end standout mode sequence,
225 for the current terminal.  This might be followed by a
226 prompt: \fBecho "${bold}Please type in your name: ${offbold}\\c"\fR
227 .TP 5
228 \fB@TPUT@ hc\fR
229 Set exit code to indicate if the current terminal is a hard copy terminal.
230 .TP 5
231 \fB@TPUT@ cup 23 4\fR
232 Send the sequence to move the cursor to row 23, column 4.
233 .TP 5
234 \fB@TPUT@ cup\fR
235 Send the terminfo string for cursor-movement, with no parameters substituted.
236 .TP 5
237 \fB@TPUT@ longname\fR
238 Print the long name from the \fBterminfo\fR database for the
239 type of terminal specified in the environmental
240 variable \fBTERM\fR.
241 .PP
242 .RS 5
243 \fB@TPUT@ \-S <<!\fR
244 .br
245 \fB> clear\fR
246 .br
247 \fB> cup 10 10\fR
248 .br
249 \fB> bold\fR
250 .br
251 \fB> !\fR
252 .RE
253 .TP 5
254 \&
255 This example shows \fB@TPUT@\fR processing several capabilities in one invocation.
256 It clears the screen,
257 moves the cursor to position 10, 10
258 and turns on bold (extra bright) mode.
259 The list is terminated by an exclamation mark (\fB!\fR) on a line by itself.
260 .SH FILES
261 .TP
262 \fB\*d\fR
263 compiled terminal description database
264 .TP
265 \fB@DATADIR@/tabset/*\fR
266 tab settings for some terminals, in a format
267 appropriate to be output to the terminal (escape
268 sequences that set margins and tabs); for more
269 information, see the
270 .IR "Tabs and Initialization" ,
271 section of \fBterminfo\fR(5)
272 .SH EXIT CODES
273 If the \fB\-S\fR option is used,
274 \fB@TPUT@\fR checks for errors from each line,
275 and if any errors are found, will set the exit code to 4 plus the
276 number of lines with errors.
277 If no errors are found, the exit code is \fB0\fR.
278 No indication of which line failed can be given so
279 exit code \fB1\fR will never appear.  Exit codes \fB2\fR, \fB3\fR, and
280 \fB4\fR retain their usual interpretation.
281 If the \fB\-S\fR option is not used,
282 the exit code depends on the type of \fIcapname\fR:
283 .RS 3
284 .TP
285 .I boolean
286 a value of \fB0\fR is set for TRUE and \fB1\fR for FALSE.
287 .TP
288 .I string
289 a value of \fB0\fR is set if the
290 \fIcapname\fR is defined for this terminal \fItype\fR (the value of
291 \fIcapname\fR is returned on standard output);
292 a value of \fB1\fR is set if \fIcapname\fR
293 is not defined for this terminal \fItype\fR
294 (nothing is written to standard output).
295 .TP
296 .I integer
297 a value of \fB0\fR is always set,
298 whether or not \fIcapname\fR is defined for this terminal \fItype\fR.
299 To determine if \fIcapname\fR is defined for this terminal \fItype\fR,
300 the user must test the value written to standard output.
301 A value of \fB\-1\fR
302 means that \fIcapname\fR is not defined for this terminal \fItype\fR.
303 .TP
304 .I other
305 \fBreset\fR or \fBinit\fR may fail to find their respective files.
306 In that case, the exit code is set to 4 + \fBerrno\fR.
307 .RE
308 .PP
309 Any other exit code indicates an error; see the DIAGNOSTICS section.
310 .SH DIAGNOSTICS
311 \fB@TPUT@\fR prints the following error messages and sets the corresponding exit
312 codes.
313 .PP
314 .ne 15
315 .TS
316 l l.
317 exit code       error message
318 =
319 \fB0\fR T{
320 (\fIcapname\fR is a numeric variable that is not specified in the
321 \fBterminfo\fR(5) database for this terminal type, e.g.
322 \fB@TPUT@ \-T450 lines\fR and \fB@TPUT@ \-T2621 xmc\fR)
323 T}
324 \fB1\fR no error message is printed, see the \fBEXIT CODES\fR section.
325 \fB2\fR usage error
326 \fB3\fR unknown terminal \fItype\fR or no \fBterminfo\fR database
327 \fB4\fR unknown \fBterminfo\fR capability \fIcapname\fR
328 \fB>4\fR        error occurred in \-S
329 =
330 .TE
331 .SH HISTORY
332 The \fBtput\fP command was begun by Bill Joy in 1980.
333 The initial version only cleared the screen.
334 .PP
335 AT&T System V provided a different \fBtput\fP command,
336 whose \fBinit\fP and \fBreset\fP  subcommands
337 (more than half the program) were incorporated from
338 the \fBreset\fP feature of BSD \fBtset\fP written by Eric Allman.
339 Later the corresponding source code for \fIreset\fP
340 was removed from the BSD \fBtset\fP
341 (in June 1993, released in 4.4BSD-Lite a year later).
342 .PP
343 Keith Bostic replaced the BSD \fBtput\fP command in 1989 with a new implementation
344 based on the AT&T System V program \fBtput\fP.
345 Like the AT&T program, Bostic's version
346 accepted some parameters named for \fIterminfo capabilities\fP
347 (\fBclear\fP, \fBinit\fP, \fBlongname\fP and \fBreset\fP).
348 However (because he had only termcap available),
349 it accepted \fItermcap names\fP for other capabilities.
350 Also, Bostic's BSD \fBtput\fP did not modify the terminal I/O modes
351 as the earlier BSD \fBtset\fP had done.
352 .PP
353 At the same time, Bostic added a shell script named \*(lqclear\*(rq,
354 which used \fBtput\fP to clear the screen.
355 .PP
356 Both of these appeared in 4.4BSD,
357 becoming the \*(lqmodern\*(rq BSD implementation of \fBtput\fP.
358 .SH PORTABILITY
359 .PP
360 This implementation of \fBtput\fP differs from AT&T \fBtput\fP in
361 two important areas:
362 .bP
363 \fB@TPUT@\fP \fIcapname\fP writes to the standard output.
364 That need not be a regular terminal.
365 However, the subcommands which manipulate terminal modes
366 may not use the standard output.
367 .IP
368 The AT&T implementation's \fBinit\fP and \fBreset\fP commands
369 use the BSD (4.1c) \fBtset\fP source, which manipulates terminal modes.
370 It successively tries standard output, standard error, standard input
371 before falling back to \*(lq/dev/tty\*(rq and finally just assumes
372 a 1200Bd terminal.
373 When updating terminal modes, it ignores errors.
374 .IP
375 Until changes made after ncurses 6.0, \fB@TPUT@\fP did not modify terminal modes.
376 \fB@TPUT@\fP now uses a similar scheme,
377 using functions shared with \fB@TSET@\fP
378 (and ultimately based on the 4.4BSD \fBtset\fP).
379 If it is not able to open a terminal, e.g., when running in \fBcron\fP,
380 \fB@TPUT@\fP will return an error.
381 .bP
382 AT&T \fBtput\fP guesses the type of its \fIcapname\fP operands by seeing if
383 all of the characters are numeric, or not.
384 .IP
385 Most implementations which provide support for \fIcapname\fR operands
386 use the \fItparm\fP function to expand parameters in it.
387 That function expects a mixture of numeric and string parameters,
388 requiring \fB@TPUT@\fP to know which type to use.
389 .IP
390 This implementation uses a table to determine the parameter types for
391 the standard \fIcapname\fR operands, and an internal library
392 function to analyze nonstandard \fIcapname\fR operands.
393 .PP
394 The \fBlongname\fR and \fB\-S\fR options, and the parameter-substitution
395 features used in the \fBcup\fR example,
396 were not supported in BSD curses before 4.3reno (1989) or in
397 AT&T/USL curses before SVr4 (1988).
398 .PP
399 IEEE Std 1003.1/The Open Group  Base Specifications Issue 7 (POSIX.1-2008) 
400 documents only the operands for \fBclear\fP, \fBinit\fP and \fBreset\fP.
401 There are a few interesting observations to make regarding that:
402 .bP
403 In this implementation, \fBclear\fP is part of the \fIcapname\fR support.
404 The others (\fBinit\fP and \fBlongname\fP) do not correspond to terminal
405 capabilities.
406 .bP
407 Other implementations of \fBtput\fP on
408 SVr4-based systems such as Solaris, IRIX64 and HPUX
409 as well as others such as AIX and Tru64
410 provide support for \fIcapname\fR operands.
411 .bP
412 A few platforms such as FreeBSD recognize termcap names rather
413 than terminfo capability names in their respective \fBtput\fP commands.
414 Since 2010, NetBSD's \fBtput\fP uses terminfo names.
415 Before that, it (like FreeBSD) recognized termcap names.
416 .PP
417 Because (apparently) \fIall\fP of the certified Unix systems
418 support the full set of capability names, the reasoning for documenting
419 only a few may not be apparent.
420 .bP
421 X/Open Curses Issue 7 documents \fBtput\fP differently, with \fIcapname\fP
422 and the other features used in this implementation.
423 .bP
424 That is, there are two standards for \fBtput\fP: POSIX (a subset) and X/Open Curses (the full implementation).
425 POSIX documents a subset to avoid the complication of including X/Open Curses
426 and the terminal capabilities database.
427 .bP
428 While it is certainly possible to write a \fBtput\fP program without using curses,
429 none of the systems which have a curses implementation provide
430 a \fBtput\fP utility which does not provide the \fIcapname\fP feature.
431 .SH SEE ALSO
432 \fB@CLEAR@\fR(\*n),
433 \fBstty\fR(1),
434 \fB@TABS@\fR(\*n),
435 \fB@TSET@\fR(\*n),
436 \fBterminfo\fR(5),
437 \fBcurs_termcap\fR(3X).
438 .PP
439 This describes \fBncurses\fR
440 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).