[6a3a178] | 1 | 'use strict';
|
---|
| 2 | const ansiEscapes = require('ansi-escapes');
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Move cursor left by `x`
|
---|
| 6 | * @param {Readline} rl - Readline instance
|
---|
| 7 | * @param {Number} x - How far to go left (default to 1)
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | exports.left = function (rl, x) {
|
---|
| 11 | rl.output.write(ansiEscapes.cursorBackward(x));
|
---|
| 12 | };
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | * Move cursor right by `x`
|
---|
| 16 | * @param {Readline} rl - Readline instance
|
---|
| 17 | * @param {Number} x - How far to go left (default to 1)
|
---|
| 18 | */
|
---|
| 19 |
|
---|
| 20 | exports.right = function (rl, x) {
|
---|
| 21 | rl.output.write(ansiEscapes.cursorForward(x));
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * Move cursor up by `x`
|
---|
| 26 | * @param {Readline} rl - Readline instance
|
---|
| 27 | * @param {Number} x - How far to go up (default to 1)
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | exports.up = function (rl, x) {
|
---|
| 31 | rl.output.write(ansiEscapes.cursorUp(x));
|
---|
| 32 | };
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | * Move cursor down by `x`
|
---|
| 36 | * @param {Readline} rl - Readline instance
|
---|
| 37 | * @param {Number} x - How far to go down (default to 1)
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | exports.down = function (rl, x) {
|
---|
| 41 | rl.output.write(ansiEscapes.cursorDown(x));
|
---|
| 42 | };
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
| 45 | * Clear current line
|
---|
| 46 | * @param {Readline} rl - Readline instance
|
---|
| 47 | * @param {Number} len - number of line to delete
|
---|
| 48 | */
|
---|
| 49 | exports.clearLine = function (rl, len) {
|
---|
| 50 | rl.output.write(ansiEscapes.eraseLines(len));
|
---|
| 51 | };
|
---|