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