xref: /freebsd/contrib/ncurses/man/clear.1 (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
***************************************************************************
Copyright 2018-2023,2024 Thomas E. Dickey *
Copyright 1998-2016,2017 Free Software Foundation, Inc. *
*
Permission is hereby granted, free of charge, to any person obtaining a *
copy of this software and associated documentation files (the *
"Software"), to deal in the Software without restriction, including *
without limitation the rights to use, copy, modify, merge, publish, *
distribute, distribute with modifications, sublicense, and/or sell *
copies of the Software, and to permit persons to whom the Software is *
furnished to do so, subject to the following conditions: *
*
The above copyright notice and this permission notice shall be included *
in all copies or substantial portions of the Software. *
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*
Except as contained in this notice, the name(s) of the above copyright *
holders shall not be used in advertising or otherwise to promote the *
sale, use or other dealings in this Software without prior written *
authorization. *
***************************************************************************

$Id: clear.1,v 1.48 2024/03/16 15:35:01 tom Exp $
@CLEAR@ 1 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
.\} .\} . .. .
NAME
\%@CLEAR@ - clear the terminal screen
SYNOPSIS
@CLEAR@ [ -x ] [ -T \c terminal-type ]

"@CLEAR@ -V"

DESCRIPTION
\%@CLEAR@ clears your terminal's screen and its scrollback buffer, if any. \%@CLEAR@ retrieves the terminal type from the environment variable TERM, then consults the terminfo terminal capability database entry for that type to determine how to perform these actions.

The capabilities to clear the screen and scrollback buffer are named \*(``clear\*('' and \*(``E3\*('', respectively. The latter is a user-defined capability, applying an extension mechanism introduced in \%ncurses 5.0 (1999).

OPTIONS
\%@CLEAR@ recognizes the following options.

9 \" "-T type" + 2n -T type produces instructions suitable for the terminal type. Normally, this option is unnecessary, because the terminal type is inferred from the environment variable TERM. If this option is specified, \%@CLEAR@ ignores the environment variables LINES and \%COLUMNS as well.

-V reports the version of \%ncurses associated with this program and exits with a successful status.

-x prevents \%@CLEAR@ from attempting to clear the scrollback buffer.

PORTABILITY
Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) nor X/Open Curses Issue 7 documents \%@CLEAR@.

The latter documents tput, which could be used to replace this utility either via a shell script or by an alias (such as a symbolic link) to run \%@TPUT@ as \%@CLEAR@.

HISTORY
A clear command using the termcap database and library appeared in 2BSD (1979). https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/clear.c
Eighth Edition Unix (1985) later included it.

The commercial Unix arm of AT&T adapted a different BSD program (tset) to make a new command, tput, and replaced the clear program with a shell script that called \*(``tput clear\*(''.

.EX /usr/bin/tput ${1:+-T$1} clear 2> /dev/null exit

In 1989, when Keith Bostic revised the BSD tput command to make it similar to AT&T's tput, he added a clear shell script as well. https://minnie.tuhs.org/cgi-bin/utree.pl?file=Net2/usr/src/usr.bin/\
tput/clear.sh

.EX exec tput clear

The remainder of the script in each case is a copyright notice.

In 1995, \%ncurses's clear began by adapting BSD's original clear command to use terminfo. The E3 extension came later. .bP In June 1999, xterm provided an extension to the standard control sequence for clearing the screen. Rather than clearing just the visible part of the screen using

.EX printf \*'\e033[2J\*'

one could clear the scrollback buffer as well by using

.EX printf \*'\e033[3J\*'

instead. \*(``XTerm Control Sequences\*('' documents this feature as originating with xterm. .bP A few other terminal emulators adopted it, such as PuTTY in 2006. .bP In April 2011, a Red Hat developer submitted a patch to the Linux kernel, modifying its console driver to do the same thing. Documentation of this change, appearing in Linux 3.0, did not mention xterm, although that program was cited in the Red Hat bug report (#683733) motivating the feature. .bP Subsequently, more terminal developers adopted the feature. The next relevant step was to change the \%ncurses clear program in 2013 to incorporate this extension. .bP In 2013, the E3 capability was not exercised by \*(``\%@TPUT@ clear\*(''. That oversight was addressed in 2016 by reorganizing \%@TPUT@ to share its logic with \%@CLEAR@ and \%@TSET@.
SEE ALSO
\%@TPUT@(1), \%xterm(1), \%terminfo(5)