]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/clear.1
ncurses 6.4 - patch 20230917
[ncurses.git] / man / clear.1
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,2017 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: clear.1,v 1.38 2023/09/16 23:39:05 tom Exp $
31 .TH @CLEAR@ 1 2023-09-16 "ncurses 6.4" "User commands"
32 .ie n .ds CW R
33 .el   \{
34 .ie \n(.g .ds CW CR
35 .el       .ds CW CW
36 .\}
37 .\" these would be fallbacks for DS/DE,
38 .\" but groff changed the meaning of the macros.
39 .de NS
40 .ie n  .sp
41 .el    .sp .5
42 .ie n  .in +4
43 .el    .in +2
44 .nf
45 .ft \*(CW
46 ..
47 .de NE
48 .fi
49 .ft R
50 .ie n  .in -4
51 .el    .in -2
52 ..
53 .ie \n(.g .ds `` \(lq
54 .el       .ds `` ``
55 .ie \n(.g .ds '' \(rq
56 .el       .ds '' ''
57 .de bP
58 .ie n  .IP \(bu 4
59 .el    .IP \(bu 2
60 ..
61 .ds n 5
62 .SH NAME
63 \fB\%@CLEAR@\fP \-
64 clear the terminal screen
65 .SH SYNOPSIS
66 \fB@CLEAR@\fR [\fB\-T\fItype\fR] [\fB\-V\fR] [\fB\-x\fR]
67 .SH DESCRIPTION
68 \fB@CLEAR@\fP clears your terminal's screen if this is possible,
69 including the terminal's scrollback buffer
70 (if the extended \*(``E3\*('' capability is defined).
71 \fB@CLEAR@\fP looks in the environment for the terminal type
72 given by the environment variable \fBTERM\fP,
73 and then in the
74 \fBterminfo\fP database to determine how to clear the screen.
75 .PP
76 \fB@CLEAR@\fP writes to the standard output.
77 You can redirect the standard output to a file (which prevents
78 \fB@CLEAR@\fP from actually clearing the screen),
79 and later \fBcat\fP the file to the screen, clearing it at that point.
80 .SH OPTIONS
81 .TP 5
82 .B \-T \fItype\fP
83 indicates the \fItype\fP of terminal.
84 Normally this option is
85 unnecessary, because the default is taken from the environment
86 variable \fBTERM\fP.
87 If \fB\-T\fP is specified, then the shell
88 variables \fBLINES\fP and \fBCOLUMNS\fP will also be ignored.
89 .TP
90 .B \-V
91 reports the version of ncurses which was used in this program, and exits.
92 The options are as follows:
93 .TP
94 .B \-x
95 do not attempt to clear the terminal's scrollback buffer
96 using the extended \*(``E3\*('' capability.
97 .SH HISTORY
98 A \fBclear\fP command appeared in 2.79BSD dated February 24, 1979.
99 Later that was provided in Unix 8th edition (1985).
100 .PP
101 AT&T adapted a different BSD program (\fBtset\fP) to make
102 a new command (\fBtput\fP),
103 and used this to replace the \fBclear\fP command with a shell script
104 which calls \fBtput clear\fP, e.g.,
105 .NS
106 /usr/bin/tput ${1:+-T$1} clear 2> /dev/null
107 exit
108 .NE
109 .PP
110 In 1989, when Keith Bostic revised the BSD \fBtput\fP command
111 to make it similar to the AT&T \fBtput\fP,
112 he added a shell script for the \fBclear\fP command:
113 .NS
114 exec tput clear
115 .NE
116 .PP
117 The remainder of the script in each case is a copyright notice.
118 .PP
119 The ncurses \fBclear\fP command began in 1995 by adapting the original
120 BSD \fBclear\fP command (with terminfo, of course).
121 .PP
122 The \fBE3\fP extension came later:
123 .bP
124 In June 1999, \fBxterm\fP provided an extension to the standard control
125 sequence for clearing the screen.
126 Rather than clearing just the visible part of the screen using
127 .NS
128 printf '\\033[2J'
129 .NE
130 .IP
131 one could clear the \fIscrollback\fP using
132 .NS
133 printf '\\033[\fB3\fPJ'
134 .NE
135 .IP
136 This is documented in \fIXTerm Control Sequences\fP as a feature originating
137 with \fBxterm\fP.
138 .bP
139 A few other terminal developers adopted the feature, e.g., PuTTY in 2006.
140 .bP
141 In April 2011, a Red Hat developer submitted a patch to the Linux
142 kernel, modifying its console driver to do the same thing.
143 The Linux change, part of the 3.0 release, did not mention \fBxterm\fP,
144 although it was cited in the Red Hat bug report (#683733)
145 which led to the change.
146 .bP
147 Again, a few other terminal developers adopted the feature.
148 But the
149 next relevant step was a change to the \fBclear\fP program in 2013
150 to incorporate this extension.
151 .bP
152 In 2013, the \fBE3\fP extension was overlooked in \fB@TPUT@\fP with
153 the \*(``clear\*('' parameter.
154 That was addressed in 2016 by reorganizing \fB@TPUT@\fP to share
155 its logic with \fB@CLEAR@\fP and \fB@TSET@\fP.
156 .SH PORTABILITY
157 Neither IEEE Std 1003.1/The Open  Group  Base  Specifications  Issue  7
158 (POSIX.1-2008) nor X/Open Curses Issue 7 documents @TSET@ or @RESET@.
159 .PP
160 The latter documents \fBtput\fP, which could be used to replace this utility
161 either via a shell script or by an alias (such as a symbolic link) to
162 run \fB@TPUT@\fP as \fB@CLEAR@\fP.
163 .SH SEE ALSO
164 \fB@TPUT@\fP(1),
165 \fBxterm\fP(1),
166 \fBterminfo\fP(\*n).
167 .PP
168 This describes \fBncurses\fP
169 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).