3 // These tables borrowed from `ansi`
7 exports.up = function up (num) {
8 return prefix + (num || '') + 'A'
11 exports.down = function down (num) {
12 return prefix + (num || '') + 'B'
15 exports.forward = function forward (num) {
16 return prefix + (num || '') + 'C'
19 exports.back = function back (num) {
20 return prefix + (num || '') + 'D'
23 exports.nextLine = function nextLine (num) {
24 return prefix + (num || '') + 'E'
27 exports.previousLine = function previousLine (num) {
28 return prefix + (num || '') + 'F'
31 exports.horizontalAbsolute = function horizontalAbsolute (num) {
32 if (num == null) throw new Error('horizontalAboslute requires a column to position to')
33 return prefix + num + 'G'
36 exports.eraseData = function eraseData () {
40 exports.eraseLine = function eraseLine () {
44 exports.goto = function (x, y) {
45 return prefix + y + ';' + x + 'H'
48 exports.gotoSOL = function () {
52 exports.beep = function () {
56 exports.hideCursor = function hideCursor () {
57 return prefix + '?25l'
60 exports.showCursor = function showCursor () {
61 return prefix + '?25h'
110 bgBrightMagenta: 105,
115 exports.color = function color (colorWith) {
116 if (arguments.length !== 1 || !Array.isArray(colorWith)) {
117 colorWith = Array.prototype.slice.call(arguments)
119 return prefix + colorWith.map(colorNameToCode).join(';') + 'm'
122 function colorNameToCode (color) {
123 if (colors[color] != null) return colors[color]
124 throw new Error('Unknown color or style name: ' + color)