]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/clear.1
ncurses 6.1 - patch 20191019
[ncurses.git] / man / clear.1
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2017,2018 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: clear.1,v 1.22 2018/07/28 21:45:40 tom Exp $
30 .TH @CLEAR@ 1 ""
31 .\" these would be fallbacks for DS/DE,
32 .\" but groff changed the meaning of the macros.
33 .de NS
34 .ie n  .sp
35 .el    .sp .5
36 .ie n  .in +4
37 .el    .in +2
38 .nf
39 .ft C                   \" Courier
40 ..
41 .de NE
42 .fi
43 .ft R
44 .ie n  .in -4
45 .el    .in -2
46 ..
47 .ie \n(.g .ds `` \(lq
48 .el       .ds `` ``
49 .ie \n(.g .ds '' \(rq
50 .el       .ds '' ''
51 .de bP
52 .ie n  .IP \(bu 4
53 .el    .IP \(bu 2
54 ..
55 .ds n 5
56 .SH NAME
57 \fB@CLEAR@\fR \- clear the terminal screen
58 .SH SYNOPSIS
59 \fB@CLEAR@\fR [\fB\-T\fR\fItype\fR] [\fB\-V\fP] [\fB\-x\fP]
60 .br
61 .SH DESCRIPTION
62 \fB@CLEAR@\fR clears your screen if this is possible,
63 including its scrollback buffer
64 (if the extended \*(``E3\*('' capability is defined).
65 \fB@CLEAR@\fR looks in the environment for the terminal type
66 given by the environment variable \fBTERM\fP,
67 and then in the
68 \fBterminfo\fR database to determine how to clear the screen.
69 .PP
70 \fB@CLEAR@\fR writes to the standard output.
71 You can redirect the standard output to a file (which prevents
72 \fB@CLEAR@\fR from actually clearing the screen),
73 and later \fBcat\fP the file to the screen, clearing it at that point.
74 .SH OPTIONS
75 .PP
76 .TP 5
77 .B \-T \fItype\fP
78 indicates the \fItype\fR of terminal.
79 Normally this option is
80 unnecessary, because the default is taken from the environment
81 variable \fBTERM\fR.
82 If \fB\-T\fR is specified, then the shell
83 variables \fBLINES\fR and \fBCOLUMNS\fR will also be ignored.
84 .TP
85 .B \-V
86 reports the version of ncurses which was used in this program, and exits.
87 The options are as follows:
88 .TP
89 .B \-x
90 do not attempt to clear the terminal's scrollback buffer
91 using the extended \*(``E3\*('' capability.
92 .SH HISTORY
93 A \fBclear\fP command appeared in 2.79BSD dated February 24, 1979.
94 Later that was provided in Unix 8th edition (1985).
95 .PP
96 AT&T adapted a different BSD program (\fBtset\fP) to make
97 a new command (\fBtput\fP),
98 and used this to replace the \fBclear\fP command with a shell script
99 which calls \fBtput clear\fP, e.g.,
100 .NS
101 /usr/bin/tput ${1:+-T$1} clear 2> /dev/null
102 exit
103 .NE
104 .PP
105 In 1989, when Keith Bostic revised the BSD \fBtput\fP command
106 to make it similar to the AT&T \fBtput\fP,
107 he added a shell script for the \fBclear\fP command:
108 .NS
109 exec tput clear
110 .NE
111 .PP
112 The remainder of the script in each case is a copyright notice.
113 .PP
114 The ncurses \fBclear\fP command began in 1995 by adapting the original
115 BSD \fBclear\fP command (with terminfo, of course).
116 .PP
117 The \fBE3\fP extension came later:
118 .bP
119 In June 1999, xterm provided an extension to the standard control
120 sequence for clearing the screen.
121 Rather than clearing just the visible part of the screen using
122 .NS
123 printf '\\033[2J'
124 .NE
125 .IP
126 one could clear the \fIscrollback\fP using
127 .NS
128 printf '\\033[\fB3\fPJ'
129 .NE
130 .IP
131 This is documented in \fIXTerm Control Sequences\fP as a feature originating
132 with xterm.
133 .bP
134 A few other terminal developers adopted the feature, e.g., PuTTY in 2006.
135 .bP
136 In April 2011, a Red Hat developer submitted a patch to the Linux
137 kernel, modifying its console driver to do the same thing.
138 The Linux change, part of the 3.0 release, did not mention xterm,
139 although it was cited in the Red Hat bug report (#683733)
140 which led to the change.
141 .bP
142 Again, a few other terminal developers adopted the feature.
143 But the
144 next relevant step was a change to the \fBclear\fP program in 2013
145 to incorporate this extension.
146 .bP
147 In 2013, the \fBE3\fP extension was overlooked in \fB@TPUT@\fP with
148 the \*(``clear\*('' parameter.
149 That was addressed in 2016 by reorganizing \fB@TPUT@\fP to share
150 its logic with \fB@CLEAR@\fP and \fB@TSET@\fP.
151 .SH PORTABILITY
152 Neither IEEE Std 1003.1/The Open  Group  Base  Specifications  Issue  7
153 (POSIX.1-2008) nor X/Open Curses Issue 7 documents @TSET@ or @RESET@.
154 .PP
155 The latter documents \fBtput\fP, which could be used to replace this utility
156 either via a shell script or by an alias (such as a symbolic link) to
157 run \fB@TPUT@\fP as \fB@CLEAR@\fP.
158 .SH SEE ALSO
159 \fB@TPUT@\fR(1), \fBterminfo\fR(\*n)
160 .PP
161 This describes \fBncurses\fR
162 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).