2 .\"***************************************************************************
3 .\" Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. *
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: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
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. *
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 *
28 .\"***************************************************************************
30 .\" $Id: tput.1,v 1.58 2018/05/19 21:07:46 tom Exp $
43 \fB@TPUT@\fR, \fBreset\fR \- initialize a terminal or query terminfo database
45 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fIcapname\fR [\fIparameters\fR]
47 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] [\fB\-x\fP] \fBclear\fR
49 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBinit\fR
51 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBreset\fR
53 \fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBlongname\fR
55 \fB@TPUT@ \-S\fR \fB<<\fR
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:
68 \fB@TPUT@\fR writes the string to the standard output.
69 No trailing newline is supplied.
72 \fB@TPUT@\fR writes the decimal value to the standard output,
73 with a trailing newline.
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.
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).
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
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.
106 indicates the \fItype\fR of terminal.
107 Normally this option is
108 unnecessary, because the default is taken from the environment
110 If \fB\-T\fR is specified, then the shell
111 variables \fBLINES\fR and \fBCOLUMNS\fR will also be ignored.
114 reports the version of ncurses which was used in this program, and exits.
117 do not attempt to clear the terminal's scrollback buffer
118 using the extended \*(``E3\*('' capability.
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.
128 indicates the capability from the terminal database.
130 If the capability is a string that takes parameters, the arguments
131 following the capability will be used as parameters for the string.
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.
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
147 first, \fB@TPUT@\fR retrieves the current terminal mode settings
149 It does this by successively testing
158 ultimately \*(``/dev/tty\*(''
161 to obtain terminal settings.
162 Having retrieved these settings, \fB@TPUT@\fP remembers which
163 file descriptor to use when updating settings.
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.
172 the terminal modes will be updated:
175 any delays (e.g., newline) specified in the entry will
176 be set in the tty driver,
178 tabs expansion will be turned on or off according to
179 the specification in the entry, and
181 if tabs are not expanded,
182 standard tabs will be set (every 8 spaces).
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" ,
195 contain the information needed for any of these activities,
196 that activity will silently be skipped.
199 This is similar to \fBinit\fP, with two differences:
203 before any other initialization,
204 the terminal modes will be reset to a \*(``sane\*('' state:
207 set cooked and echo modes,
209 turn off cbreak and raw modes,
211 turn on newline translation and
213 reset any unset special characters to their default values
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.
224 Otherwise, \fBreset\fR acts identically to \fBinit\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. The long name is the last
230 name in the first line of the terminal's description in the
231 \fBterminfo\fR database [see \fBterm\fR(5)].
233 \fB@TPUT@\fR handles the \fBclear\fP, \fBinit\fP and \fBreset\fP
235 it allows for the possibility that it is invoked by a link with those names.
237 If \fB@TPUT@\fR is invoked by a link named \fBreset\fR, this has the
238 same effect as \fB@TPUT@ reset\fR.
239 The \fB@TSET@\fR(\*n) utility also treats a link named \fBreset\fP specially.
241 Before ncurses 6.1, the two utilities were different from each other:
243 \fB@TSET@\fP utility reset the terminal modes and special characters
244 (not done with \fB@TPUT@\fP).
246 On the other hand, \fB@TSET@\fP's repertoire of terminal capabilities for
247 resetting the terminal was more limited,
248 i.e., only \fBreset_1string\fP, \fBreset_2string\fP and \fBreset_file\fP
249 in contrast to the tab-stops and margins which are set by this utility.
251 The \fBreset\fP program is usually an alias for \fB@TSET@\fP,
252 because of this difference with resetting terminal modes and special characters.
254 With the changes made for ncurses 6.1, the \fIreset\fP feature of the
255 two programs is (mostly) the same. A few differences remain:
257 The \fB@TSET@\fP program waits one second when resetting,
258 in case it happens to be a hardware terminal.
260 The two programs write the terminal initialization strings
261 to different streams (i.e.,. the standard error for \fB@TSET@\fP and the
262 standard output for \fB@TPUT@\fP).
264 \fBNote:\fP although these programs write to different streams,
265 redirecting their output to a file will capture only part of their actions.
266 The changes to the terminal modes are not affected by redirecting the output.
268 If \fB@TPUT@\fR is invoked by a link named \fBinit\fR, this has the
269 same effect as \fB@TPUT@ init\fR.
270 Again, you are less likely to use that link because another program
271 named \fBinit\fP has a more well-established use.
275 Initialize the terminal according to the type of
276 terminal in the environmental variable \fBTERM\fR. This
277 command should be included in everyone's .profile after
278 the environmental variable \fBTERM\fR has been exported, as
279 illustrated on the \fBprofile\fR(5) manual page.
281 \fB@TPUT@ \-T5620 reset\fR
282 Reset an AT&T 5620 terminal, overriding the type of
283 terminal in the environmental variable \fBTERM\fR.
286 Send the sequence to move the cursor to row \fB0\fR, column \fB0\fR
287 (the upper left corner of the screen, usually known as the \*(``home\*(''
291 Echo the clear-screen sequence for the current terminal.
294 Print the number of columns for the current terminal.
296 \fB@TPUT@ \-T450 cols\fR
297 Print the number of columns for the 450 terminal.
299 \fBbold=`@TPUT@ smso` offbold=`@TPUT@ rmso`\fR
300 Set the shell variables \fBbold\fR, to begin stand-out mode
301 sequence, and \fBoffbold\fR, to end standout mode sequence,
302 for the current terminal. This might be followed by a
303 prompt: \fBecho "${bold}Please type in your name: ${offbold}\\c"\fR
306 Set exit code to indicate if the current terminal is a hard copy terminal.
308 \fB@TPUT@ cup 23 4\fR
309 Send the sequence to move the cursor to row 23, column 4.
312 Send the terminfo string for cursor-movement, with no parameters substituted.
314 \fB@TPUT@ longname\fR
315 Print the long name from the \fBterminfo\fR database for the
316 type of terminal specified in the environmental
332 This example shows \fB@TPUT@\fR processing several capabilities
334 It clears the screen,
335 moves the cursor to position 10, 10
336 and turns on bold (extra bright) mode.
337 The list is terminated by an exclamation mark (\fB!\fR) on a line by itself.
341 compiled terminal description database
343 \fB@DATADIR@/tabset/*\fR
344 tab settings for some terminals, in a format
345 appropriate to be output to the terminal (escape
346 sequences that set margins and tabs); for more
348 .IR "Tabs and Initialization" ,
349 section of \fBterminfo\fR(5)
351 If the \fB\-S\fR option is used,
352 \fB@TPUT@\fR checks for errors from each line,
353 and if any errors are found, will set the exit code to 4 plus the
354 number of lines with errors.
355 If no errors are found, the exit code is \fB0\fR.
356 No indication of which line failed can be given so
357 exit code \fB1\fR will never appear. Exit codes \fB2\fR, \fB3\fR, and
358 \fB4\fR retain their usual interpretation.
359 If the \fB\-S\fR option is not used,
360 the exit code depends on the type of \fIcapname\fR:
364 a value of \fB0\fR is set for TRUE and \fB1\fR for FALSE.
367 a value of \fB0\fR is set if the
368 \fIcapname\fR is defined for this terminal \fItype\fR (the value of
369 \fIcapname\fR is returned on standard output);
370 a value of \fB1\fR is set if \fIcapname\fR
371 is not defined for this terminal \fItype\fR
372 (nothing is written to standard output).
375 a value of \fB0\fR is always set,
376 whether or not \fIcapname\fR is defined for this terminal \fItype\fR.
377 To determine if \fIcapname\fR is defined for this terminal \fItype\fR,
378 the user must test the value written to standard output.
380 means that \fIcapname\fR is not defined for this terminal \fItype\fR.
383 \fBreset\fR or \fBinit\fR may fail to find their respective files.
384 In that case, the exit code is set to 4 + \fBerrno\fR.
387 Any other exit code indicates an error; see the DIAGNOSTICS section.
389 \fB@TPUT@\fR prints the following error messages and sets the corresponding exit
395 exit code error message
398 (\fIcapname\fR is a numeric variable that is not specified in the
399 \fBterminfo\fR(5) database for this terminal type, e.g.
400 \fB@TPUT@ \-T450 lines\fR and \fB@TPUT@ \-T2621 xmc\fR)
402 \fB1\fR no error message is printed, see the \fBEXIT CODES\fR section.
404 \fB3\fR unknown terminal \fItype\fR or no \fBterminfo\fR database
405 \fB4\fR unknown \fBterminfo\fR capability \fIcapname\fR
406 \fB>4\fR error occurred in \-S
410 The \fBtput\fP command was begun by Bill Joy in 1980.
411 The initial version only cleared the screen.
413 AT&T System V provided a different \fBtput\fP command,
414 whose \fBinit\fP and \fBreset\fP subcommands
415 (more than half the program) were incorporated from
416 the \fBreset\fP feature of BSD \fBtset\fP written by Eric Allman.
418 Keith Bostic replaced the BSD \fBtput\fP command in 1989
419 with a new implementation
420 based on the AT&T System V program \fBtput\fP.
421 Like the AT&T program, Bostic's version
422 accepted some parameters named for \fIterminfo capabilities\fP
423 (\fBclear\fP, \fBinit\fP, \fBlongname\fP and \fBreset\fP).
424 However (because he had only termcap available),
425 it accepted \fItermcap names\fP for other capabilities.
426 Also, Bostic's BSD \fBtput\fP did not modify the terminal I/O modes
427 as the earlier BSD \fBtset\fP had done.
429 At the same time, Bostic added a shell script named \*(``clear\*('',
430 which used \fBtput\fP to clear the screen.
432 Both of these appeared in 4.4BSD,
433 becoming the \*(``modern\*('' BSD implementation of \fBtput\fP.
435 This implementation of \fBtput\fP began from a different source than
436 AT&T or BSD: Ross Ridge's \fImytinfo\fP package, published on
437 \fIcomp.sources.unix\fP in December 1992.
438 Ridge's program made more sophisticated use of the terminal capabilities
439 than the BSD program.
440 Eric Raymond used the \fBtput\fP program
441 (and other parts of \fImytinfo\fP) in ncurses in June 1995.
442 Using the portions dealing with terminal capabilities
443 almost without change,
444 Raymond made improvements to the way the command-line parameters
448 This implementation of \fBtput\fP differs from AT&T \fBtput\fP in
451 \fB@TPUT@\fP \fIcapname\fP writes to the standard output.
452 That need not be a regular terminal.
453 However, the subcommands which manipulate terminal modes
454 may not use the standard output.
456 The AT&T implementation's \fBinit\fP and \fBreset\fP commands
457 use the BSD (4.1c) \fBtset\fP source, which manipulates terminal modes.
458 It successively tries standard output, standard error, standard input
459 before falling back to \*(``/dev/tty\*('' and finally just assumes
461 When updating terminal modes, it ignores errors.
463 Until changes made after ncurses 6.0,
464 \fB@TPUT@\fP did not modify terminal modes.
465 \fB@TPUT@\fP now uses a similar scheme,
466 using functions shared with \fB@TSET@\fP
467 (and ultimately based on the 4.4BSD \fBtset\fP).
468 If it is not able to open a terminal, e.g., when running in \fBcron\fP,
469 \fB@TPUT@\fP will return an error.
471 AT&T \fBtput\fP guesses the type of its \fIcapname\fP operands by seeing if
472 all of the characters are numeric, or not.
474 Most implementations which provide support for \fIcapname\fR operands
475 use the \fItparm\fP function to expand parameters in it.
476 That function expects a mixture of numeric and string parameters,
477 requiring \fB@TPUT@\fP to know which type to use.
479 This implementation uses a table to determine the parameter types for
480 the standard \fIcapname\fR operands, and an internal library
481 function to analyze nonstandard \fIcapname\fR operands.
483 This implementation (unlike others) can accept both \fItermcap\fP
484 and \fIterminfo\fP names for the \fIcapname\fP feature,
486 \fItermcap\fR support is compiled in.
487 However, the predefined \fItermcap\fP and \fIterminfo\fP names have two
488 ambiguities in this case (and the \fIterminfo\fP name is assumed):
490 The \fItermcap\fP name \fBdl\fP corresponds to
491 the \fIterminfo\fP name \fBdl1\fP (delete one line).
493 The \fIterminfo\fP name \fBdl\fP corresponds to
494 the \fItermcap\fP name \fBDL\fP (delete a given number of lines).
496 The \fItermcap\fP name \fBed\fP corresponds to
497 the \fIterminfo\fP name \fBrmdc\fP (end delete mode).
499 The \fIterminfo\fP name \fBed\fP corresponds to
500 the \fItermcap\fP name \fBcd\fP (clear to end of screen).
502 The \fBlongname\fR and \fB\-S\fR options, and the parameter-substitution
503 features used in the \fBcup\fR example,
504 were not supported in BSD curses before 4.3reno (1989) or in
505 AT&T/USL curses before SVr4 (1988).
507 IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008)
508 documents only the operands for \fBclear\fP, \fBinit\fP and \fBreset\fP.
509 There are a few interesting observations to make regarding that:
511 In this implementation, \fBclear\fP is part of the \fIcapname\fR support.
512 The others (\fBinit\fP and \fBlongname\fP) do not correspond to terminal
515 Other implementations of \fBtput\fP on
516 SVr4-based systems such as Solaris, IRIX64 and HPUX
517 as well as others such as AIX and Tru64
518 provide support for \fIcapname\fR operands.
520 A few platforms such as FreeBSD recognize termcap names rather
521 than terminfo capability names in their respective \fBtput\fP commands.
522 Since 2010, NetBSD's \fBtput\fP uses terminfo names.
523 Before that, it (like FreeBSD) recognized termcap names.
525 Because (apparently) \fIall\fP of the certified Unix systems
526 support the full set of capability names, the reasoning for documenting
527 only a few may not be apparent.
529 X/Open Curses Issue 7 documents \fBtput\fP differently, with \fIcapname\fP
530 and the other features used in this implementation.
532 That is, there are two standards for \fBtput\fP:
533 POSIX (a subset) and X/Open Curses (the full implementation).
534 POSIX documents a subset to avoid the complication of including X/Open Curses
535 and the terminal capabilities database.
537 While it is certainly possible to write a \fBtput\fP program
538 without using curses,
539 none of the systems which have a curses implementation provide
540 a \fBtput\fP utility which does not provide the \fIcapname\fP feature.
547 \fBcurs_termcap\fR(3X).
549 This describes \fBncurses\fR
550 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).