wishthis/node_modules/inquirer/lib/utils/readline.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-01-21 08:28:41 +00:00
'use strict';
2022-05-29 09:24:36 +00:00
var ansiEscapes = require('ansi-escapes');
2022-01-21 08:28:41 +00:00
/**
* Move cursor left by `x`
* @param {Readline} rl - Readline instance
* @param {Number} x - How far to go left (default to 1)
*/
2022-05-29 09:24:36 +00:00
exports.left = function(rl, x) {
2022-01-21 08:28:41 +00:00
rl.output.write(ansiEscapes.cursorBackward(x));
};
/**
* Move cursor right by `x`
* @param {Readline} rl - Readline instance
* @param {Number} x - How far to go left (default to 1)
*/
2022-05-29 09:24:36 +00:00
exports.right = function(rl, x) {
2022-01-21 08:28:41 +00:00
rl.output.write(ansiEscapes.cursorForward(x));
};
/**
* Move cursor up by `x`
* @param {Readline} rl - Readline instance
* @param {Number} x - How far to go up (default to 1)
*/
2022-05-29 09:24:36 +00:00
exports.up = function(rl, x) {
2022-01-21 08:28:41 +00:00
rl.output.write(ansiEscapes.cursorUp(x));
};
/**
* Move cursor down by `x`
* @param {Readline} rl - Readline instance
* @param {Number} x - How far to go down (default to 1)
*/
2022-05-29 09:24:36 +00:00
exports.down = function(rl, x) {
2022-01-21 08:28:41 +00:00
rl.output.write(ansiEscapes.cursorDown(x));
};
/**
* Clear current line
* @param {Readline} rl - Readline instance
* @param {Number} len - number of line to delete
*/
2022-05-29 09:24:36 +00:00
exports.clearLine = function(rl, len) {
2022-01-21 08:28:41 +00:00
rl.output.write(ansiEscapes.eraseLines(len));
};