Skip to content

Commit

Permalink
Add .clearTerminal to clear the whole terminal, not just visible pa…
Browse files Browse the repository at this point in the history
…rt of it (#6)
  • Loading branch information
Vadim Demedes authored and sindresorhus committed Jan 28, 2019
1 parent e8a567f commit 9d3a0c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions index.js
Expand Up @@ -78,6 +78,15 @@ x.scrollUp = ESC + 'S';
x.scrollDown = ESC + 'T';

x.clearScreen = '\u001Bc';

x.clearTerminal = process.platform === 'win32' ?
`${x.eraseScreen}${ESC}0f` :
// 1. Erases the screen (Only done in case `2` is not supported)
// 2. Erases the whole screen including scrollback buffer
// 3. Moves cursor to the top-left position
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
`${x.eraseScreen}${ESC}3J${ESC}H`;

x.beep = BEL;

x.link = (text, url) => {
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Expand Up @@ -117,7 +117,11 @@ Scroll display down one line.

### clearScreen

Clear the terminal screen.
Clear the terminal screen. (Viewport)

### clearTerminal

Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)

### beep

Expand Down

0 comments on commit 9d3a0c8

Please sign in to comment.