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