Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 16, 2023
1 parent b359b30 commit fa3d1b3
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ npm install ansi-escapes

## Usage

### Use within terminal

```js
import ansiEscapes from 'ansi-escapes';

Expand All @@ -20,18 +18,17 @@ process.stdout.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);
//=> '\u001B[2A\u001B[1000D'
```

### Use with xterm.js
**You can also use it in the browser with Xterm.js:**

```js
import ansiEscapes from 'ansi-escapes';
import { Terminal } from 'xterm';
import {Terminal} from 'xterm';
import 'xterm/css/xterm.css';

...
const term = new Terminal({...});
...
const terminal = new Terminal({…});

// Moves the cursor two rows up and to the left
term.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);
terminal.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);
//=> '\u001B[2A\u001B[1000D'
```

Expand Down

0 comments on commit fa3d1b3

Please sign in to comment.