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