blob: eba073390df5cb1db27379170de0e232b0279c0c [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301'\" t
2.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04003.\" Copyright 2018-2023,2024 Thomas E. Dickey *
4.\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05305.\" *
6.\" Permission is hereby granted, free of charge, to any person obtaining a *
7.\" copy of this software and associated documentation files (the *
8.\" "Software"), to deal in the Software without restriction, including *
9.\" without limitation the rights to use, copy, modify, merge, publish, *
10.\" distribute, distribute with modifications, sublicense, and/or sell *
11.\" copies of the Software, and to permit persons to whom the Software is *
12.\" furnished to do so, subject to the following conditions: *
13.\" *
14.\" The above copyright notice and this permission notice shall be included *
15.\" in all copies or substantial portions of the Software. *
16.\" *
17.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24.\" *
25.\" Except as contained in this notice, the name(s) of the above copyright *
26.\" holders shall not be used in advertising or otherwise to promote the *
27.\" sale, use or other dealings in this Software without prior written *
28.\" authorization. *
29.\"***************************************************************************
30.\"
micky3879b9f5e72025-07-08 18:04:53 -040031.\" $Id: tput.1,v 1.113 2024/04/20 19:58:50 tom Exp $
32.TH @TPUT@ 1 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
33.ie \n(.g \{\
34.ds `` \(lq
35.ds '' \(rq
36.\}
37.el \{\
38.ie t .ds `` ``
39.el .ds `` ""
40.ie t .ds '' ''
41.el .ds '' ""
42.\}
43.
44.de bP
45.ie n .IP \(bu 4
46.el .IP \(bu 2
47..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053048.ds d @TERMINFO@
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053049.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040050\fB\%@TPUT@\fP \-
51initialize a terminal, exercise its capabilities, or query \fI\%term\%info\fP database
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053052.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040053\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP]
54{\fIcap-code\fP [\fIparameter\fP .\|.\|.\&]} .\|.\|.
55.PP
56\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] [\fB\-x\fP] \fBclear\fP
57.PP
58\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fBinit\fP
59.PP
60\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fB\%reset\fP
61.PP
62\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fB\%longname\fP
63.PP
64\fB@TPUT@ \-S\fP
65.PP
66\fB@TPUT@ \-V\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053067.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040068\fB\%@TPUT@\fP uses the
69.I \%term\%info
70library and database to make terminal-specific capabilities and
71information available to the shell,
72to initialize or reset the terminal,
73or
74to report a description of the current
75(or specified)
76terminal type.
77Terminal capabilities are accessed by
78.IR cap-code .
79.PP
80\fB\%terminfo\fP(5) discusses terminal capabilities at length
81and presents a complete list of
82.IR cap-codes .
83.PP
84When retrieving capability values,
85the result depends upon the capability's type.
86.TP 9 \" "Boolean" + 2n
87Boolean
88\fB\%@TPUT@\fP sets its exit status to
89.B 0
90if the terminal possesses
91.IR cap-code ,
92and
93.B 1
94if it does not.
95.TP
96numeric
97\fB\%@TPUT@\fP writes
98.IR cap-code 's
99decimal value to the standard output stream if defined
100.RB ( \-1
101if it is not)
102followed by a newline.
103.TP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530104string
micky3879b9f5e72025-07-08 18:04:53 -0400105\fB\%@TPUT@\fP writes
106.IR cap-code 's
107value to the standard output stream if defined,
108without a trailing newline.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530109.PP
110Before using a value returned on the standard output,
micky3879b9f5e72025-07-08 18:04:53 -0400111the application should test \fB\%@TPUT@\fP's exit status
112to be sure it is 0;
113see section \*(``EXIT STATUS\*('' below.
114.SS Operands
115Generally,
116an operand is a
117.IR cap-code ,
118a capability code from the terminal database,
119or a parameter thereto.
120Three others are specially recognized by \fB\%@TPUT@\fP:
121.BR init ,
122.BR \%reset ,
123and
124.BR \%longname .
125Although these resemble capability codes,
126they in fact receive special handling;
127we term them \*(``pseudo-capabilities\*(''.
128.TP 11n \" "longname" + 2n + adjustment for PDF
129.I cap-code
130indicates a capability from the terminal database.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530131.IP
micky3879b9f5e72025-07-08 18:04:53 -0400132If
133.I cap-code
134is of string type and takes parameters,
135\fB\%@TPUT@\fP interprets arguments following
136.I cap-code
137as the parameters,
138up to the (fixed) quantity the capability requires.
139.IP
140Most parameters are numeric.
141Only a few terminal capabilities require string parameters;
142\fB\%@TPUT@\fP uses a table to decide which to pass as strings.
143Normally \fB\%@TPUT@\fP uses \fB\%tparm\fP(3X) to perform the
144substitution.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530145If no parameters are given for the capability,
micky3879b9f5e72025-07-08 18:04:53 -0400146\fB\%@TPUT@\fP writes the string without performing the substitution.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530147.TP
micky3879b9f5e72025-07-08 18:04:53 -0400148.B init
149initializes the terminal.
150If the terminal database is present
151and an entry for the user's terminal type exists,
152the following occur.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530153.RS
micky3879b9f5e72025-07-08 18:04:53 -0400154.TP 5
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530155(1)
micky3879b9f5e72025-07-08 18:04:53 -0400156\fB\%@TPUT@\fP retrieves the terminal's mode settings.
157It successively tests the file descriptors corresponding to
158.RS
159.bP
160the standard error stream,
161.bP
162the standard output stream,
163.bP
164the standard input stream,
165and
166.bP
167.I \%/dev/tty
168.RE
169.IP
170to obtain terminal settings.
171Having retrieved them,
172\fB\%@TPUT@\fP remembers which descriptor to use for further updates.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530173.TP
174(2)
micky3879b9f5e72025-07-08 18:04:53 -0400175If the terminal dimensions cannot be obtained from the operating system,
176but the environment or terminal type database entry describes them,
177\fB\%@TPUT@\fP updates the operating system's notion of them.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530178.TP
179(3)
micky3879b9f5e72025-07-08 18:04:53 -0400180\fB\%@TPUT@\fP updates the terminal modes.
181.RS
182.bP
183Any delays specified in the entry
184(for example,
185when a newline is sent)
186are set in the terminal driver.
187.bP
188Tab expansion is turned on or off per the specification in the entry,
189and
190.bP
191if tabs are not expanded,
192standard tabs
193(every 8 spaces)
194are set.
195.RE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530196.TP
197(4)
micky3879b9f5e72025-07-08 18:04:53 -0400198If initialization capabilities,
199detailed in subsection \*(``Tabs and Initialization\*('' of
200\fB\%terminfo\fP(5),
201are present,
202\fB\%@TPUT@\fP writes them to the standard output stream.
203.TP
204(5)
205\fB\%@TPUT@\fP flushes the standard output stream.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530206.RE
207.IP
micky3879b9f5e72025-07-08 18:04:53 -0400208If an entry lacks the information needed for an activity above,
209that activity is silently skipped.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530210.TP
micky3879b9f5e72025-07-08 18:04:53 -0400211.B reset
212re-initializes the terminal.
213A reset differs from initialization in two ways.
214.RS
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530215.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400216(1)
217\fB\%@TPUT@\fP sets the the terminal modes to a \*(``sane\*('' state,
218.RS
219.bP
220enabling cooked and echo modes,
221.bP
222disabling cbreak and raw modes,
223.bP
224enabling newline translation,
225and
226.bP
227setting any unset special characters to their default values.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530228.RE
229.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400230(2)
231If any reset capabilities are defined for the terminal type,
232\fB\%@TPUT@\fP writes them to the output stream.
233Otherwise,
234\fB\%@TPUT@\fP uses any defined initialization capabilities.
235Reset capabilities are detailed in subsection
236\*(``Tabs and Initialization\*('' of \fB\%terminfo\fP(5).
237.RE
238.TP
239.B longname
240A
241.I \%term\%info
242entry begins with one or more names by which an application
243can refer to the entry,
244before the list of terminal capabilities.
245The names are separated by \*(``|\*('' characters.
246X/Open Curses terms the last name the \*(``long name\*('',
247and indicates that it may include blanks.
248.IP
249\fB\%@TIC@\fP warns if the last name does not include blanks,
250to accommodate old
251.I \%term\%info
252entries that treated the long name as an optional feature.
253The long name is often referred to as the description field.
254.IP
255If the terminal database is present and an entry for the user's terminal
256type exists,
257\fB\%@TPUT@\fP reports its description to the standard output stream,
258without a trailing newline.
259See \fB\%terminfo\fP(5).
260.PP
261.I Note:
262Redirecting the output of
263.RB \%\*(`` "@TPUT@ init" \*(''
264or
265.RB \%\*(`` "@TPUT@ reset" \*(''
266to a file will capture only part of their actions.
267Changes to the terminal modes are not affected by file descriptor
268redirection,
269since the terminal modes are altered via \fB\%ioctl\fP(2).
270.SS Aliases
271If \fB\%@TPUT@\fP is invoked via link with any of the names
272.BR clear ,
273.BR init ,
274or
275.BR \%reset ,
276it operates as if run with the corresponding (pseudo-)capability
277operand.
278For example,
279executing a link named
280.B \%reset
281that points to \fB\%@TPUT@\fP has the same effect as
282.RB \%\*(`` "@TPUT@ \%reset" \*(''.
283.PP
284This feature was introduced by
285.I \%ncurses
2865.2 in 2000.
287It is rarely used:
288.TP
289.B \%clear
290is a separate program,
291which is both smaller and more frequently executed.
292.TP
293.B init
294has the same name as another program in widespread use.
295.TP
296.B \%reset
297is provided
298by the \fB\%@TSET@\fP(1) utility (also via a link named
299.BR \%reset ")."
300.SS "Terminal Size"
301Besides the pseudo-capabilities
302(such as
303.BR init ),
304\fB\%@TPUT@\fP treats the
305.B lines
306and
307.B cols
308.I cap-codes
309specially:
310it may call \fB\%setupterm\fP(3X) to obtain the terminal size.
311.bP
312First,
313\fB\%@TPUT@\fP attempts to obtain these capabilities from the terminal
314database.
315This generally fails for terminal emulators,
316which lack a fixed window size and thus omit the capabilities.
317.bP
318It then asks the operating system for the terminal's size,
319which generally works,
320unless the connection is via a serial line that
321does not support \*(``NAWS\*('': negotiations about window size.
322.bP
323Finally,
324it inspects the environment variables
325.I LINES
326and
327.IR \%COLUMNS ,
328which may override the terminal size.
329.PP
330If the
331.B \-T
332option is given,
333\fB\%@TPUT@\fP ignores the environment variables by calling
334.BR \%use_tioctl(TRUE) ,
335relying upon the operating system
336(or,
337ultimately,
338the terminal database).
339.SH OPTIONS
340.TP 9n \" "-T type" + 2n
341.B \-S
342retrieves more than one capability per invocation of \fB\%@TPUT@\fP.
343The capabilities must be passed to \fB\%@TPUT@\fP from the standard
344input stream instead of from the command line
345(see section \*(``EXAMPLES\*('' below).
346Only one
347.I cap-code
348is allowed per line.
349The
350.B \-S
351option changes the meanings of the
352.B 0
353and
354.B 1
355exit statuses
356(see section \*(``EXIT STATUS\*('' below).
357.IP
358Some capabilities use string parameters rather than numeric ones.
359\fB\%@TPUT@\fP employs a built-in table and the presence of parameters
360in its input to decide how to interpret them,
361and whether to use \fB\%tparm\fP(3X).
362.TP
363.BI \-T\ type
364indicates the terminal's
365.IR type .
366Normally this option is unnecessary,
367because a default is taken from the
368.I TERM
369environment variable.
370If specified,
371the environment variables
372.I LINES
373and
374.I \%COLUMNS
375are also ignored.
376.TP
377.B \-V
378reports the version of
379.I \%ncurses
380associated with \fB\%@TPUT@\fP,
381and exits with a successful status.
382.TP
383.B \-x
384prevents
385.RB \%\*(`` "@TPUT@ clear" \*(''
386from attempting to clear the scrollback buffer.
387.SH EXIT STATUS
388Normally,
389one should interpret \fB\%@TPUT@\fP's exit statuses as follows.
390.PP
391.if n .ne 3
392.if t .ne 2
393.TS
394Lb Lb
395Lb Lx.
396Status Meaning When \-S Not Specified
397_
3980 Boolean or string capability present
3991 Boolean or numeric capability absent
4002 usage error or no terminal type specified
4013 unrecognized terminal type
4024 unrecognized capability code
403>4 system error (4 + \fBerrno\fP)
404.TE
405.PP
406When the
407.B \-S
408option is used,
409some statuses change meanings.
410.PP
411.if n .ne 4
412.if t .ne 3
413.TS
414Lb Lb
415Lb Lx.
416Status Meaning When \-S Specified
417_
4180 all operands interpreted
4191 unused
4204 some operands not interpreted
421.TE
422.SH ENVIRONMENT
423\fB@TPUT@\fP reads one environment variable.
424.TP 8n \" "TERM" + 2n + adjustment for PDF
425.I TERM
426denotes the terminal type.
427Each terminal type is distinct,
428though many are similar.
429The
430.B \-T
431option overrides its value.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530432.SH FILES
433.TP
micky3879b9f5e72025-07-08 18:04:53 -0400434.I @DATADIR@/tabset
435tab stop initialization database
436.TP
437.I \*d
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530438compiled terminal description database
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530439.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400440Over time
441.I \%ncurses
442\fB\%@TPUT@\fP
443has differed from that of System\ V in two important respects,
444one now mostly historical.
445.bP
446\%\*(``\fB@TPUT@\fP
447.IR cap-code \*(''
448writes to the standard output,
449which need not be a terminal device.
450However,
451the operands that manipulate terminal modes might not use the standard
452output.
453.IP
454System\ V
455.BR tput 's
456.B init
457and
458.B \%reset
459operands use logic from 4.1cBSD
460.BR tset ,
461manipulating terminal modes.
462It checks the same file descriptors
463(and
464.IR \%/dev/tty )
465for association with a terminal device as
466.I \%ncurses
467now does,
468and if none are,
469finally assumes a 1200 baud terminal.
470When updating terminal modes,
471it ignores errors.
472.IP
473Until
474.I \%ncurses
4756.1
476(see section \*(``HISTORY\*('' below),
477\fB\%@TPUT@\fP did not modify terminal modes.
478It now employs a scheme similar to System\ V,
479using functions shared with \fB\%@TSET@\fP
480(and ultimately based on 4.4BSD
481.BR tset ).
482If it is not able to open a terminal
483(for instance,
484when run by \fIcron\fP(1)),
485\fB\%@TPUT@\fP exits with an error status.
486.bP
487System\ V
488.B tput
489assumes that the type of a
490.I cap-code
491operand is numeric if all the characters of its value are decimal
492numbers;
493if they are not,
494it treats
495.I cap-code
496as a string capability.
497.IP
498Most implementations that provide support for
499.I cap-code
500operands use the \fB\%tparm\fP(3X) function to expand its parameters.
Steve Kondikae271bc2015-11-15 02:50:53 +0100501That function expects a mixture of numeric and string parameters,
micky3879b9f5e72025-07-08 18:04:53 -0400502requiring \fB\%@TPUT@\fP to know which type to use.
503.IP
504.I \%ncurses
505\fB\%@TPUT@\fP
506uses a table to determine the parameter types for
507the standard
508.I cap-code
509operands,
510and an internal function to analyze nonstandard
511.I cap-code
512operands.
513.IP
514While more reliable than System\ V's utility,
515a portability problem is introduced by this analysis.
516An OpenBSD developer adapted the internal library function from
517.I \%ncurses
518to port NetBSD's
519.IR termcap -based
520.B tput
521to
522.IR \%term\%info ,
523and modified it to interpret multiple
524.I cap-codes
525(and parameters)
526on the command line.
527Portable applications should not rely upon this feature;
528.I \%ncurses
529offers it to support applications written specifically for OpenBSD.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530530.PP
micky3879b9f5e72025-07-08 18:04:53 -0400531This implementation,
532unlike others,
533accepts both
534.I termcap
535and
536.I \%term\%info
537.I cap-codes
538if
539.I termcap
540support is compiled in.
541In that case,
542however,
543the predefined
544.I termcap
545and
546.I \%term\%info
547codes have two
548ambiguities;
549.I \%ncurses
550assumes the
551.I \%term\%info
552code.
553.bP
554The
555.I cap-code
556.B dl
557means
558.B \%delete_line
559to
560.I termcap
561but
562.B \%parm_delete_line
563to
564.IR \%term\%info .
565.I termcap
566uses the code
567.B DL
568for
569.BR \%parm_delete_line .
570.I \%term\%info
571uses the code
572.B dl1
573for
574.BR \%delete_line .
575.bP
576The
577.I cap-code
578.B ed
579means
580.B \%exit_delete_mode
581to
582.I termcap
583but
584.B \%clr_eos
585to
586.IR \%term\%info .
587.I termcap
588uses the code
589.B cd
590for
591.BR \%clr_eos .
592.I \%term\%info
593uses the code
594.B rmdc
595for
596.BR \%exit_delete_mode .
597.PP
598The
599.B \%longname
600operand,
601.B \-S
602option,
603and the parameter-substitution features used in the
604.B cup
605example below,
606were not supported in
607AT&T/USL
608.I curses
609before SVr4 (1989).
610Later,
6114.3BSD-Reno (1990) added support for
612.BR \%longname ,
613.\" longname was added in October 1989.
614and in 1994,
615NetBSD added support for the parameter-substitution features.
616.PP
617IEEE Std 1003.1/The Open Group Base Specifications Issue 7
618(POSIX.1-2008)
619documents only the
620.BR clear ,
621.BR init ,
622and
623.B \%reset
624operands.
625A few observations of interest arise from that selection.
626.bP
627.I \%ncurses
628supports
629.B clear
630as it does any other standard
631.IR cap-code .
632The others
633.RB ( init
634and
635.BR \%longname )
636do not correspond to terminal capabilities.
637.bP
638The
639.B tput
640on SVr4-based systems such as Solaris,
641IRIX64,
642and HP-UX,
643as well as others such as AIX and Tru64,
644also support standard
645.I cap-code
646operands.
647.bP
648A few platforms such as FreeBSD recognize
649.I termcap
650codes rather than
651.I \%term\%info
652capability codes in their respective
653.B tput
654commands.
655Since 2010,
656NetBSD's
657.B tput
658uses
659.I \%term\%info
660codes.
661Before that,
662it
663(like FreeBSD)
664recognized
665.I termcap
666codes.
667.IP
668Beginning in 2021,
669FreeBSD uses
670.I \%ncurses
671.BR tput ,
672configured for both
673.I \%term\%info
674(tested first)
675and
676.I termcap
677(as a fallback).
678.PP
679Because (apparently) all
680.I certified
681Unix systems support the full set of capability codes,
682the reason for documenting only a few may not be apparent.
683.bP
684X/Open Curses Issue 7 documents
685.B tput
686differently,
687with
688.I cap-code
689and the other features used in this implementation.
690.bP
691That is,
692there are two standards for
693.BR tput :
694POSIX (a subset) and X/Open Curses (the full implementation).
695POSIX documents a subset to avoid the complication of including
696X/Open Curses and the terminal capability database.
697.bP
698While it is certainly possible to write a
699.B tput
700program without using
701.IR curses ,
702no system with a
703.I curses
704implementation provides a
705.B tput
706utility that does not also support standard
707.IR cap-codes .
708.PP
709X/Open Curses Issue 7 (2009) is the first version to document utilities.
710However that part of X/Open Curses does not follow existing practice
711(that is,
712System\ V
713.I curses
714behavior).
715.bP
716It assigns exit status 4 to \*(``invalid operand\*('',
717which may have the same meaning as \*(``unknown capability\*(''.
718For instance,
719the source code for
720Solaris
721.I xcurses
722uses the term \*(``invalid\*('' in this case.
723.bP
724It assigns exit status 255 to a numeric variable that is not specified
725in the
726.I \%term\%info
727database.
728That likely is a documentation error,
729mistaking the \*(``\-1\*('' written to the standard output to indicate
730an absent or cancelled numeric capability for an (unsigned) exit status.
731.PP
732The various System\ V implementations
733(AIX,
734HP-UX,
735Solaris)
736use the same exit statuses as
737.IR \%ncurses .
738.PP
739NetBSD
740.I curses
741documents exit statuses that correspond to neither
742.I \%ncurses
743nor X/Open Curses.
744.SH HISTORY
745Bill Joy wrote a
746.B tput
747command during development of 4BSD in October 1980.
748This initial version only cleared the screen,
749and did not ship with official distributions.
750.\" It also exited with backwards exit status (1 on success, 0 on
751.\" failure), and was characterized by Bostic in 1988 as "pretty
752.\" unreasonable".
753.\" See Spinellis's "unix-history-repo" on GitHub.
754.PP
755System\ V developed a different
756.B tput
757command.
758.bP
759SVr2 (1984) provided a rudimentary
760.B tput
761that checked the parameter against each
762predefined capability and returned the corresponding value.
763This version of
764.B tput
765did not use \fB\%tparm\fP(3X) for parameterized capabilities.
766.bP
767SVr3 (1987) replaced that
768.\" SVr3 released in 1987, not 1985.
769.\" https://unix.org/what_is_unix/history_timeline.html
770with a more extensive program
771whose support for
772.B init
773and
774.B \%reset
775operands
776(more than half the program)
777incorporated the
778.B \%reset
779feature of BSD
780.B tset
781written by Eric Allman.
782.bP
783SVr4 (1989) added color initialization by using the
784.B \%orig_colors
785.RB ( oc )
786and
787.B \%orig_pair
788.RB ( op )
789capabilities in its
790.B init
791logic.
792.PP
793Keith Bostic refactored BSD
794.B tput
795for shipment in 4.3BSD-Tahoe (1988),
796then replaced it the next year with a new implementation based on
797System\ V
798.BR tput .
799Bostic's version similarly accepted some parameters named for
800.I \%term\%info
801(pseudo-)capabilities:
802.BR clear ,
803.BR init ,
804.BR \%longname ,
805and
806.BR \%reset .
807However,
808because he had only
809.I termcap
810available,
811it accepted
812.I termcap
813codes for other capabilities.
814Also,
815Bostic's BSD
816.B tput
817did not modify the terminal modes as the earlier BSD
818.B tset
819had done.
820.PP
821At the same time,
822Bostic added a shell script named \*(``clear\*('' that used
823.B tput
824to clear the screen.
825Both of these appeared in 4.4BSD,
826becoming the \*(``modern\*('' BSD implementation of
827.BR tput .
828.PP
829The origin of
830.I \%ncurses
831\fB\%@TPUT@\fP lies outside both System\ V and BSD,
832in Ross Ridge's
833.I \%mytinfo
834package,
835published on
836.I comp.sources.unix
837in December 1992.
838Ridge's program made more sophisticated use of the terminal capabilities
839than the BSD program.
840Eric Raymond used that
841.B tput
842program
843(and other parts of
844.IR \%mytinfo )
845in
846.I \%ncurses
847in June 1995.
848Incorporating the portions dealing with terminal capabilities
849almost without change,
850Raymond made improvements to the way command-line parameters
851were handled.
852.PP
853Before
854.I \%ncurses
8556.1 (2018),
856its \fB\%@TSET@\fP and \fB\%@TPUT@\fP utilities differed.
857.bP
858\fB\%@TSET@\fP was more effective,
859resetting the terminal modes and special characters.
860.bP
861On the other hand,
862\fB\%@TSET@\fP's repertoire of terminal capabilities for resetting the
863terminal was more limited;
864it had only equivalents of
865.B \%reset_1string
866.RB ( rs1 ),
867.B \%reset_2string
868.RB ( rs2 ),
869and
870.B \%reset_file
871.RB ( rf ),
872and not the tab stop and margin update features of \fB\%@TPUT@\fP.
873.PP
874The
875.B \%reset
876program is traditionally an alias for \fB\%@TSET@\fP due to its ability
877to reset terminal modes and special characters.
878.PP
879As of
880.I \%ncurses
8816.1,
882the \*(``reset\*('' features of the two programs are (mostly) the same.
883Two minor differences remain.
884.bP
885The \fB\%@TSET@\fP program waits one second when resetting,
886in case the terminal happens to be a hardware device.
887.bP
888The two programs write the terminal initialization strings
889to different streams;
890that is,
891standard error for \fB\%@TSET@\fP and
892standard output for \fB\%@TPUT@\fP.
893.SH EXAMPLES
894.TP
895.B "@TPUT@ init"
896Initialize the terminal according to the type of
897terminal in the
898.I TERM
899environment variable.
900If the system does not reliably initialize the terminal upon login,
901this command can be included in
902.I \%$HOME/.profile
903after exporting the
904.I TERM
905environment variable.
906.TP
907.B "@TPUT@ \-T5620 reset"
908Reset an AT&T 5620 terminal,
909overriding the terminal type in the
910.I TERM
911environment variable.
912.TP
913.B "@TPUT@ cnorm"
914Set cursor to normal visibility.
915.TP
916.B "@TPUT@ home"
917Move the cursor to row 0,
918column 0:
919the upper left corner of the screen,
920usually known as the \*(``home\*('' cursor position.
921.TP
922.B "@TPUT@ clear"
923Clear the screen:
924write the
925.B \%clear_screen
926capability's value to the standard output stream.
927.TP
928.B "@TPUT@ cols"
929Report the number of columns used by the current terminal type.
930.TP
931.B "@TPUT@ \-Tadm3a cols"
932Report the number of columns used by an ADM-3A terminal.
933.TP
934.B "strong=\(ga@TPUT@ smso\(ga normal=\(ga@TPUT@ rmso\(ga"
935Set shell variables to capability values:
936.B strong
937and
938.BR normal ,
939to begin and end,
940respectively,
941stand-out mode for the terminal.
942One might use these to present a prompt.
943.IP
944.EX
945.RS 14
946printf "${strong}Username:${normal} "
947.RE
948.EE
949.TP
950.B "@TPUT@ hc"
951Indicate via exit status whether the terminal is a hard copy device.
952.TP
953.B "@TPUT@ cup 23 4"
954Move the cursor to row 23,
955column 4.
956.TP
957.B "@TPUT@ cup"
958Report the value of the
959.B \%cursor_address
960.RB ( cup )
961capability
962(used for cursor movement),
963with no parameters substituted.
964.TP
965.B "@TPUT@ longname"
966Report the
967.I \%term\%info
968database's description of the terminal type specified in the
969.I TERM
970environment variable.
971.TP
972.B "@TPUT@ \-S"
973Process multiple capabilities.
974The
975.B \-S
976option can be profitably used with a shell \*(``here document\*(''.
977.IP
978.EX
979.RB $\ "@TPUT@ \-S <<!"
980.RB >\ clear
981.RB >\ "cup 10 10"
982.RB >\ bold
983.RB >\ !
984.EE
985.IP
986The foregoing
987clears the screen,
988moves the cursor to position
989(10, 10)
990and turns on bold
991(extra bright)
992mode.
993.TP
994.B "@TPUT@ clear cup 10 10 bold"
995Perform the same actions as the foregoing
996.RB \%\*(`` "@TPUT@ \-S" \*(''
997example.
998.SH SEE ALSO
999\fB\%@CLEAR@\fP(1),
1000\fB\%stty\fP(1),
1001\fB\%@TABS@\fP(1),
1002\fB\%@TSET@\fP(1),
1003\fB\%curs_termcap\fP(3X),
1004\fB\%terminfo\fP(5)