| 1 | # sister ANSI [](https://www.npmjs.com/package/sisteransi) [](https://travis-ci.org/terkelg/sisteransi) [](https://www.npmjs.com/package/sisteransi)
|
|---|
| 2 |
|
|---|
| 3 | > Ansi escape codes faster than you can say "[Bam bam](https://www.youtube.com/watch?v=OcaPu9JPenU)".
|
|---|
| 4 |
|
|---|
| 5 | ## Installation
|
|---|
| 6 |
|
|---|
| 7 | ```
|
|---|
| 8 | npm install sisteransi
|
|---|
| 9 | ```
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | ## Usage
|
|---|
| 13 |
|
|---|
| 14 | ```js
|
|---|
| 15 | const ansi = require('sisteransi');
|
|---|
| 16 | // or const { cursor } = require('sisteransi');
|
|---|
| 17 |
|
|---|
| 18 | const p = str => process.stdout.write(str);
|
|---|
| 19 |
|
|---|
| 20 | // move cursor to 2, 1
|
|---|
| 21 | p(ansi.cursor.to(2, 1));
|
|---|
| 22 |
|
|---|
| 23 | // to up, one down
|
|---|
| 24 | p(ansi.cursor.up(2)+ansi.cursor.down(1));
|
|---|
| 25 | ```
|
|---|
| 26 |
|
|---|
| 27 | ## API
|
|---|
| 28 |
|
|---|
| 29 | ### cursor
|
|---|
| 30 |
|
|---|
| 31 | #### to(x, y)
|
|---|
| 32 | Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.
|
|---|
| 33 |
|
|---|
| 34 | #### move(x, y)
|
|---|
| 35 | Set the position of the cursor relative to its current position.
|
|---|
| 36 |
|
|---|
| 37 | #### up(count = 1)
|
|---|
| 38 | Move cursor up a specific amount of rows. Default is `1`.
|
|---|
| 39 |
|
|---|
| 40 | #### down(count = 1)
|
|---|
| 41 | Move cursor down a specific amount of rows. Default is `1`.
|
|---|
| 42 |
|
|---|
| 43 | #### forward(count = 1)
|
|---|
| 44 | Move cursor forward a specific amount of rows. Default is `1`.
|
|---|
| 45 |
|
|---|
| 46 | #### backward(count = 1)
|
|---|
| 47 | Move cursor backward a specific amount of rows. Default is `1`.
|
|---|
| 48 |
|
|---|
| 49 | #### nextLine(count = 1)
|
|---|
| 50 | Move cursor to the next line a specific amount of lines. Default is `1`.
|
|---|
| 51 |
|
|---|
| 52 | #### prevLine(count = 1)
|
|---|
| 53 | Move cursor to the previous a specific amount of lines. Default is `1`.
|
|---|
| 54 |
|
|---|
| 55 | #### left
|
|---|
| 56 | Move cursor to the left side.
|
|---|
| 57 |
|
|---|
| 58 | #### hide
|
|---|
| 59 | Hide cursor.
|
|---|
| 60 |
|
|---|
| 61 | #### show
|
|---|
| 62 | Show cursor.
|
|---|
| 63 |
|
|---|
| 64 | #### save
|
|---|
| 65 |
|
|---|
| 66 | Save cursor position.
|
|---|
| 67 |
|
|---|
| 68 | #### restore
|
|---|
| 69 |
|
|---|
| 70 | Restore cursor position.
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | ### scroll
|
|---|
| 74 |
|
|---|
| 75 | #### up(count = 1)
|
|---|
| 76 | Scroll display up a specific amount of lines. Default to `1`.
|
|---|
| 77 |
|
|---|
| 78 | #### down(count = 1)
|
|---|
| 79 | Scroll display down a specific amount of lines. Default to `1`.
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | ### erase
|
|---|
| 83 |
|
|---|
| 84 | #### screen
|
|---|
| 85 | Erase the screen and move the cursor the top left position.
|
|---|
| 86 |
|
|---|
| 87 | #### up(count = 1)
|
|---|
| 88 | Erase the screen from the current line up to the top of the screen. Default to `1`.
|
|---|
| 89 |
|
|---|
| 90 | #### down(count = 2)
|
|---|
| 91 | Erase the screen from the current line down to the bottom of the screen. Default to `1`.
|
|---|
| 92 |
|
|---|
| 93 | #### line
|
|---|
| 94 | Erase the entire current line.
|
|---|
| 95 |
|
|---|
| 96 | #### lineEnd
|
|---|
| 97 | Erase from the current cursor position to the end of the current line.
|
|---|
| 98 |
|
|---|
| 99 | #### lineStart
|
|---|
| 100 | Erase from the current cursor position to the start of the current line.
|
|---|
| 101 |
|
|---|
| 102 | #### lines(count)
|
|---|
| 103 | Erase from the current cursor position up the specified amount of rows.
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | ## Credit
|
|---|
| 107 |
|
|---|
| 108 | This is a fork of [ansi-escapes](https://github.com/sindresorhus/ansi-escapes).
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 | ## License
|
|---|
| 112 |
|
|---|
| 113 | MIT © [Terkel Gjervig](https://terkel.com)
|
|---|