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