Comparing version 1.2.0 to 1.3.0
10
art.js
@@ -1,9 +0,9 @@ | ||
'use strict'; | ||
"use strict"; | ||
var object = require('es5-ext/object/valid-object') | ||
, stringifiable = require('es5-ext/object/validate-stringifiable-value') | ||
, forOf = require('es6-iterator/for-of'); | ||
var object = require("es5-ext/object/valid-object") | ||
, stringifiable = require("es5-ext/object/validate-stringifiable-value") | ||
, forOf = require("es6-iterator/for-of"); | ||
module.exports = function (text, style) { | ||
var result = ''; | ||
var result = ""; | ||
text = stringifiable(text); | ||
@@ -10,0 +10,0 @@ object(style); |
46
bare.js
@@ -1,13 +0,13 @@ | ||
'use strict'; | ||
"use strict"; | ||
var d = require('d') | ||
, assign = require('es5-ext/object/assign') | ||
, forEach = require('es5-ext/object/for-each') | ||
, map = require('es5-ext/object/map') | ||
, primitiveSet = require('es5-ext/object/primitive-set') | ||
, setPrototypeOf = require('es5-ext/object/set-prototype-of') | ||
, memoize = require('memoizee') | ||
, memoizeMethods = require('memoizee/methods') | ||
var d = require("d") | ||
, assign = require("es5-ext/object/assign") | ||
, forEach = require("es5-ext/object/for-each") | ||
, map = require("es5-ext/object/map") | ||
, primitiveSet = require("es5-ext/object/primitive-set") | ||
, setPrototypeOf = require("es5-ext/object/set-prototype-of") | ||
, memoize = require("memoizee") | ||
, memoizeMethods = require("memoizee/methods") | ||
, sgr = require('./lib/sgr') | ||
, sgr = require("./lib/sgr") | ||
, mods = sgr.mods | ||
@@ -17,3 +17,3 @@ | ||
, max = Math.max, min = Math.min | ||
, variantModes = primitiveSet('_fg', '_bg') | ||
, variantModes = primitiveSet("_fg", "_bg") | ||
, xtermMatch, getFn; | ||
@@ -25,3 +25,3 @@ | ||
var memoized = memoize(function (scope, mod) { | ||
return defineProperty(getFn(), '_cliColorData', d(assign({}, scope._cliColorData, mod))); | ||
return defineProperty(getFn(), "_cliColorData", d(assign({}, scope._cliColorData, mod))); | ||
}); | ||
@@ -35,5 +35,5 @@ | ||
code = isNaN(code) ? 255 : min(max(code, 0), 255); | ||
return defineProperty(getFn(), '_cliColorData', | ||
return defineProperty(getFn(), "_cliColorData", | ||
d(assign({}, this._cliColorData, { | ||
_fg: [xtermMatch ? xtermMatch[code] : ('38;5;' + code), 39] | ||
_fg: [xtermMatch ? xtermMatch[code] : "38;5;" + code, 39] | ||
}))); | ||
@@ -43,5 +43,5 @@ }), | ||
code = isNaN(code) ? 255 : min(max(code, 0), 255); | ||
return defineProperty(getFn(), '_cliColorData', | ||
return defineProperty(getFn(), "_cliColorData", | ||
d(assign({}, this._cliColorData, { | ||
_bg: [xtermMatch ? (xtermMatch[code] + 10) : ('48;5;' + code), 49] | ||
_bg: [xtermMatch ? xtermMatch[code] + 10 : "48;5;" + code, 49] | ||
}))); | ||
@@ -52,16 +52,16 @@ }) | ||
var getEndRe = memoize(function (code) { | ||
return new RegExp('\x1b\\[' + code + 'm', 'g'); | ||
return new RegExp("\x1b\\[" + code + "m", "g"); | ||
}, { primitive: true }); | ||
if (process.platform === 'win32') xtermMatch = require('./lib/xterm-match'); | ||
if (process.platform === "win32") xtermMatch = require("./lib/xterm-match"); | ||
getFn = function () { | ||
return setPrototypeOf(function self(/*…msg*/) { | ||
var start = '', end = '', msg = join.call(arguments, ' '), conf = self._cliColorData | ||
return setPrototypeOf(function self(/* …msg*/) { | ||
var start = "", end = "", msg = join.call(arguments, " "), conf = self._cliColorData | ||
, hasAnsi = sgr.hasCSI(msg); | ||
forEach(conf, function (mod, key) { | ||
end = sgr(mod[1]) + end; | ||
end = sgr(mod[1]) + end; | ||
start += sgr(mod[0]); | ||
if (hasAnsi) { | ||
msg = msg.replace(getEndRe(mod[1]), variantModes[key] ? sgr(mod[0]) : ''); | ||
msg = msg.replace(getEndRe(mod[1]), variantModes[key] ? sgr(mod[0]) : ""); | ||
} | ||
@@ -75,3 +75,3 @@ }, null, true); | ||
xtermSupported: d(!xtermMatch), | ||
_cliColorData: d('', {}) | ||
_cliColorData: d("", {}) | ||
}); |
@@ -1,3 +0,3 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = '\x07'; | ||
module.exports = "\x07"; |
@@ -1,30 +0,56 @@ | ||
'use strict'; | ||
"use strict"; | ||
var from = require('es5-ext/array/from') | ||
, iterable = require('es5-ext/iterable/validate-object') | ||
, stringifiable = require('es5-ext/object/validate-stringifiable') | ||
, repeat = require('es5-ext/string/#/repeat') | ||
, getStrippedLength = require('./get-stripped-length'); | ||
var generate = require("es5-ext/array/generate") | ||
, from = require("es5-ext/array/from") | ||
, iterable = require("es5-ext/iterable/validate-object") | ||
, isValue = require("es5-ext/object/is-value") | ||
, stringifiable = require("es5-ext/object/validate-stringifiable") | ||
, repeat = require("es5-ext/string/#/repeat") | ||
, getStrippedLength = require("./get-stripped-length"); | ||
module.exports = function (rows/*, options*/) { | ||
var options = Object(arguments[1]), cols = [] | ||
, colsOptions = options.columns || []; | ||
return from(iterable(rows), function (row, index) { | ||
return from(iterable(row), function (str, index) { | ||
var col = cols[index], strLength; | ||
if (!col) col = cols[index] = { width: 0 }; | ||
str = stringifiable(str); | ||
strLength = getStrippedLength(str); | ||
if (strLength > col.width) col.width = strLength; | ||
return { str: str, length: strLength }; | ||
var push = Array.prototype.push; | ||
module.exports = function (inputRows/*, options*/) { | ||
var options = Object(arguments[1]) | ||
, colsMeta = [] | ||
, colsOptions = options.columns || [] | ||
, rows = []; | ||
from(iterable(inputRows), function (row) { | ||
var rowRows = [[]]; | ||
from(iterable(row), function (cellStr, columnIndex) { | ||
var cellRows = stringifiable(cellStr).split("\n"); | ||
while (cellRows.length > rowRows.length) rowRows.push(generate(columnIndex, "")); | ||
cellRows.forEach(function (cellRow, rowRowIndex) { | ||
rowRows[rowRowIndex][columnIndex] = cellRow; | ||
}); | ||
}); | ||
}).map(function (row) { | ||
return row.map(function (item, index) { | ||
var pad, align = 'left', colOptions = colsOptions && colsOptions[index]; | ||
align = (colOptions && (colOptions.align === 'right')) ? 'right' : 'left'; | ||
pad = repeat.call(' ', cols[index].width - item.length); | ||
if (align === 'left') return item.str + pad; | ||
return pad + item.str; | ||
}).join((options.sep == null) ? ' | ' : options.sep); | ||
}).join('\n') + '\n'; | ||
push.apply(rows, rowRows); | ||
}); | ||
return ( | ||
rows | ||
.map(function (row) { | ||
return from(iterable(row), function (str, index) { | ||
var col = colsMeta[index], strLength; | ||
if (!col) col = colsMeta[index] = { width: 0 }; | ||
str = stringifiable(str); | ||
strLength = getStrippedLength(str); | ||
if (strLength > col.width) col.width = strLength; | ||
return { str: str, length: strLength }; | ||
}); | ||
}) | ||
.map(function (row) { | ||
return row | ||
.map(function (item, index) { | ||
var pad, align = "left", colOptions = colsOptions && colsOptions[index]; | ||
align = colOptions && colOptions.align === "right" ? "right" : "left"; | ||
pad = repeat.call(" ", colsMeta[index].width - item.length); | ||
if (align === "left") return item.str + pad; | ||
return pad + item.str; | ||
}) | ||
.join(isValue(options.sep) ? options.sep : " | "); | ||
}) | ||
.join("\n") + "\n" | ||
); | ||
}; |
14
erase.js
@@ -1,10 +0,10 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = { | ||
screen: '\x1b[2J', | ||
screenLeft: '\x1b[1J', | ||
screenRight: '\x1b[J', | ||
line: '\x1b[2K', | ||
lineLeft: '\x1b[1K', | ||
lineRight: '\x1b[K' | ||
screen: "\x1b[2J", | ||
screenLeft: "\x1b[1J", | ||
screenRight: "\x1b[J", | ||
line: "\x1b[2K", | ||
lineLeft: "\x1b[1K", | ||
lineRight: "\x1b[K" | ||
}; |
@@ -1,8 +0,8 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('../'); | ||
var clc = require("../"); | ||
var text = '.........\n' + '. Hello .\n' + '.........\n'; | ||
var text = ".........\n. Hello .\n.........\n"; | ||
var style = { ".": clc.yellowBright("X") }; | ||
process.stdout.write(clc.art(text, style)); |
@@ -1,18 +0,18 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('../'); | ||
var clc = require("../"); | ||
console.log('Output colored text:'); | ||
console.log(clc.red('Text in red')); | ||
console.log("Output colored text:"); | ||
console.log(clc.red("Text in red")); | ||
console.log('Styles can be mixed:'); | ||
console.log(clc.red.bgWhite.underline('Underlined red text on white background.')); | ||
console.log("Styles can be mixed:"); | ||
console.log(clc.red.bgWhite.underline("Underlined red text on white background.")); | ||
console.log('Styled text can be mixed with unstyled:'); | ||
console.log(clc.red('red') + ' plain ' + clc.blue('blue')); | ||
console.log("Styled text can be mixed with unstyled:"); | ||
console.log(clc.red("red") + " plain " + clc.blue("blue")); | ||
console.log('Styled text can be nested:'); | ||
console.log(clc.red('red ' + clc.blue('blue') + ' red')); | ||
console.log("Styled text can be nested:"); | ||
console.log(clc.red("red " + clc.blue("blue") + " red")); | ||
console.log('Best way is to predefine needed stylings and then use it:'); | ||
console.log("Best way is to predefine needed stylings and then use it:"); | ||
@@ -23,4 +23,4 @@ var error = clc.red.bold; | ||
console.log(error('Error!')); | ||
console.log(warn('Warning')); | ||
console.log(notice('Notice')); | ||
console.log(error("Error!")); | ||
console.log(warn("Warning")); | ||
console.log(notice("Notice")); |
@@ -1,6 +0,6 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('../'); | ||
var clc = require("../"); | ||
console.log('Erasing screen ..'); | ||
console.log("Erasing screen .."); | ||
@@ -10,8 +10,8 @@ setTimeout(function () { | ||
console.log('This a line of text that should not be cleared'); | ||
process.stdout.write('This line will be cleared but cursor will be here ->'); | ||
console.log("This a line of text that should not be cleared"); | ||
process.stdout.write("This line will be cleared but cursor will be here ->"); | ||
setTimeout(function () { | ||
process.stdout.write(clc.erase.line); | ||
process.stdout.write('\nMoving cursor backwards and deleting (from here): to the right'); | ||
process.stdout.write("\nMoving cursor backwards and deleting (from here): to the right"); | ||
@@ -21,7 +21,4 @@ setTimeout(function () { | ||
process.stdout.write(clc.erase.lineRight); | ||
setTimeout(function () {}, 2000); | ||
}, 2000); | ||
}, 2000); | ||
}, 2000); |
@@ -1,10 +0,10 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('../'); | ||
var clc = require("../"); | ||
console.log(clc.bold('Bold text')); | ||
console.log(clc.italic('Italic text')); | ||
console.log(clc.underline('Underlined text')); | ||
console.log(clc.blink('Blinking text (might not work for your font)')); | ||
console.log(clc.inverse('Inverse text')); | ||
console.log(clc.strike('Strikethrough text')); | ||
console.log(clc.bold("Bold text")); | ||
console.log(clc.italic("Italic text")); | ||
console.log(clc.underline("Underlined text")); | ||
console.log(clc.blink("Blinking text (might not work for your font)")); | ||
console.log(clc.inverse("Inverse text")); | ||
console.log(clc.strike("Strikethrough text")); |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
"use strict"; | ||
var setupThrobber = require('../throbber'); | ||
var setupThrobber = require("../throbber"); | ||
@@ -9,3 +9,3 @@ var throbber = setupThrobber(function (str) { | ||
process.stdout.write('Throbbing for 3 seconds here -> '); | ||
process.stdout.write("Throbbing for 3 seconds here -> "); | ||
throbber.start(); | ||
@@ -12,0 +12,0 @@ |
@@ -1,6 +0,6 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('../'); | ||
var clc = require("../"); | ||
var msg = clc.xterm(202).bgXterm(236); | ||
console.log(msg('Orange text on dark gray background')); | ||
console.log(msg("Orange text on dark gray background")); |
@@ -1,2 +0,3 @@ | ||
'use strict'; | ||
"use strict"; | ||
/* | ||
@@ -6,3 +7,3 @@ * get actual length of ANSI-formatted string | ||
var strip = require('./strip'); | ||
var strip = require("./strip"); | ||
@@ -9,0 +10,0 @@ module.exports = function (str) { |
28
index.js
@@ -1,17 +0,17 @@ | ||
'use strict'; | ||
"use strict"; | ||
var d = require('d'); | ||
var d = require("d"); | ||
module.exports = Object.defineProperties(require('./bare'), { | ||
windowSize: d(require('./window-size')), | ||
erase: d(require('./erase')), | ||
move: d(require('./move')), | ||
beep: d(require('./beep')), | ||
columns: d(require('./columns')), | ||
strip: d(require('./strip')), | ||
getStrippedLength: d(require('./get-stripped-length')), | ||
slice: d(require('./slice')), | ||
throbber: d(require('./throbber')), | ||
reset: d(require('./reset')), | ||
art: d(require('./art')) | ||
module.exports = Object.defineProperties(require("./bare"), { | ||
windowSize: d(require("./window-size")), | ||
erase: d(require("./erase")), | ||
move: d(require("./move")), | ||
beep: d(require("./beep")), | ||
columns: d(require("./columns")), | ||
strip: d(require("./strip")), | ||
getStrippedLength: d(require("./get-stripped-length")), | ||
slice: d(require("./slice")), | ||
throbber: d(require("./throbber")), | ||
reset: d(require("./reset")), | ||
art: d(require("./art")) | ||
}); |
@@ -1,42 +0,47 @@ | ||
'use strict'; | ||
"use strict"; | ||
/* CSI - control sequence introducer */ | ||
/* SGR - set graphic rendition */ | ||
var assign = require('es5-ext/object/assign') | ||
, includes = require('es5-ext/string/#/contains') | ||
, forOwn = require('es5-ext/object/for-each') | ||
, onlyKey = require('es5-ext/object/first-key') | ||
, forEachRight = require('es5-ext/array/#/for-each-right') | ||
, uniq = require('es5-ext/array/#/uniq.js'); | ||
var assign = require("es5-ext/object/assign") | ||
, includes = require("es5-ext/string/#/contains") | ||
, forOwn = require("es5-ext/object/for-each") | ||
, onlyKey = require("es5-ext/object/first-key") | ||
, forEachRight = require("es5-ext/array/#/for-each-right") | ||
, uniq = require("es5-ext/array/#/uniq.js"); | ||
var CSI = '\x1b['; | ||
var CSI = "\x1b["; | ||
var sgr = function (code) { | ||
return CSI + code + 'm'; | ||
}; | ||
var sgr = function (code) { return CSI + code + "m"; }; | ||
sgr.CSI = CSI; | ||
var mods = assign({ | ||
// Style | ||
bold: { _bold: [1, 22] }, | ||
italic: { _italic: [3, 23] }, | ||
underline: { _underline: [4, 24] }, | ||
blink: { _blink: [5, 25] }, | ||
inverse: { _inverse: [7, 27] }, | ||
strike: { _strike: [9, 29] } | ||
var mods = assign( | ||
{ | ||
// Style | ||
bold: { _bold: [1, 22] }, | ||
italic: { _italic: [3, 23] }, | ||
underline: { _underline: [4, 24] }, | ||
blink: { _blink: [5, 25] }, | ||
inverse: { _inverse: [7, 27] }, | ||
strike: { _strike: [9, 29] } | ||
// Color | ||
}, ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] | ||
.reduce(function (obj, color, index) { | ||
// Color | ||
}, | ||
["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"].reduce(function ( | ||
obj, | ||
color, | ||
index | ||
) { | ||
// foreground | ||
obj[color] = { _fg: [30 + index, 39] }; | ||
obj[color + 'Bright'] = { _fg: [90 + index, 39] }; | ||
obj[color + "Bright"] = { _fg: [90 + index, 39] }; | ||
// background | ||
obj['bg' + color[0].toUpperCase() + color.slice(1)] = { _bg: [40 + index, 49] }; | ||
obj['bg' + color[0].toUpperCase() + color.slice(1) + 'Bright'] = { _bg: [100 + index, 49] }; | ||
obj["bg" + color[0].toUpperCase() + color.slice(1)] = { _bg: [40 + index, 49] }; | ||
obj["bg" + color[0].toUpperCase() + color.slice(1) + "Bright"] = { _bg: [100 + index, 49] }; | ||
return obj; | ||
}, {})); | ||
}, {}) | ||
); | ||
@@ -55,10 +60,8 @@ sgr.mods = mods; | ||
sgr.openStyle = function (mods, code) { | ||
mods.push(sgr.openers[code]); | ||
}; | ||
sgr.openStyle = function (openedMods, code) { openedMods.push(sgr.openers[code]); }; | ||
sgr.closeStyle = function (mods, code) { | ||
forEachRight.call(mods, function (modPair, index) { | ||
sgr.closeStyle = function (openedMods, code) { | ||
forEachRight.call(openedMods, function (modPair, index) { | ||
if (modPair[1] === code) { | ||
mods.splice(index, 1); | ||
openedMods.splice(index, 1); | ||
} | ||
@@ -69,30 +72,22 @@ }); | ||
/* prepend openers */ | ||
sgr.prepend = function (mods) { | ||
return mods.map(function (modPair, key) { | ||
return sgr(modPair[0]); | ||
}); | ||
sgr.prepend = function (currentMods) { | ||
return currentMods.map(function (modPair) { return sgr(modPair[0]); }); | ||
}; | ||
/* complete non-closed openers with corresponding closers */ | ||
sgr.complete = function (mods, closerCodes) { | ||
closerCodes.forEach(function (code) { | ||
sgr.closeStyle(mods, code); | ||
}); | ||
sgr.complete = function (openedMods, closerCodes) { | ||
closerCodes.forEach(function (code) { sgr.closeStyle(openedMods, code); }); | ||
// mods must be closed from the last opened to first opened | ||
mods = mods.reverse(); | ||
openedMods = openedMods.reverse(); | ||
mods = mods.map(function (modPair, key) { | ||
return modPair[1]; | ||
}); | ||
openedMods = openedMods.map(function (modPair) { return modPair[1]; }); | ||
// one closer can close many openers (31, 32 -> 39) | ||
mods = uniq.call(mods); | ||
openedMods = uniq.call(openedMods); | ||
return mods.map(sgr); | ||
return openedMods.map(sgr); | ||
}; | ||
var hasCSI = function (str) { | ||
return includes.call(str, CSI); | ||
}; | ||
var hasCSI = function (str) { return includes.call(str, CSI); }; | ||
@@ -99,0 +94,0 @@ sgr.hasCSI = hasCSI; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -3,0 +3,0 @@ module.exports = [ |
@@ -1,7 +0,12 @@ | ||
'use strict'; | ||
"use strict"; | ||
var push = Array.prototype.push, reduce = Array.prototype.reduce, abs = Math.abs | ||
, colors, match, result, i; | ||
var push = Array.prototype.push | ||
, reduce = Array.prototype.reduce | ||
, abs = Math.abs | ||
, colors | ||
, match | ||
, result | ||
, i; | ||
colors = require('./xterm-colors').map(function (color) { | ||
colors = require("./xterm-colors").map(function (color) { | ||
return { | ||
@@ -26,16 +31,23 @@ r: parseInt(color.slice(0, 2), 16), | ||
} | ||
push.apply(result, colors.slice(16).map(function (data) { | ||
var index, diff = Infinity; | ||
match.every(function (match, i) { | ||
var ndiff = reduce.call('rgb', function (diff, channel) { | ||
diff += abs(match[channel] - data[channel]); | ||
return diff; | ||
}, 0); | ||
if (ndiff < diff) { | ||
index = i; | ||
diff = ndiff; | ||
} | ||
return ndiff; | ||
}); | ||
return result[index]; | ||
})); | ||
push.apply( | ||
result, | ||
colors.slice(16).map(function (data) { | ||
var index, diff = Infinity; | ||
match.every(function (innerMatch, currentIndex) { | ||
var ndiff = reduce.call( | ||
"rgb", | ||
function (currentDiff, channel) { | ||
currentDiff += abs(innerMatch[channel] - data[channel]); | ||
return currentDiff; | ||
}, | ||
0 | ||
); | ||
if (ndiff < diff) { | ||
index = currentIndex; | ||
diff = ndiff; | ||
} | ||
return ndiff; | ||
}); | ||
return result[index]; | ||
}) | ||
); |
28
move.js
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
"use strict"; | ||
var d = require('d') | ||
, trunc = require('es5-ext/math/trunc') | ||
var d = require("d") | ||
, trunc = require("es5-ext/math/trunc") | ||
@@ -12,3 +12,3 @@ , up, down, right, left | ||
num = isNaN(num) ? 0 : max(floor(num), 0); | ||
return num ? ('\x1b[' + num + control) : ''; | ||
return num ? "\x1b[" + num + control : ""; | ||
}; | ||
@@ -19,12 +19,12 @@ }; | ||
y = isNaN(y) ? 0 : floor(y); | ||
return ((x > 0) ? right(x) : left(-x)) + ((y > 0) ? down(y) : up(-y)); | ||
return (x > 0 ? right(x) : left(-x)) + (y > 0 ? down(y) : up(-y)); | ||
}, { | ||
up: d(up = getMove('A')), | ||
down: d(down = getMove('B')), | ||
right: d(right = getMove('C')), | ||
left: d(left = getMove('D')), | ||
up: d(up = getMove("A")), | ||
down: d(down = getMove("B")), | ||
right: d(right = getMove("C")), | ||
left: d(left = getMove("D")), | ||
to: d(function (x, y) { | ||
x = isNaN(x) ? 1 : (max(floor(x), 0) + 1); | ||
y = isNaN(y) ? 1 : (max(floor(y), 0) + 1); | ||
return '\x1b[' + y + ';' + x + 'H'; | ||
x = isNaN(x) ? 1 : max(floor(x), 0) + 1; | ||
y = isNaN(y) ? 1 : max(floor(y), 0) + 1; | ||
return "\x1b[" + y + ";" + x + "H"; | ||
}), | ||
@@ -34,6 +34,6 @@ lines: d(function (n) { | ||
n = trunc(n) || 0; | ||
dir = (n >= 0) ? 'E' : 'F'; | ||
dir = n >= 0 ? "E" : "F"; | ||
n = floor(abs(n)); | ||
return '\x1b[' + n + dir; | ||
return "\x1b[" + n + dir; | ||
}) | ||
}); |
{ | ||
"name": "cli-color", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Colors, formatting and other tools for the console", | ||
@@ -24,18 +24,35 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"d": "1", | ||
"es5-ext": "^0.10.12", | ||
"es6-iterator": "2", | ||
"memoizee": "^0.4.3", | ||
"timers-ext": "0.1" | ||
"es5-ext": "^0.10.46", | ||
"es6-iterator": "^2.0.3", | ||
"memoizee": "^0.4.14", | ||
"timers-ext": "^0.1.5" | ||
}, | ||
"devDependencies": { | ||
"tad": "^0.2.7", | ||
"xlint": "^0.2.2", | ||
"xlint-jslint-medikoo": "^0.1.4" | ||
"eslint": "^5.4", | ||
"eslint-config-medikoo-es5": "^1.6.1", | ||
"tad": "^0.2.7" | ||
}, | ||
"eslintConfig": { | ||
"extends": "medikoo-es5", | ||
"root": true, | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
"id-length": "off" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": "examples/**", | ||
"rules": { | ||
"no-console": "off" | ||
} | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", | ||
"lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", | ||
"lint": "eslint --ignore-path=.gitignore .", | ||
"test": "node ./node_modules/tad/bin/tad" | ||
}, | ||
"license": "MIT" | ||
"license": "ISC" | ||
} |
105
README.md
@@ -0,2 +1,8 @@ | ||
[![*nix build status][nix-build-image]][nix-build-url] | ||
[![Windows build status][win-build-image]][win-build-url] | ||
![Transpilation status][transpilation-image] | ||
[![npm version][npm-image]][npm-url] | ||
# cli-color | ||
## Yet another colors and formatting for the console solution | ||
@@ -8,3 +14,3 @@ | ||
$ npm install cli-color | ||
$ npm install cli-color | ||
@@ -16,3 +22,3 @@ ## Usage | ||
```javascript | ||
var clc = require('cli-color'); | ||
var clc = require("cli-color"); | ||
``` | ||
@@ -23,3 +29,3 @@ | ||
```javascript | ||
console.log(clc.red('Text in red')); | ||
console.log(clc.red("Text in red")); | ||
``` | ||
@@ -30,3 +36,3 @@ | ||
```javascript | ||
console.log(clc.red.bgWhite.underline('Underlined red text on white background.')); | ||
console.log(clc.red.bgWhite.underline("Underlined red text on white background.")); | ||
``` | ||
@@ -37,3 +43,3 @@ | ||
```javascript | ||
console.log(clc.red('red') + ' plain ' + clc.blue('blue')); | ||
console.log(clc.red("red") + " plain " + clc.blue("blue")); | ||
``` | ||
@@ -44,6 +50,6 @@ | ||
```javascript | ||
console.log(clc.red('red ' + clc.blue('blue') + ' red')); | ||
console.log(clc.red("red " + clc.blue("blue") + " red")); | ||
``` | ||
__Best way is to predefine needed stylings and then use it__: | ||
**Best way is to predefine needed stylings and then use it**: | ||
@@ -55,5 +61,5 @@ ```javascript | ||
console.log(error('Error!')); | ||
console.log(warn('Warning')); | ||
console.log(notice('Notice')); | ||
console.log(error("Error!")); | ||
console.log(warn("Warning")); | ||
console.log(notice("Notice")); | ||
``` | ||
@@ -67,8 +73,8 @@ | ||
* bold | ||
* italic | ||
* underline | ||
* blink | ||
* inverse | ||
* strike | ||
- bold | ||
- italic | ||
- underline | ||
- blink | ||
- inverse | ||
- strike | ||
@@ -109,3 +115,3 @@ #### Colors | ||
__Not supported on Windows and some terminals__. However if used in not supported environment, the closest color from basic (16 colors) palette is chosen. | ||
**Not supported on Windows and some terminals**. However if used in not supported environment, the closest color from basic (16 colors) palette is chosen. | ||
@@ -116,3 +122,3 @@ Usage: | ||
var msg = clc.xterm(202).bgXterm(236); | ||
console.log(msg('Orange text on dark gray background')); | ||
console.log(msg("Orange text on dark gray background")); | ||
``` | ||
@@ -605,5 +611,5 @@ | ||
```javascript | ||
var clc = require('cli-color'); | ||
var clc = require("cli-color"); | ||
var str = clc.bold('foo') + 'bar' + clc.red('elo'); | ||
var str = clc.bold("foo") + "bar" + clc.red("elo"); | ||
var sliced = clc.slice(str, 1, 7); // Same as: clc.bold('oo') + 'bar' + clc.red('e') | ||
@@ -617,3 +623,3 @@ ``` | ||
```javascript | ||
var ansiStrip = require('cli-color/strip'); | ||
var ansiStrip = require("cli-color/strip"); | ||
@@ -628,5 +634,5 @@ var plain = ansiStrip(formatted); | ||
```javascript | ||
var clc = require('cli-color'); | ||
var clc = require("cli-color"); | ||
var str = clc.bold('foo') + 'bar' + clc.red('elo'); | ||
var str = clc.bold("foo") + "bar" + clc.red("elo"); | ||
clc.getStrippedLength(str); // 9 | ||
@@ -640,5 +646,3 @@ ``` | ||
```javascript | ||
var text = '.........\n' + | ||
'. Hello .\n' + | ||
'.........\n'; | ||
var text = ".........\n" + ". Hello .\n" + ".........\n"; | ||
var style = { ".": clc.yellowBright("X") }; | ||
@@ -656,15 +660,18 @@ | ||
Supported `options`: | ||
- `sep`: Custom colums separator (defaults to `|`) | ||
- `columns`: Per column customizations, as e.g. `[{ align: 'right' }, null, { align: 'left' }]`: | ||
- `align`: Possible options: `'left'`, `'right` (efaults to `'left'`) | ||
- `sep`: Custom colums separator (defaults to `|`) | ||
- `columns`: Per column customizations, as e.g. `[{ align: 'right' }, null, { align: 'left' }]`: | ||
- `align`: Possible options: `'left'`, `'right` (efaults to `'left'`) | ||
```javascript | ||
var clc = require('cli-color'); | ||
var clc = require("cli-color"); | ||
process.stdout.write(clc.columns([ | ||
[clc.bold('First Name'), clc.bold('Last Name'), clc.bold('Age')], | ||
['John', 'Doe', 34], | ||
['Martha', 'Smith', 20], | ||
['Jan', 'Kowalski', 30] | ||
])); | ||
process.stdout.write( | ||
clc.columns([ | ||
[clc.bold("First Name"), clc.bold("Last Name"), clc.bold("Age")], | ||
["John", "Doe", 34], | ||
["Martha", "Smith", 20], | ||
["Jan", "Kowalski", 30] | ||
]) | ||
); | ||
@@ -685,6 +692,6 @@ /* Outputs: | ||
```javascript | ||
var setupThrobber = require('cli-color/throbber'); | ||
var setupThrobber = require("cli-color/throbber"); | ||
var throbber = setupThrobber(function (str) { | ||
process.stdout.write(str); | ||
var throbber = setupThrobber(function(str) { | ||
process.stdout.write(str); | ||
}, 200); | ||
@@ -698,11 +705,19 @@ | ||
## Tests [![Build Status](https://travis-ci.org/medikoo/cli-color.png)](https://travis-ci.org/medikoo/cli-color) | ||
## Tests | ||
$ npm test | ||
$ npm test | ||
## Contributors | ||
* [@rentalhost](https://github.com/rentalhost) (David Rodrigues) | ||
* Help with support for nested styles. Introduction of `clc.art` module, and significant improvements to tests coverage | ||
* [@StreetStrider](https://github.com/StreetStrider) | ||
* Implementation of sophistcated `clc.slice` functionality, and introduction of `clc.getStrippedLength` utility | ||
- [@rentalhost](https://github.com/rentalhost) (David Rodrigues) | ||
- Help with support for nested styles. Introduction of `clc.art` module, and significant improvements to tests coverage | ||
- [@StreetStrider](https://github.com/StreetStrider) | ||
- Implementation of sophistcated `clc.slice` functionality, and introduction of `clc.getStrippedLength` utility | ||
[nix-build-image]: https://semaphoreci.com/api/v1/medikoo-org/cli-color/branches/master/shields_badge.svg | ||
[nix-build-url]: https://semaphoreci.com/medikoo-org/cli-color | ||
[win-build-image]: https://ci.appveyor.com/api/projects/status/mnd4catkeu181ll5?svg=true | ||
[win-build-url]: https://ci.appveyor.com/project/medikoo/cli-color | ||
[transpilation-image]: https://img.shields.io/badge/transpilation-free-brightgreen.svg | ||
[npm-image]: https://img.shields.io/npm/v/cli-color.svg | ||
[npm-url]: https://www.npmjs.com/package/cli-color |
@@ -1,3 +0,3 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = '\x1b[2J\x1b[0;0H'; | ||
module.exports = "\x1b[2J\x1b[0;0H"; |
137
slice.js
@@ -1,14 +0,11 @@ | ||
'use strict'; | ||
"use strict"; | ||
var reAnsi = require('ansi-regex') | ||
, stringifiable = require('es5-ext/object/validate-stringifiable-value') | ||
, length = require('./get-stripped-length') | ||
, sgr = require('./lib/sgr') | ||
var reAnsi = require("ansi-regex") | ||
, stringifiable = require("es5-ext/object/validate-stringifiable-value") | ||
, length = require("./get-stripped-length") | ||
, sgr = require("./lib/sgr") | ||
, max = Math.max; | ||
, max = Math.max; | ||
var Token = function (token) { this.token = token; }; | ||
var Token = function Token(token) { | ||
this.token = token; | ||
}; | ||
var tokenize = function (str) { | ||
@@ -18,7 +15,6 @@ var match = reAnsi().exec(str); | ||
if (!match) { | ||
return [ str ]; | ||
return [str]; | ||
} | ||
var index = match.index | ||
, head, prehead, tail; | ||
var index = match.index, head, prehead, tail; | ||
@@ -29,3 +25,3 @@ if (index === 0) { | ||
return [ new Token(head) ].concat(tokenize(tail)); | ||
return [new Token(head)].concat(tokenize(tail)); | ||
} | ||
@@ -37,3 +33,3 @@ | ||
return [ prehead, new Token(head) ].concat(tokenize(tail)); | ||
return [prehead, new Token(head)].concat(tokenize(tail)); | ||
}; | ||
@@ -49,62 +45,65 @@ | ||
// eslint-disable-next-line max-lines-per-function | ||
var sliceSeq = function (seq, begin, end) { | ||
var sliced = seq.reduce(function (state, chunk) { | ||
var index = state.index; | ||
var sliced = seq.reduce( | ||
function (state, chunk) { | ||
var index = state.index; | ||
if (!(chunk instanceof Token)) { | ||
var nextChunk = ''; | ||
if (chunk instanceof Token) { | ||
var code = sgr.extractCode(chunk.token); | ||
if (isChunkInSlice(chunk, index, begin, end)) { | ||
var relBegin = Math.max(begin - index, 0) | ||
, relEnd = Math.min(end - index, chunk.length); | ||
if (index <= begin) { | ||
if (code in sgr.openers) { | ||
sgr.openStyle(state.preOpeners, code); | ||
} | ||
if (code in sgr.closers) { | ||
sgr.closeStyle(state.preOpeners, code); | ||
} | ||
} else if (index < end) { | ||
if (code in sgr.openers) { | ||
sgr.openStyle(state.inOpeners, code); | ||
state.seq.push(chunk); | ||
} else if (code in sgr.closers) { | ||
state.inClosers.push(code); | ||
state.seq.push(chunk); | ||
} | ||
} | ||
} else { | ||
var nextChunk = ""; | ||
nextChunk = chunk.slice(relBegin, relEnd); | ||
} | ||
if (isChunkInSlice(chunk, index, begin, end)) { | ||
var relBegin = Math.max(begin - index, 0) | ||
, relEnd = Math.min(end - index, chunk.length); | ||
state.seq.push(nextChunk); | ||
state.index = index + chunk.length; | ||
} else { | ||
var code = sgr.extractCode(chunk.token); | ||
nextChunk = chunk.slice(relBegin, relEnd); | ||
} | ||
if (index <= begin) { | ||
if (code in sgr.openers) { | ||
sgr.openStyle(state.preOpeners, code); | ||
} | ||
if (code in sgr.closers) { | ||
sgr.closeStyle(state.preOpeners, code); | ||
} | ||
} else if (index < end) { | ||
if (code in sgr.openers) { | ||
sgr.openStyle(state.inOpeners, code); | ||
state.seq.push(chunk); | ||
} else if (code in sgr.closers) { | ||
state.inClosers.push(code); | ||
state.seq.push(chunk); | ||
} | ||
state.seq.push(nextChunk); | ||
state.index = index + chunk.length; | ||
} | ||
} | ||
return state; | ||
}, { | ||
index: 0, | ||
seq: [], | ||
return state; | ||
}, | ||
{ | ||
index: 0, | ||
seq: [], | ||
// preOpeners -> [ mod ] | ||
// preOpeners must be prepended to the slice if they wasn't closed til the end of it | ||
// preOpeners must be closed if they wasn't closed til the end of the slice | ||
preOpeners: [], | ||
// preOpeners -> [ mod ] | ||
// preOpeners must be prepended to the slice if they wasn't closed til the end of it | ||
// preOpeners must be closed if they wasn't closed til the end of the slice | ||
preOpeners: [], | ||
// inOpeners -> [ mod ] | ||
// inOpeners already in the slice and must not be prepended to the slice | ||
// inOpeners must be closed if they wasn't closed til the end of the slice | ||
inOpeners: [], // opener CSI inside slice | ||
// inOpeners -> [ mod ] | ||
// inOpeners already in the slice and must not be prepended to the slice | ||
// inOpeners must be closed if they wasn't closed til the end of the slice | ||
inOpeners: [], // opener CSI inside slice | ||
// inClosers -> [ code ] | ||
// closer CSIs for determining which pre/in-Openers must be closed | ||
inClosers: [] | ||
}); | ||
// inClosers -> [ code ] | ||
// closer CSIs for determining which pre/in-Openers must be closed | ||
inClosers: [] | ||
} | ||
); | ||
sliced.seq = [].concat( | ||
sgr.prepend(sliced.preOpeners), | ||
sliced.seq, | ||
sgr.prepend(sliced.preOpeners), sliced.seq, | ||
sgr.complete([].concat(sliced.preOpeners, sliced.inOpeners), sliced.inClosers) | ||
@@ -137,9 +136,11 @@ ); | ||
seq = sliceSeq(seq, begin, end); | ||
return seq.map(function (chunk) { | ||
if (chunk instanceof Token) { | ||
return chunk.token; | ||
} | ||
return seq | ||
.map(function (chunk) { | ||
if (chunk instanceof Token) { | ||
return chunk.token; | ||
} | ||
return chunk; | ||
}).join(''); | ||
return chunk; | ||
}) | ||
.join(""); | ||
}; |
// Strip ANSI formatting from string | ||
'use strict'; | ||
"use strict"; | ||
var stringifiable = require('es5-ext/object/validate-stringifiable') | ||
, r = require('ansi-regex')(); | ||
var stringifiable = require("es5-ext/object/validate-stringifiable") | ||
, r = require("ansi-regex")(); | ||
module.exports = function (str) { return stringifiable(str).replace(r, ''); }; | ||
module.exports = function (str) { return stringifiable(str).replace(r, ""); }; |
#!/usr/bin/env node | ||
'use strict'; | ||
"use strict"; | ||
var setupThrobber = require('../../throbber') | ||
, format = require('../../index').red | ||
var setupThrobber = require("../../throbber") | ||
, format = require("../../index").red | ||
, throbber = setupThrobber(process.stdout.write.bind(process.stdout), 200, format); | ||
process.stdout.write('START'); | ||
process.stdout.write("START"); | ||
throbber.start(); | ||
setTimeout(throbber.stop, 1100); |
#!/usr/bin/env node | ||
'use strict'; | ||
"use strict"; | ||
var setupThrobber = require('../../throbber') | ||
var setupThrobber = require("../../throbber") | ||
, throbber = setupThrobber(process.stdout.write.bind(process.stdout), 200); | ||
process.stdout.write('START'); | ||
process.stdout.write("START"); | ||
throbber.start(); | ||
setTimeout(throbber.stop, 1100); |
@@ -1,28 +0,28 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('../'); | ||
var clc = require("../"); | ||
module.exports = function (t, a) { | ||
a(t('ooo', { o: clc.yellow("x") }), | ||
'\x1b[33mx\x1b[39m\x1b[33mx\x1b[39m\x1b[33mx\x1b[39m', | ||
a(t("ooo", { o: clc.yellow("x") }), | ||
"\x1b[33mx\x1b[39m\x1b[33mx\x1b[39m\x1b[33mx\x1b[39m", | ||
"Basic art"); | ||
a(t('oyo', { o: clc.yellow("x") }), | ||
'\x1b[33mx\x1b[39my\x1b[33mx\x1b[39m', | ||
a(t("oyo", { o: clc.yellow("x") }), | ||
"\x1b[33mx\x1b[39my\x1b[33mx\x1b[39m", | ||
"Free text art"); | ||
a(t('o o', { o: clc.yellow("x") }), | ||
'\x1b[33mx\x1b[39m \x1b[33mx\x1b[39m', | ||
a(t("o o", { o: clc.yellow("x") }), | ||
"\x1b[33mx\x1b[39m \x1b[33mx\x1b[39m", | ||
"Spaced art"); | ||
a(t('<=>', { "<": clc.yellow("<"), ">": clc.yellow(">") }), | ||
'\x1b[33m<\x1b[39m=\x1b[33m>\x1b[39m', | ||
a(t("<=>", { "<": clc.yellow("<"), ">": clc.yellow(">") }), | ||
"\x1b[33m<\x1b[39m=\x1b[33m>\x1b[39m", | ||
"Symbol art"); | ||
a(t('o\no', { o: clc.yellow("x") }), | ||
'\x1b[33mx\x1b[39m\n\x1b[33mx\x1b[39m', | ||
a(t("o\no", { o: clc.yellow("x") }), | ||
"\x1b[33mx\x1b[39m\n\x1b[33mx\x1b[39m", | ||
"Multiline art"); | ||
a(t('ooo', {}), | ||
'ooo', | ||
a(t("ooo", {}), | ||
"ooo", | ||
"Only text art"); | ||
}; |
350
test/bare.js
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,257 +6,257 @@ module.exports = function (t, a) { | ||
a(t('test'), 'test', "Plain"); | ||
a(t('test', 'foo', 3, { toString: function () { return 'bar'; } }), | ||
'test foo 3 bar', "Plain: Many args"); | ||
a(t("test"), "test", "Plain"); | ||
a(t("test", "foo", 3, { toString: function () { return "bar"; } }), | ||
"test foo 3 bar", "Plain: Many args"); | ||
a(t.red('foo'), '\x1b[31mfoo\x1b[39m', "Foreground"); | ||
a(t.red('foo', 'bar', 3), '\x1b[31mfoo bar 3\x1b[39m', | ||
a(t.red("foo"), "\x1b[31mfoo\x1b[39m", "Foreground"); | ||
a(t.red("foo", "bar", 3), "\x1b[31mfoo bar 3\x1b[39m", | ||
"Foreground: Many args"); | ||
a(t.red.yellow('foo', 'bar', 3), '\x1b[33mfoo bar 3\x1b[39m', | ||
a(t.red.yellow("foo", "bar", 3), "\x1b[33mfoo bar 3\x1b[39m", | ||
"Foreground: Overriden"); | ||
a(t.bgRed('foo', 'bar'), '\x1b[41mfoo bar\x1b[49m', "Background"); | ||
a(t.bgRed.bgYellow('foo', 'bar', 3), '\x1b[43mfoo bar 3\x1b[49m', | ||
a(t.bgRed("foo", "bar"), "\x1b[41mfoo bar\x1b[49m", "Background"); | ||
a(t.bgRed.bgYellow("foo", "bar", 3), "\x1b[43mfoo bar 3\x1b[49m", | ||
"Background: Overriden"); | ||
a(t.blue.bgYellow('foo', 'bar'), '\x1b[43m\x1b[34mfoo bar\x1b[39m\x1b[49m', | ||
a(t.blue.bgYellow("foo", "bar"), "\x1b[43m\x1b[34mfoo bar\x1b[39m\x1b[49m", | ||
"Foreground & Background"); | ||
a(t.blue.bgYellow.red.bgMagenta('foo', 'bar'), | ||
'\x1b[45m\x1b[31mfoo bar\x1b[39m\x1b[49m', | ||
a(t.blue.bgYellow.red.bgMagenta("foo", "bar"), | ||
"\x1b[45m\x1b[31mfoo bar\x1b[39m\x1b[49m", | ||
"Foreground & Background: Overriden"); | ||
a(t.bold('foo', 'bar'), '\x1b[1mfoo bar\x1b[22m', "Format"); | ||
a(t.blink('foobar'), '\x1b[5mfoobar\x1b[25m', "Format: blink"); | ||
a(t.bold.blue('foo', 'bar', 3), '\x1b[1m\x1b[34mfoo bar 3\x1b[39m\x1b[22m', | ||
a(t.bold("foo", "bar"), "\x1b[1mfoo bar\x1b[22m", "Format"); | ||
a(t.blink("foobar"), "\x1b[5mfoobar\x1b[25m", "Format: blink"); | ||
a(t.bold.blue("foo", "bar", 3), "\x1b[1m\x1b[34mfoo bar 3\x1b[39m\x1b[22m", | ||
"Foreground & Format"); | ||
a(t.redBright('foo', 'bar'), '\x1b[91mfoo bar\x1b[39m', "Bright"); | ||
a(t.bgRedBright('foo', 3), '\x1b[101mfoo 3\x1b[49m', "Bright background"); | ||
a(t.redBright("foo", "bar"), "\x1b[91mfoo bar\x1b[39m", "Bright"); | ||
a(t.bgRedBright("foo", 3), "\x1b[101mfoo 3\x1b[49m", "Bright background"); | ||
a(t.blueBright.bgYellowBright.red.bgMagenta('foo', 'bar'), | ||
'\x1b[45m\x1b[31mfoo bar\x1b[39m\x1b[49m', | ||
a(t.blueBright.bgYellowBright.red.bgMagenta("foo", "bar"), | ||
"\x1b[45m\x1b[31mfoo bar\x1b[39m\x1b[49m", | ||
"Foreground & Background: Bright: Overriden"); | ||
a(t.red.blue('foo'), '\x1b[34mfoo\x1b[39m', "Prioritize the Last Color: Blue"); | ||
a(t.blue.red('foo'), '\x1b[31mfoo\x1b[39m', "Prioritize the Last Color: Red"); | ||
a(t.bgRed.bgBlue('foo'), '\x1b[44mfoo\x1b[49m', "Prioritize the Last Background Color: Blue"); | ||
a(t.bgBlue.bgRed('foo'), '\x1b[41mfoo\x1b[49m', "Prioritize the Last Background Color: Red"); | ||
a(t.bgRed.red.bgBlue.blue('foo'), | ||
'\x1b[44m\x1b[34mfoo\x1b[39m\x1b[49m', | ||
a(t.red.blue("foo"), "\x1b[34mfoo\x1b[39m", "Prioritize the Last Color: Blue"); | ||
a(t.blue.red("foo"), "\x1b[31mfoo\x1b[39m", "Prioritize the Last Color: Red"); | ||
a(t.bgRed.bgBlue("foo"), "\x1b[44mfoo\x1b[49m", "Prioritize the Last Background Color: Blue"); | ||
a(t.bgBlue.bgRed("foo"), "\x1b[41mfoo\x1b[49m", "Prioritize the Last Background Color: Red"); | ||
a(t.bgRed.red.bgBlue.blue("foo"), | ||
"\x1b[44m\x1b[34mfoo\x1b[39m\x1b[49m", | ||
"Prioritize the Last Mixed Style: Blue"); | ||
a(t.bgBlue.blue.bgRed.red('foo'), | ||
'\x1b[41m\x1b[31mfoo\x1b[39m\x1b[49m', | ||
a(t.bgBlue.blue.bgRed.red("foo"), | ||
"\x1b[41m\x1b[31mfoo\x1b[39m\x1b[49m", | ||
"Prioritize the Last Mixed Style: Red"); | ||
a(t.bgRed.blue.bgBlue.red('foo'), | ||
'\x1b[44m\x1b[31mfoo\x1b[39m\x1b[49m', | ||
a(t.bgRed.blue.bgBlue.red("foo"), | ||
"\x1b[44m\x1b[31mfoo\x1b[39m\x1b[49m", | ||
"Prioritize the Last Mixed Style: BG Blue and Red"); | ||
a(t.bgBlue.red.bgRed.blue('foo'), | ||
'\x1b[41m\x1b[34mfoo\x1b[39m\x1b[49m', | ||
a(t.bgBlue.red.bgRed.blue("foo"), | ||
"\x1b[41m\x1b[34mfoo\x1b[39m\x1b[49m", | ||
"Prioritize the Last Mixed Style: BG Red and Blue"); | ||
a(t.bold('bold ' + t.whiteBright('whiteBright ') + 'bold'), | ||
'\x1b[1mbold \x1b[97mwhiteBright \x1b[39mbold\x1b[22m', | ||
a(t.bold("bold " + t.whiteBright("whiteBright ") + "bold"), | ||
"\x1b[1mbold \x1b[97mwhiteBright \x1b[39mbold\x1b[22m", | ||
"Nested Format: Bold Type 1"); | ||
a(t.white('white ' + t.bold('bold ') + 'white'), | ||
'\x1b[37mwhite \x1b[1mbold \x1b[22mwhite\x1b[39m', | ||
a(t.white("white " + t.bold("bold ") + "white"), | ||
"\x1b[37mwhite \x1b[1mbold \x1b[22mwhite\x1b[39m", | ||
"Nested Format: Bold Type 2"); | ||
a(t.italic('italic ' + t.whiteBright('whiteBright ') + 'italic'), | ||
'\x1b[3mitalic \x1b[97mwhiteBright \x1b[39mitalic\x1b[23m', | ||
a(t.italic("italic " + t.whiteBright("whiteBright ") + "italic"), | ||
"\x1b[3mitalic \x1b[97mwhiteBright \x1b[39mitalic\x1b[23m", | ||
"Nested Format: Italic"); | ||
a(t.white('white ' + t.italic('italic ') + 'white'), | ||
'\x1b[37mwhite \x1b[3mitalic \x1b[23mwhite\x1b[39m', | ||
a(t.white("white " + t.italic("italic ") + "white"), | ||
"\x1b[37mwhite \x1b[3mitalic \x1b[23mwhite\x1b[39m", | ||
"Nested Format: Italic Type 2"); | ||
a(t.underline('underline ' + t.whiteBright('whiteBright ') + 'underline'), | ||
'\x1b[4munderline \x1b[97mwhiteBright \x1b[39munderline\x1b[24m', | ||
a(t.underline("underline " + t.whiteBright("whiteBright ") + "underline"), | ||
"\x1b[4munderline \x1b[97mwhiteBright \x1b[39munderline\x1b[24m", | ||
"Nested Format: Underline"); | ||
a(t.white('white ' + t.underline('underline ') + 'white'), | ||
'\x1b[37mwhite \x1b[4munderline \x1b[24mwhite\x1b[39m', | ||
a(t.white("white " + t.underline("underline ") + "white"), | ||
"\x1b[37mwhite \x1b[4munderline \x1b[24mwhite\x1b[39m", | ||
"Nested Format: Underline Type 2"); | ||
a(t.blink('blink ' + t.whiteBright('whiteBright ') + 'blink'), | ||
'\x1b[5mblink \x1b[97mwhiteBright \x1b[39mblink\x1b[25m', | ||
a(t.blink("blink " + t.whiteBright("whiteBright ") + "blink"), | ||
"\x1b[5mblink \x1b[97mwhiteBright \x1b[39mblink\x1b[25m", | ||
"Nested Format: Blink"); | ||
a(t.white('white ' + t.blink('blink ') + 'white'), | ||
'\x1b[37mwhite \x1b[5mblink \x1b[25mwhite\x1b[39m', | ||
a(t.white("white " + t.blink("blink ") + "white"), | ||
"\x1b[37mwhite \x1b[5mblink \x1b[25mwhite\x1b[39m", | ||
"Nested Format: Blink Type 2"); | ||
a(t.inverse('inverse ' + t.whiteBright('whiteBright ') + 'inverse'), | ||
'\x1b[7minverse \x1b[97mwhiteBright \x1b[39minverse\x1b[27m', | ||
a(t.inverse("inverse " + t.whiteBright("whiteBright ") + "inverse"), | ||
"\x1b[7minverse \x1b[97mwhiteBright \x1b[39minverse\x1b[27m", | ||
"Nested Format: Inverse"); | ||
a(t.white('white ' + t.inverse('inverse ') + 'white'), | ||
'\x1b[37mwhite \x1b[7minverse \x1b[27mwhite\x1b[39m', | ||
a(t.white("white " + t.inverse("inverse ") + "white"), | ||
"\x1b[37mwhite \x1b[7minverse \x1b[27mwhite\x1b[39m", | ||
"Nested Format: Inverse Type 2"); | ||
a(t.strike('strike ' + t.whiteBright('whiteBright ') + 'strike'), | ||
'\x1b[9mstrike \x1b[97mwhiteBright \x1b[39mstrike\x1b[29m', | ||
a(t.strike("strike " + t.whiteBright("whiteBright ") + "strike"), | ||
"\x1b[9mstrike \x1b[97mwhiteBright \x1b[39mstrike\x1b[29m", | ||
"Nested Format: Strike"); | ||
a(t.white('white ' + t.strike('strike ') + 'white'), | ||
'\x1b[37mwhite \x1b[9mstrike \x1b[29mwhite\x1b[39m', | ||
a(t.white("white " + t.strike("strike ") + "white"), | ||
"\x1b[37mwhite \x1b[9mstrike \x1b[29mwhite\x1b[39m", | ||
"Nested Format: Strike Type 2"); | ||
a(t.red('red ' + t.blue('blue ')), | ||
'\x1b[31mred \x1b[34mblue \x1b[31m\x1b[39m', | ||
a(t.red("red " + t.blue("blue ")), | ||
"\x1b[31mred \x1b[34mblue \x1b[31m\x1b[39m", | ||
"Nested Foreground: Two Levels Type 1"); | ||
a(t.red(t.blue('blue ') + 'red'), | ||
'\x1b[31m\x1b[34mblue \x1b[31mred\x1b[39m', | ||
a(t.red(t.blue("blue ") + "red"), | ||
"\x1b[31m\x1b[34mblue \x1b[31mred\x1b[39m", | ||
"Nested Foreground: Two Levels Type 2"); | ||
a(t.red('red ' + t.blue('blue ') + 'red'), | ||
'\x1b[31mred \x1b[34mblue \x1b[31mred\x1b[39m', | ||
a(t.red("red " + t.blue("blue ") + "red"), | ||
"\x1b[31mred \x1b[34mblue \x1b[31mred\x1b[39m", | ||
"Nested Foreground: Two Levels Type 3"); | ||
a(t.red('red ' + t.blue('blue ' + t.green('green ')) + 'red'), | ||
'\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34m\x1b[31mred\x1b[39m', | ||
a(t.red("red " + t.blue("blue " + t.green("green ")) + "red"), | ||
"\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34m\x1b[31mred\x1b[39m", | ||
"Nested Foreground: Three Levels Type 1"); | ||
a(t.red('red ' + t.blue('blue ' + t.green('green ') + 'blue ') + 'red'), | ||
'\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34mblue \x1b[31mred\x1b[39m', | ||
a(t.red("red " + t.blue("blue " + t.green("green ") + "blue ") + "red"), | ||
"\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34mblue \x1b[31mred\x1b[39m", | ||
"Nested Foreground: Three Levels Type 2"); | ||
a(t.red('red ' + t.blue('blue ' + t.green('green ')) + t.green('green ') + 'red'), | ||
'\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34m' + | ||
'\x1b[31m\x1b[32mgreen \x1b[31mred\x1b[39m', | ||
a(t.red("red " + t.blue("blue " + t.green("green ")) + t.green("green ") + "red"), | ||
"\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34m" + | ||
"\x1b[31m\x1b[32mgreen \x1b[31mred\x1b[39m", | ||
"Nested Foreground: Three Levels Type 3"); | ||
a(t.red('red ' + t.blue('blue ' + t.green('green ') + t.yellow('yellow ')) + 'red'), | ||
'\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34m' + | ||
'\x1b[33myellow \x1b[34m\x1b[31mred\x1b[39m', | ||
a(t.red("red " + t.blue("blue " + t.green("green ") + t.yellow("yellow ")) + "red"), | ||
"\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34m" + | ||
"\x1b[33myellow \x1b[34m\x1b[31mred\x1b[39m", | ||
"Nested Foreground: Three Levels Type 4"); | ||
a(t.red('red ' + t.blue('blue ' + t.green('green ') + "blue " + t.yellow('yellow ')) + 'red'), | ||
'\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34mblue \x1b[33myellow ' + | ||
'\x1b[34m\x1b[31mred\x1b[39m', "Nested Foreground: Three Levels Type 5"); | ||
a(t.red("red " + t.blue("blue " + t.green("green ") + "blue " + t.yellow("yellow ")) + "red"), | ||
"\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[34mblue \x1b[33myellow " + | ||
"\x1b[34m\x1b[31mred\x1b[39m", "Nested Foreground: Three Levels Type 5"); | ||
a(t.red('red ' + t.blue('blue ' + t.green('green ' + t.yellow('yellow ') + "green ")) + 'red'), | ||
'\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[33myellow \x1b[32mgreen ' + | ||
'\x1b[34m\x1b[31mred\x1b[39m', "Nested Foreground: Four Levels"); | ||
a(t.red("red " + t.blue("blue " + t.green("green " + t.yellow("yellow ") + "green ")) + "red"), | ||
"\x1b[31mred \x1b[34mblue \x1b[32mgreen \x1b[33myellow \x1b[32mgreen " + | ||
"\x1b[34m\x1b[31mred\x1b[39m", "Nested Foreground: Four Levels"); | ||
a(t.red('\x1bAred'), | ||
'\x1b[31m\x1bAred\x1b[39m', | ||
a(t.red("\x1bAred"), | ||
"\x1b[31m\x1bAred\x1b[39m", | ||
"Nested Foreground: Trap Type 1 - Not a Style Before"); | ||
a(t.red('red\x1bA'), | ||
'\x1b[31mred\x1bA\x1b[39m', | ||
a(t.red("red\x1bA"), | ||
"\x1b[31mred\x1bA\x1b[39m", | ||
"Nested Foreground: Trap Type 2 - Not a Style After"); | ||
a(t.red('\x1bAred\x1bA'), | ||
'\x1b[31m\x1bAred\x1bA\x1b[39m', | ||
a(t.red("\x1bAred\x1bA"), | ||
"\x1b[31m\x1bAred\x1bA\x1b[39m", | ||
"Nested Foreground: Trap Type 3 - Not a Style Around"); | ||
a(t.red('\x1b34m\x1b39m'), | ||
'\x1b[31m\x1b34m\x1b39m\x1b[39m', | ||
a(t.red("\x1b34m\x1b39m"), | ||
"\x1b[31m\x1b34m\x1b39m\x1b[39m", | ||
"Nested Foreground: Trap Type 4 - Not a Valid Style"); | ||
a(t.red('\x1b[34m\x1b[39m'), | ||
'\x1b[31m\x1b[34m\x1b[31m\x1b[39m', | ||
a(t.red("\x1b[34m\x1b[39m"), | ||
"\x1b[31m\x1b[34m\x1b[31m\x1b[39m", | ||
"Nested Foreground: Trap Type 5 - No Message Style"); | ||
a(t.red('\x1b[34m\x1b[39m\x1b[34mblue\x1b[39m'), | ||
'\x1b[31m\x1b[34m\x1b[31m\x1b[34mblue\x1b[31m\x1b[39m', | ||
a(t.red("\x1b[34m\x1b[39m\x1b[34mblue\x1b[39m"), | ||
"\x1b[31m\x1b[34m\x1b[31m\x1b[34mblue\x1b[31m\x1b[39m", | ||
"Nested Foreground: Trap Type 6 - No Message Style Before"); | ||
a(t.red('\x1b[34mblue\x1b[39m\x1b[34m\x1b[39m'), | ||
'\x1b[31m\x1b[34mblue\x1b[31m\x1b[34m\x1b[31m\x1b[39m', | ||
a(t.red("\x1b[34mblue\x1b[39m\x1b[34m\x1b[39m"), | ||
"\x1b[31m\x1b[34mblue\x1b[31m\x1b[34m\x1b[31m\x1b[39m", | ||
"Nested Foreground: Trap Type 7 - No Message Style After"); | ||
a(t.red('\x1b[34m\x1b[39m\x1b[34mblue\x1b[39m\x1b[34m\x1b[39m'), | ||
'\x1b[31m\x1b[34m\x1b[31m\x1b[34mblue\x1b[31m\x1b[34m\x1b[31m\x1b[39m', | ||
a(t.red("\x1b[34m\x1b[39m\x1b[34mblue\x1b[39m\x1b[34m\x1b[39m"), | ||
"\x1b[31m\x1b[34m\x1b[31m\x1b[34mblue\x1b[31m\x1b[34m\x1b[31m\x1b[39m", | ||
"Nested Foreground: Trap Type 8 - No Message Style Around"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ')), | ||
'\x1b[41mred \x1b[44mblue \x1b[41m\x1b[49m', | ||
a(t.bgRed("red " + t.bgBlue("blue ")), | ||
"\x1b[41mred \x1b[44mblue \x1b[41m\x1b[49m", | ||
"Nested Background: Two Levels Type 1"); | ||
a(t.bgRed(t.bgBlue('blue ') + 'red'), | ||
'\x1b[41m\x1b[44mblue \x1b[41mred\x1b[49m', | ||
a(t.bgRed(t.bgBlue("blue ") + "red"), | ||
"\x1b[41m\x1b[44mblue \x1b[41mred\x1b[49m", | ||
"Nested Background: Two Levels Type 2"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ') + 'red'), | ||
'\x1b[41mred \x1b[44mblue \x1b[41mred\x1b[49m', | ||
a(t.bgRed("red " + t.bgBlue("blue ") + "red"), | ||
"\x1b[41mred \x1b[44mblue \x1b[41mred\x1b[49m", | ||
"Nested Background: Two Levels Type 3"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ' + t.bgGreen('green ')) + 'red'), | ||
'\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44m\x1b[41mred\x1b[49m', | ||
a(t.bgRed("red " + t.bgBlue("blue " + t.bgGreen("green ")) + "red"), | ||
"\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44m\x1b[41mred\x1b[49m", | ||
"Nested Background: Three Levels Type 1"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ' + t.bgGreen('green ') + 'blue ') + 'red'), | ||
'\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44mblue \x1b[41mred\x1b[49m', | ||
a(t.bgRed("red " + t.bgBlue("blue " + t.bgGreen("green ") + "blue ") + "red"), | ||
"\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44mblue \x1b[41mred\x1b[49m", | ||
"Nested Background: Three Levels Type 2"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ' + t.bgGreen('green ')) + t.bgGreen('green ') + 'red'), | ||
'\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44m' + | ||
'\x1b[41m\x1b[42mgreen \x1b[41mred\x1b[49m', | ||
a(t.bgRed("red " + t.bgBlue("blue " + t.bgGreen("green ")) + t.bgGreen("green ") + "red"), | ||
"\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44m" + | ||
"\x1b[41m\x1b[42mgreen \x1b[41mred\x1b[49m", | ||
"Nested Background: Three Levels Type 3"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ' + t.bgGreen('green ') + t.bgYellow('yellow ')) + 'red'), | ||
'\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44m' + | ||
'\x1b[43myellow \x1b[44m\x1b[41mred\x1b[49m', | ||
a(t.bgRed("red " + t.bgBlue("blue " + t.bgGreen("green ") + t.bgYellow("yellow ")) + "red"), | ||
"\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44m" + | ||
"\x1b[43myellow \x1b[44m\x1b[41mred\x1b[49m", | ||
"Nested Background: Three Levels Type 4"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ' + t.bgGreen('green ') + "blue " + | ||
t.bgYellow('yellow ')) + 'red'), | ||
'\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44mblue \x1b[43myellow ' + | ||
'\x1b[44m\x1b[41mred\x1b[49m', "Nested Background: Three Levels Type 5"); | ||
a(t.bgRed("red " + t.bgBlue("blue " + t.bgGreen("green ") + "blue " + | ||
t.bgYellow("yellow ")) + "red"), | ||
"\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[44mblue \x1b[43myellow " + | ||
"\x1b[44m\x1b[41mred\x1b[49m", "Nested Background: Three Levels Type 5"); | ||
a(t.bgRed('red ' + t.bgBlue('blue ' + t.bgGreen('green ' + | ||
t.bgYellow('yellow ') + "green ")) + 'red'), | ||
'\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[43myellow \x1b[42mgreen ' + | ||
'\x1b[44m\x1b[41mred\x1b[49m', "Nested Background: Four Levels"); | ||
a(t.bgRed("red " + t.bgBlue("blue " + t.bgGreen("green " + | ||
t.bgYellow("yellow ") + "green ")) + "red"), | ||
"\x1b[41mred \x1b[44mblue \x1b[42mgreen \x1b[43myellow \x1b[42mgreen " + | ||
"\x1b[44m\x1b[41mred\x1b[49m", "Nested Background: Four Levels"); | ||
a(t.bgRed('\x1bAred'), | ||
'\x1b[41m\x1bAred\x1b[49m', | ||
a(t.bgRed("\x1bAred"), | ||
"\x1b[41m\x1bAred\x1b[49m", | ||
"Nested Background: Trap Type 1 - Not a Style Before"); | ||
a(t.bgRed('red\x1bA'), | ||
'\x1b[41mred\x1bA\x1b[49m', | ||
a(t.bgRed("red\x1bA"), | ||
"\x1b[41mred\x1bA\x1b[49m", | ||
"Nested Background: Trap Type 2 - Not a Style After"); | ||
a(t.bgRed('\x1bAred\x1bA'), | ||
'\x1b[41m\x1bAred\x1bA\x1b[49m', | ||
a(t.bgRed("\x1bAred\x1bA"), | ||
"\x1b[41m\x1bAred\x1bA\x1b[49m", | ||
"Nested Background: Trap Type 3 - Not a Style Around"); | ||
a(t.bgRed('\x1b44m\x1b39m'), | ||
'\x1b[41m\x1b44m\x1b39m\x1b[49m', | ||
a(t.bgRed("\x1b44m\x1b39m"), | ||
"\x1b[41m\x1b44m\x1b39m\x1b[49m", | ||
"Nested Background: Trap Type 4 - Not a Valid Style"); | ||
a(t.bgRed('\x1b[44m\x1b[49m'), | ||
'\x1b[41m\x1b[44m\x1b[41m\x1b[49m', | ||
a(t.bgRed("\x1b[44m\x1b[49m"), | ||
"\x1b[41m\x1b[44m\x1b[41m\x1b[49m", | ||
"Nested Background: Trap Type 5 - No Message Style"); | ||
a(t.bgRed('\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m'), | ||
'\x1b[41m\x1b[44m\x1b[41m\x1b[44mblue\x1b[41m\x1b[49m', | ||
a(t.bgRed("\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m"), | ||
"\x1b[41m\x1b[44m\x1b[41m\x1b[44mblue\x1b[41m\x1b[49m", | ||
"Nested Background: Trap Type 6 - No Message Style Before"); | ||
a(t.bgRed('\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m'), | ||
'\x1b[41m\x1b[44mblue\x1b[41m\x1b[44m\x1b[41m\x1b[49m', | ||
a(t.bgRed("\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m"), | ||
"\x1b[41m\x1b[44mblue\x1b[41m\x1b[44m\x1b[41m\x1b[49m", | ||
"Nested Background: Trap Type 7 - No Message Style After"); | ||
a(t.bgRed('\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m'), | ||
'\x1b[41m\x1b[44m\x1b[41m\x1b[44mblue\x1b[41m\x1b[44m\x1b[41m\x1b[49m', | ||
a(t.bgRed("\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m"), | ||
"\x1b[41m\x1b[44m\x1b[41m\x1b[44mblue\x1b[41m\x1b[44m\x1b[41m\x1b[49m", | ||
"Nested Background: Trap Type 8 - No Message Style Around"); | ||
a(t.red('red ' + t.bgBlue('blue ')), | ||
'\x1b[31mred \x1b[44mblue \x1b[49m\x1b[39m', | ||
a(t.red("red " + t.bgBlue("blue ")), | ||
"\x1b[31mred \x1b[44mblue \x1b[49m\x1b[39m", | ||
"Nested Foreground and Background: Two Levels Type 1"); | ||
a(t.red('red ' + t.bgBlue('blue ') + t.white('white')), | ||
'\x1b[31mred \x1b[44mblue \x1b[49m\x1b[37mwhite\x1b[31m\x1b[39m', | ||
a(t.red("red " + t.bgBlue("blue ") + t.white("white")), | ||
"\x1b[31mred \x1b[44mblue \x1b[49m\x1b[37mwhite\x1b[31m\x1b[39m", | ||
"Nested Foreground and Background: Two Levels Type 2"); | ||
a(t.red('red ' + t.bgBlue('blue ') + 'red'), | ||
'\x1b[31mred \x1b[44mblue \x1b[49mred\x1b[39m', | ||
a(t.red("red " + t.bgBlue("blue ") + "red"), | ||
"\x1b[31mred \x1b[44mblue \x1b[49mred\x1b[39m", | ||
"Nested Foreground and Background: Two Levels Type 3"); | ||
a(t.bgBlue('blue ' + t.bgRed('red ' + t.whiteBright('white ') + 'red ') + 'blue'), | ||
'\x1b[44mblue \x1b[41mred \x1b[97mwhite \x1b[39mred \x1b[44mblue\x1b[49m', | ||
a(t.bgBlue("blue " + t.bgRed("red " + t.whiteBright("white ") + "red ") + "blue"), | ||
"\x1b[44mblue \x1b[41mred \x1b[97mwhite \x1b[39mred \x1b[44mblue\x1b[49m", | ||
"Nested Foreground and Background: Two Levels Type 3"); | ||
a(t.red.bgWhite('white ' + t.bgBlue('blue')), | ||
'\x1b[47m\x1b[31mwhite \x1b[44mblue\x1b[47m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("white " + t.bgBlue("blue")), | ||
"\x1b[47m\x1b[31mwhite \x1b[44mblue\x1b[47m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Mixed Type 1"); | ||
a(t.red.bgWhite('white ' + t.blue('blue')), | ||
'\x1b[47m\x1b[31mwhite \x1b[34mblue\x1b[31m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("white " + t.blue("blue")), | ||
"\x1b[47m\x1b[31mwhite \x1b[34mblue\x1b[31m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Mixed Type 2"); | ||
a(t.red.bgWhite('white ' + t.blue('blue ') + 'white'), | ||
'\x1b[47m\x1b[31mwhite \x1b[34mblue \x1b[31mwhite\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("white " + t.blue("blue ") + "white"), | ||
"\x1b[47m\x1b[31mwhite \x1b[34mblue \x1b[31mwhite\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Mixed Type 3"); | ||
a(t.red.bgWhite('\x1bAred'), | ||
'\x1b[47m\x1b[31m\x1bAred\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1bAred"), | ||
"\x1b[47m\x1b[31m\x1bAred\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 1 - Not a Style Before"); | ||
a(t.red.bgWhite('red\x1bA'), | ||
'\x1b[47m\x1b[31mred\x1bA\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("red\x1bA"), | ||
"\x1b[47m\x1b[31mred\x1bA\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 2 - Not a Style After"); | ||
a(t.red.bgWhite('\x1bAred\x1bA'), | ||
'\x1b[47m\x1b[31m\x1bAred\x1bA\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1bAred\x1bA"), | ||
"\x1b[47m\x1b[31m\x1bAred\x1bA\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 3 - Not a Style Around"); | ||
a(t.red.bgWhite('\x1b34m\x1b39m'), | ||
'\x1b[47m\x1b[31m\x1b34m\x1b39m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1b34m\x1b39m"), | ||
"\x1b[47m\x1b[31m\x1b34m\x1b39m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 4 - Not a Valid Style"); | ||
a(t.red.bgWhite('\x1b[34m\x1b[39m'), | ||
'\x1b[47m\x1b[31m\x1b[34m\x1b[31m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1b[34m\x1b[39m"), | ||
"\x1b[47m\x1b[31m\x1b[34m\x1b[31m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 5 - No Message Style"); | ||
a(t.red.bgWhite('\x1b[44m\x1b[49m'), | ||
'\x1b[47m\x1b[31m\x1b[44m\x1b[47m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1b[44m\x1b[49m"), | ||
"\x1b[47m\x1b[31m\x1b[44m\x1b[47m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 6 - No Message Style"); | ||
a(t.red.bgWhite('\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m'), | ||
'\x1b[47m\x1b[31m\x1b[44m\x1b[47m\x1b[44mblue\x1b[47m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m"), | ||
"\x1b[47m\x1b[31m\x1b[44m\x1b[47m\x1b[44mblue\x1b[47m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 7 - No Message Style Before"); | ||
a(t.red.bgWhite('\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m'), | ||
'\x1b[47m\x1b[31m\x1b[44mblue\x1b[47m\x1b[44m\x1b[47m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m"), | ||
"\x1b[47m\x1b[31m\x1b[44mblue\x1b[47m\x1b[44m\x1b[47m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 8 - No Message Style After"); | ||
a(t.red.bgWhite('\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m'), | ||
'\x1b[47m\x1b[31m\x1b[44m\x1b[47m\x1b[44mblue\x1b[47m\x1b[44m\x1b[47m\x1b[39m\x1b[49m', | ||
a(t.red.bgWhite("\x1b[44m\x1b[49m\x1b[44mblue\x1b[49m\x1b[44m\x1b[49m"), | ||
"\x1b[47m\x1b[31m\x1b[44m\x1b[47m\x1b[44mblue\x1b[47m\x1b[44m\x1b[47m\x1b[39m\x1b[49m", | ||
"Nested Foreground and Background: Trap Type 9 - No Message Style Around"); | ||
@@ -267,20 +267,20 @@ | ||
a(x('foo', 'red') + ' ' + y('foo', 'boldred'), | ||
'\x1b[31mfoo red\x1b[39m \x1b[1m\x1b[31mfoo boldred\x1b[39m\x1b[22m', | ||
a(x("foo", "red") + " " + y("foo", "boldred"), | ||
"\x1b[31mfoo red\x1b[39m \x1b[1m\x1b[31mfoo boldred\x1b[39m\x1b[22m", | ||
"Detached extension"); | ||
if (t.xtermSupported) { | ||
a(t.xterm(12).bgXterm(67)('foo', 'xterm'), | ||
'\x1b[48;5;67m\x1b[38;5;12mfoo xterm\x1b[39m\x1b[49m', "Xterm"); | ||
a(t.xterm(12).bgXterm(67)("foo", "xterm"), | ||
"\x1b[48;5;67m\x1b[38;5;12mfoo xterm\x1b[39m\x1b[49m", "Xterm"); | ||
a(t.redBright.bgBlueBright.xterm(12).bgXterm(67)('foo', 'xterm'), | ||
'\x1b[48;5;67m\x1b[38;5;12mfoo xterm\x1b[39m\x1b[49m', | ||
a(t.redBright.bgBlueBright.xterm(12).bgXterm(67)("foo", "xterm"), | ||
"\x1b[48;5;67m\x1b[38;5;12mfoo xterm\x1b[39m\x1b[49m", | ||
"Xterm: Override & Bright"); | ||
a(t.xterm(12).bgXterm(67).redBright.bgMagentaBright('foo', 'xterm'), | ||
'\x1b[105m\x1b[91mfoo xterm\x1b[39m\x1b[49m', | ||
a(t.xterm(12).bgXterm(67).redBright.bgMagentaBright("foo", "xterm"), | ||
"\x1b[105m\x1b[91mfoo xterm\x1b[39m\x1b[49m", | ||
"Xterm: Override & Bright #2"); | ||
} else { | ||
a(t.xterm(12).bgXterm(67)('foo', 'xterm'), | ||
'\x1b[100m\x1b[94mfoo xterm\x1b[39m\x1b[49m', "Xterm"); | ||
a(t.xterm(12).bgXterm(67)("foo", "xterm"), | ||
"\x1b[100m\x1b[94mfoo xterm\x1b[39m\x1b[49m", "Xterm"); | ||
} | ||
}; |
@@ -1,3 +0,3 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = function (t, a) { a(t, '\x07'); }; | ||
module.exports = function (t, a) { a(t, "\x07"); }; |
@@ -1,32 +0,31 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = function (t, a) { | ||
a(t([]), '\n', "Empty #1"); | ||
a(t([ [], [], [] ]), '\n\n\n', "Empty #2"); | ||
a(t([]), "\n", "Empty #1"); | ||
a(t([[], [], []]), "\n\n\n", "Empty #2"); | ||
a(t([ [ "A", "BC", "DEF" ] ]), | ||
'A | BC | DEF\n', | ||
"Header Only"); | ||
a(t([["A", "BC", "DEF"]]), "A | BC | DEF\n", "Header Only"); | ||
a(t([ [ "A", "BC", "DEF" ], [ 1, 23, 456 ] ]), | ||
'A | BC | DEF\n1 | 23 | 456\n', | ||
"Small items"); | ||
a(t([ [ "A", "BC", "DEF" ], [ 12, 234, 4567 ] ]), | ||
'A | BC | DEF \n12 | 234 | 4567\n', | ||
"Large items"); | ||
a(t([ [ "A", "BC", "DEF" ], [ 1234, 23456, 456789 ] ]), | ||
'A | BC | DEF \n1234 | 23456 | 456789\n', | ||
"Very large items"); | ||
a(t([["A", "BC", "DEF"], [1, 23, 456]]), "A | BC | DEF\n1 | 23 | 456\n", "Small items"); | ||
a( | ||
t([["A", "BC", "DEF"], [12, 234, 4567]]), "A | BC | DEF \n12 | 234 | 4567\n", | ||
"Large items" | ||
); | ||
a( | ||
t([["A", "BC", "DEF"], [1234, 23456, 456789]]), | ||
"A | BC | DEF \n1234 | 23456 | 456789\n", "Very large items" | ||
); | ||
a(t([ [ "A" ], [ 1 ], [ 23 ], [ 456 ] ]), | ||
'A \n1 \n23 \n456\n', | ||
"Single column"); | ||
a(t([["A"], [1], [23], [456]]), "A \n1 \n23 \n456\n", "Single column"); | ||
a(t([ [ "ID" ], [ 1 ], [ 1, 23 ], [ 1, 23, 456 ] ]), | ||
'ID\n1 \n1 | 23\n1 | 23 | 456\n', | ||
"Force columns"); | ||
a(t([["ID"], [1], [1, 23], [1, 23, 456]]), "ID\n1 \n1 | 23\n1 | 23 | 456\n", "Force columns"); | ||
a(t([ [ "ID" ], [ "", "" ], [ 123, 123 ] ]), | ||
'ID \n | \n123 | 123\n', | ||
"Empty cells"); | ||
a( | ||
t([["ONE", "TWO", "THREE"], ["ON", "DWA\nTRZY", "DWA\nTRZY\nCZTERY"], ["HOPLA", "B", "C"]]), | ||
"ONE | TWO | THREE \nON | DWA | DWA \n | TRZY | TRZY \n" + | ||
" | | CZTERY\nHOPLA | B | C \n", | ||
"Rows" | ||
); | ||
a(t([["ID"], ["", ""], [123, 123]]), "ID \n | \n123 | 123\n", "Empty cells"); | ||
}; |
@@ -1,6 +0,6 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = function (t, a) { | ||
a(t.screen, '\x1b[2J'); | ||
a(t.line, '\x1b[2K'); | ||
a(t.screen, "\x1b[2J"); | ||
a(t.line, "\x1b[2K"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,12 +6,12 @@ module.exports = function (t, a) { | ||
a(typeof length, 'function'); | ||
a(typeof length, "function"); | ||
a(length('ABC'), 3, "Works on plain string"); | ||
a(length('\x1b[31mABC\x1b[39m'), 3, "Works on formatted string"); | ||
a(length('\x1b[31mABC\x1b[39mDE'), 5, "Works on partially formatted string"); | ||
a(length('\x1b[31mABC\x1b[39mDE'), 5, "Works on formatted string by couple of styles"); | ||
a(length("ABC"), 3, "Works on plain string"); | ||
a(length("\x1b[31mABC\x1b[39m"), 3, "Works on formatted string"); | ||
a(length("\x1b[31mABC\x1b[39mDE"), 5, "Works on partially formatted string"); | ||
a(length("\x1b[31mABC\x1b[39mDE"), 5, "Works on formatted string by couple of styles"); | ||
a(length('\x1b[31mABC\x1b[3mDE\x1b[23m\x1b[39m'), 5, "Works on nested formatted string"); | ||
a(length('\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m'), 9, | ||
a(length("\x1b[31mABC\x1b[3mDE\x1b[23m\x1b[39m"), 5, "Works on nested formatted string"); | ||
a(length("\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m"), 9, | ||
"Works on nested formatted string with overlapping styles"); | ||
}; |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
"use strict"; | ||
var bareTests = require('./bare'); | ||
var bareTests = require("./bare"); | ||
@@ -8,10 +8,10 @@ module.exports = function (t, a) { | ||
a(typeof t.windowSize.width, 'number', "Width"); | ||
a(typeof t.windowSize.width, "number", "Width"); | ||
a(t.move.up(34), '\x1b[34A', "Up: Positive"); | ||
a(t.move(2, 35), '\x1b[2C\x1b[35B', "Move: two positives"); | ||
a(t.move.up(34), "\x1b[34A", "Up: Positive"); | ||
a(t.move(2, 35), "\x1b[2C\x1b[35B", "Move: two positives"); | ||
a(t.erase.screen, '\x1b[2J', "Erase"); | ||
a(t.erase.screen, "\x1b[2J", "Erase"); | ||
a(t.beep, '\x07', "Beep"); | ||
a(t.beep, "\x07", "Beep"); | ||
}; |
@@ -1,14 +0,14 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = function (sgr, a) { | ||
a(sgr(31), '\x1b[31m', "sgr creates set graphic rendition CSIs #1"); | ||
a(sgr(39), '\x1b[39m', "sgr creates set graphic rendition CSIs #2"); | ||
a(sgr(31), "\x1b[31m", "sgr creates set graphic rendition CSIs #1"); | ||
a(sgr(39), "\x1b[39m", "sgr creates set graphic rendition CSIs #2"); | ||
a(sgr.hasCSI('\x1b[31mA\x1b[39m'), true, "sgr.hasCSI detecs CSIs in string #1"); | ||
a(sgr.hasCSI('\x1b[31m'), true, "sgr.hasCSI detecs CSIs in string #2"); | ||
a(sgr.hasCSI('[31m'), false, "sgr.hasCSI detecs CSIs in string #3"); | ||
a(sgr.hasCSI('A'), false, "sgr.hasCSI detecs CSIs in string #4"); | ||
a(sgr.hasCSI("\x1b[31mA\x1b[39m"), true, "sgr.hasCSI detecs CSIs in string #1"); | ||
a(sgr.hasCSI("\x1b[31m"), true, "sgr.hasCSI detecs CSIs in string #2"); | ||
a(sgr.hasCSI("[31m"), false, "sgr.hasCSI detecs CSIs in string #3"); | ||
a(sgr.hasCSI("A"), false, "sgr.hasCSI detecs CSIs in string #4"); | ||
a(sgr.extractCode('\x1b[31m'), 31, "sgr.extractCode extract numeric code of CSI"); | ||
a(sgr.extractCode('\x1b[39m'), 39, "sgr.extractCode extract numeric code of CSI"); | ||
a(sgr.extractCode("\x1b[31m"), 31, "sgr.extractCode extract numeric code of CSI"); | ||
a(sgr.extractCode("\x1b[39m"), 39, "sgr.extractCode extract numeric code of CSI"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -3,0 +3,0 @@ module.exports = function (t, a) { |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -3,0 +3,0 @@ module.exports = function (t, a) { |
@@ -1,37 +0,37 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = function (t, a) { | ||
a(t.up(), '', "Up: No argument"); | ||
a(t.up({}), '', "Up: Not a number"); | ||
a(t.up(-34), '', "Up: Negative"); | ||
a(t.up(34), '\x1b[34A', "Up: Positive"); | ||
a(t.up(), "", "Up: No argument"); | ||
a(t.up({}), "", "Up: Not a number"); | ||
a(t.up(-34), "", "Up: Negative"); | ||
a(t.up(34), "\x1b[34A", "Up: Positive"); | ||
a(t.down(), '', "Down: No argument"); | ||
a(t.down({}), '', "Down: Not a number"); | ||
a(t.down(-34), '', "Down: Negative"); | ||
a(t.down(34), '\x1b[34B', "Down: Positive"); | ||
a(t.down(), "", "Down: No argument"); | ||
a(t.down({}), "", "Down: Not a number"); | ||
a(t.down(-34), "", "Down: Negative"); | ||
a(t.down(34), "\x1b[34B", "Down: Positive"); | ||
a(t.right(), '', "Right: No argument"); | ||
a(t.right({}), '', "Right: Not a number"); | ||
a(t.right(-34), '', "Right: Negative"); | ||
a(t.right(34), '\x1b[34C', "Right: Positive"); | ||
a(t.right(), "", "Right: No argument"); | ||
a(t.right({}), "", "Right: Not a number"); | ||
a(t.right(-34), "", "Right: Negative"); | ||
a(t.right(34), "\x1b[34C", "Right: Positive"); | ||
a(t.left(), '', "Left: No argument"); | ||
a(t.left({}), '', "Left: Not a number"); | ||
a(t.left(-34), '', "Left: Negative"); | ||
a(t.left(34), '\x1b[34D', "Left: Positive"); | ||
a(t.left(), "", "Left: No argument"); | ||
a(t.left({}), "", "Left: Not a number"); | ||
a(t.left(-34), "", "Left: Negative"); | ||
a(t.left(34), "\x1b[34D", "Left: Positive"); | ||
a(t(), '', "Move: No arguments"); | ||
a(t({}, {}), '', "Move: Bad arguments"); | ||
a(t({}, 12), '\x1b[12B', "Move: One direction"); | ||
a(t(0, -12), '\x1b[12A', "Move: One negative direction"); | ||
a(t(-42, -2), '\x1b[42D\x1b[2A', "Move: two negatives"); | ||
a(t(2, 35), '\x1b[2C\x1b[35B', "Move: two positives"); | ||
a(t(), "", "Move: No arguments"); | ||
a(t({}, {}), "", "Move: Bad arguments"); | ||
a(t({}, 12), "\x1b[12B", "Move: One direction"); | ||
a(t(0, -12), "\x1b[12A", "Move: One negative direction"); | ||
a(t(-42, -2), "\x1b[42D\x1b[2A", "Move: two negatives"); | ||
a(t(2, 35), "\x1b[2C\x1b[35B", "Move: two positives"); | ||
a(t.to(), '\x1b[1;1H', "MoveTo: No arguments"); | ||
a(t.to({}, {}), '\x1b[1;1H', "MoveTo: Bad arguments"); | ||
a(t.to({}, 12), '\x1b[13;1H', "MoveTo: One direction"); | ||
a(t.to(2, -12), '\x1b[1;3H', "MoveTo: One negative direction"); | ||
a(t.to(-42, -2), '\x1b[1;1H', "MoveTo: two negatives"); | ||
a(t.to(2, 35), '\x1b[36;3H', "MoveTo: two positives"); | ||
a(t.to(), "\x1b[1;1H", "MoveTo: No arguments"); | ||
a(t.to({}, {}), "\x1b[1;1H", "MoveTo: Bad arguments"); | ||
a(t.to({}, 12), "\x1b[13;1H", "MoveTo: One direction"); | ||
a(t.to(2, -12), "\x1b[1;3H", "MoveTo: One negative direction"); | ||
a(t.to(-42, -2), "\x1b[1;1H", "MoveTo: two negatives"); | ||
a(t.to(2, 35), "\x1b[36;3H", "MoveTo: two positives"); | ||
}; |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = function (t, a) { | ||
a(typeof t, 'string'); | ||
a(typeof t, "string"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,88 +6,140 @@ module.exports = function (t, a) { | ||
a(typeof slice, 'function'); | ||
a(typeof slice, "function"); | ||
a(slice('ABCDE', 1), "BCDE", "Works on plain string"); | ||
a(slice('ABCDE', -1), "E", "Works on plain string"); | ||
a(slice('ABCDE', 1, 3), "BC", "Works on plain string"); | ||
a(slice('ABCDE', -3, -1), "CD", "Works on plain string"); | ||
a(slice("ABCDE", 1), "BCDE", "Works on plain string"); | ||
a(slice("ABCDE", -1), "E", "Works on plain string"); | ||
a(slice("ABCDE", 1, 3), "BC", "Works on plain string"); | ||
a(slice("ABCDE", -3, -1), "CD", "Works on plain string"); | ||
a(slice('\x1b[31mABCDE\x1b[39m', 1), "\x1b[31mBCDE\x1b[39m", | ||
"Works on whole single forecolor-styled string"); | ||
a(slice('\x1b[31mABCDE\x1b[39m', -1), "\x1b[31mE\x1b[39m", | ||
"Works on whole single forecolor-styled string"); | ||
a(slice('\x1b[31mABCDE\x1b[39m', 1, 3), "\x1b[31mBC\x1b[39m", | ||
"Works on whole single forecolor-styled string"); | ||
a(slice('\x1b[31mABCDE\x1b[39m', -3, -1), "\x1b[31mCD\x1b[39m", | ||
"Works on whole single forecolor-styled string"); | ||
a( | ||
slice("\x1b[31mABCDE\x1b[39m", 1), "\x1b[31mBCDE\x1b[39m", | ||
"Works on whole single forecolor-styled string" | ||
); | ||
a( | ||
slice("\x1b[31mABCDE\x1b[39m", -1), "\x1b[31mE\x1b[39m", | ||
"Works on whole single forecolor-styled string" | ||
); | ||
a( | ||
slice("\x1b[31mABCDE\x1b[39m", 1, 3), "\x1b[31mBC\x1b[39m", | ||
"Works on whole single forecolor-styled string" | ||
); | ||
a( | ||
slice("\x1b[31mABCDE\x1b[39m", -3, -1), "\x1b[31mCD\x1b[39m", | ||
"Works on whole single forecolor-styled string" | ||
); | ||
a(slice('\x1b[41mABCDE\x1b[49m', 1), "\x1b[41mBCDE\x1b[49m", | ||
"Works on whole single backcolor-styled string"); | ||
a(slice('\x1b[41mABCDE\x1b[49m', -1), "\x1b[41mE\x1b[49m", | ||
"Works on whole single backcolor-styled string"); | ||
a(slice('\x1b[41mABCDE\x1b[49m', 1, 3), "\x1b[41mBC\x1b[49m", | ||
"Works on whole single backcolor-styled string"); | ||
a(slice('\x1b[41mABCDE\x1b[49m', -3, -1), "\x1b[41mCD\x1b[49m", | ||
"Works on whole single backcolor-styled string"); | ||
a( | ||
slice("\x1b[41mABCDE\x1b[49m", 1), "\x1b[41mBCDE\x1b[49m", | ||
"Works on whole single backcolor-styled string" | ||
); | ||
a( | ||
slice("\x1b[41mABCDE\x1b[49m", -1), "\x1b[41mE\x1b[49m", | ||
"Works on whole single backcolor-styled string" | ||
); | ||
a( | ||
slice("\x1b[41mABCDE\x1b[49m", 1, 3), "\x1b[41mBC\x1b[49m", | ||
"Works on whole single backcolor-styled string" | ||
); | ||
a( | ||
slice("\x1b[41mABCDE\x1b[49m", -3, -1), "\x1b[41mCD\x1b[49m", | ||
"Works on whole single backcolor-styled string" | ||
); | ||
a(slice('ABC\x1b[31mDEF\x1b[39m', 0, 5), "ABC\x1b[31mDE\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string"); | ||
a(slice('ABC\x1b[31mDEF\x1b[39m', 1, 4), "BC\x1b[31mD\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string"); | ||
a(slice('ABC\x1b[31mDEF\x1b[39m', 1, 6), "BC\x1b[31mDEF\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string"); | ||
a(slice('ABC\x1b[31mDEF\x1b[39m', -5, -1), "BC\x1b[31mDE\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string"); | ||
a( | ||
slice("ABC\x1b[31mDEF\x1b[39m", 0, 5), "ABC\x1b[31mDE\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string" | ||
); | ||
a( | ||
slice("ABC\x1b[31mDEF\x1b[39m", 1, 4), "BC\x1b[31mD\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string" | ||
); | ||
a( | ||
slice("ABC\x1b[31mDEF\x1b[39m", 1, 6), "BC\x1b[31mDEF\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string" | ||
); | ||
a( | ||
slice("ABC\x1b[31mDEF\x1b[39m", -5, -1), "BC\x1b[31mDE\x1b[39m", | ||
"Save styles when chopping part of the forecolor-styled string" | ||
); | ||
a(slice('ABC\x1b[41mDEF\x1b[49m', 0, 5), "ABC\x1b[41mDE\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string"); | ||
a(slice('ABC\x1b[41mDEF\x1b[49m', 1, 4), "BC\x1b[41mD\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string"); | ||
a(slice('ABC\x1b[41mDEF\x1b[49m', 1, 6), "BC\x1b[41mDEF\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string"); | ||
a(slice('ABC\x1b[41mDEF\x1b[49m', -5, -1), "BC\x1b[41mDE\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string"); | ||
a( | ||
slice("ABC\x1b[41mDEF\x1b[49m", 0, 5), "ABC\x1b[41mDE\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string" | ||
); | ||
a( | ||
slice("ABC\x1b[41mDEF\x1b[49m", 1, 4), "BC\x1b[41mD\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string" | ||
); | ||
a( | ||
slice("ABC\x1b[41mDEF\x1b[49m", 1, 6), "BC\x1b[41mDEF\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string" | ||
); | ||
a( | ||
slice("ABC\x1b[41mDEF\x1b[49m", -5, -1), "BC\x1b[41mDE\x1b[49m", | ||
"Save styles when chopping part of the backcolor-styled string" | ||
); | ||
a(slice('\x1b[1mAAA\x1b[31mBBB\x1b[39mAAA\x1b[22m', 0, 5), "\x1b[1mAAA\x1b[31mBB\x1b[39m\x1b[22m", | ||
"Works with nested styles #1"); | ||
a(slice('\x1b[1mAAA\x1b[31mBBB\x1b[39mAAA\x1b[22m', 2, 7), "\x1b[1mA\x1b[31mBBB\x1b[39mA\x1b[22m", | ||
"Works with nested styles #2"); | ||
a(slice('\x1b[3mAAA\x1b[41mBBB\x1b[49mAAA\x1b[23m', 0, 5), "\x1b[3mAAA\x1b[41mBB\x1b[49m\x1b[23m", | ||
"Works with nested styles #3"); | ||
a(slice('\x1b[3mAAA\x1b[41mBBB\x1b[49mAAA\x1b[23m', 2, 7), "\x1b[3mA\x1b[41mBBB\x1b[49mA\x1b[23m", | ||
"Works with nested styles #4"); | ||
a(slice('\x1b[3mAAA\x1b[41mBBB\x1b[49mAAA\x1b[23m', -8, -1), | ||
"\x1b[3mAA\x1b[41mBBB\x1b[49mAA\x1b[23m", | ||
"Works with nested styles #5"); | ||
a( | ||
slice("\x1b[1mAAA\x1b[31mBBB\x1b[39mAAA\x1b[22m", 0, 5), | ||
"\x1b[1mAAA\x1b[31mBB\x1b[39m\x1b[22m", "Works with nested styles #1" | ||
); | ||
a( | ||
slice("\x1b[1mAAA\x1b[31mBBB\x1b[39mAAA\x1b[22m", 2, 7), | ||
"\x1b[1mA\x1b[31mBBB\x1b[39mA\x1b[22m", "Works with nested styles #2" | ||
); | ||
a( | ||
slice("\x1b[3mAAA\x1b[41mBBB\x1b[49mAAA\x1b[23m", 0, 5), | ||
"\x1b[3mAAA\x1b[41mBB\x1b[49m\x1b[23m", "Works with nested styles #3" | ||
); | ||
a( | ||
slice("\x1b[3mAAA\x1b[41mBBB\x1b[49mAAA\x1b[23m", 2, 7), | ||
"\x1b[3mA\x1b[41mBBB\x1b[49mA\x1b[23m", "Works with nested styles #4" | ||
); | ||
a( | ||
slice("\x1b[3mAAA\x1b[41mBBB\x1b[49mAAA\x1b[23m", -8, -1), | ||
"\x1b[3mAA\x1b[41mBBB\x1b[49mAA\x1b[23m", "Works with nested styles #5" | ||
); | ||
a(slice('\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m', 0, 5), | ||
"\x1b[31mAAA\x1b[32mBB\x1b[39m", | ||
"Works with nested overlapping styles #1"); | ||
a(slice('\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m', 2, 7), | ||
"\x1b[31mA\x1b[32mBBB\x1b[31mA\x1b[39m", | ||
"Works with nested overlapping styles #2"); | ||
a(slice('\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m', -8, -1), | ||
"\x1b[31mAA\x1b[32mBBB\x1b[31mAA\x1b[39m", | ||
"Works with nested overlapping styles #3"); | ||
a( | ||
slice("\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m", 0, 5), "\x1b[31mAAA\x1b[32mBB\x1b[39m", | ||
"Works with nested overlapping styles #1" | ||
); | ||
a( | ||
slice("\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m", 2, 7), | ||
"\x1b[31mA\x1b[32mBBB\x1b[31mA\x1b[39m", "Works with nested overlapping styles #2" | ||
); | ||
a( | ||
slice("\x1b[31mAAA\x1b[32mBBB\x1b[31mAAA\x1b[39m", -8, -1), | ||
"\x1b[31mAA\x1b[32mBBB\x1b[31mAA\x1b[39m", "Works with nested overlapping styles #3" | ||
); | ||
/* CSI at the edge of slice */ | ||
a(slice('ABC\x1b[31mDEF\x1b[39m', 3), "\x1b[31mDEF\x1b[39m", "Does not corrupt start CSI"); | ||
a(slice('\x1b[41mABC\x1b[49mDEF', 0, 3), "\x1b[41mABC\x1b[49m", "Does not corrupt end CSI"); | ||
a(slice("ABC\x1b[31mDEF\x1b[39m", 3), "\x1b[31mDEF\x1b[39m", "Does not corrupt start CSI"); | ||
a(slice("\x1b[41mABC\x1b[49mDEF", 0, 3), "\x1b[41mABC\x1b[49m", "Does not corrupt end CSI"); | ||
/* CSI-reducing tests */ | ||
a(slice('ABC\x1b[31mDEF\x1b[39m', 0, 3), "ABC", "Does not mixin CSI to plain string"); | ||
a(slice('ABCD\x1b[31mEF\x1b[39m', 0, 3), "ABC", "Does not mixin CSI to plain string"); | ||
a(slice('\x1b[41mABC\x1b[49mDEF', 3), "DEF", "Does not mixin CSI to plain string"); | ||
a(slice('\x1b[41mAB\x1b[49mCDEF', 3), "DEF", "Does not mixin CSI to plain string"); | ||
a(slice("ABC\x1b[31mDEF\x1b[39m", 0, 3), "ABC", "Does not mixin CSI to plain string"); | ||
a(slice("ABCD\x1b[31mEF\x1b[39m", 0, 3), "ABC", "Does not mixin CSI to plain string"); | ||
a(slice("\x1b[41mABC\x1b[49mDEF", 3), "DEF", "Does not mixin CSI to plain string"); | ||
a(slice("\x1b[41mAB\x1b[49mCDEF", 3), "DEF", "Does not mixin CSI to plain string"); | ||
a(slice('A\x1b[31mBBB\x1b[39mD\x1b[32mE\x1b[39m', 2, 3), "\x1b[31mB\x1b[39m", | ||
"Does slice with surrounding styles"); | ||
a(slice('A\x1b[31mBBB\x1b[39mD\x1b[32mE\x1b[39m', 0, 5), "A\x1b[31mBBB\x1b[39mD", | ||
"Does slice with inner styles"); | ||
a( | ||
slice("A\x1b[31mBBB\x1b[39mD\x1b[32mE\x1b[39m", 2, 3), "\x1b[31mB\x1b[39m", | ||
"Does slice with surrounding styles" | ||
); | ||
a( | ||
slice("A\x1b[31mBBB\x1b[39mD\x1b[32mE\x1b[39m", 0, 5), "A\x1b[31mBBB\x1b[39mD", | ||
"Does slice with inner styles" | ||
); | ||
a(slice('A\x1b[31mBBB\x1b[39m\x1b[2J\x1b[0;0H', 0, 4), "A\x1b[31mBBB\x1b[39m", | ||
"Remove reset CSI"); | ||
a( | ||
slice("A\x1b[31mBBB\x1b[39m\x1b[2J\x1b[0;0H", 0, 4), "A\x1b[31mBBB\x1b[39m", | ||
"Remove reset CSI" | ||
); | ||
// 'A' + clc.red('BBB') + clc.erase.screen + clc.move.to(0, 0) | ||
a(slice('A\u001b[31mBBB\u001b[39m\u001b[2J\u001b[1;1H', 0, 4), "A\x1b[31mBBB\x1b[39m", | ||
"Remove control CSIs"); | ||
a( | ||
slice("A\u001b[31mBBB\u001b[39m\u001b[2J\u001b[1;1H", 0, 4), "A\x1b[31mBBB\x1b[39m", | ||
"Remove control CSIs" | ||
); | ||
}; |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('../'); | ||
var clc = require("../"); | ||
@@ -9,91 +9,91 @@ module.exports = function (t, a) { | ||
a(t('test'), 'test', "Plain"); | ||
a(t("test"), "test", "Plain"); | ||
a(t('\x1bA'), '', "Simple Command Type 1"); | ||
a(t('\x9bA'), '', "Simple Command Type 2"); | ||
a(t("\x1bA"), "", "Simple Command Type 1"); | ||
a(t("\x9bA"), "", "Simple Command Type 2"); | ||
a(t('\x1b[0A'), '', "Single Command"); | ||
a(t('\x1b[0;A'), '', "Single Separated Command"); | ||
a(t('\x1b[0;0A'), '', "Two Commands"); | ||
a(t('\x1b[0;0;A'), '', "Two Separated Commands"); | ||
a(t("\x1b[0A"), "", "Single Command"); | ||
a(t("\x1b[0;A"), "", "Single Separated Command"); | ||
a(t("\x1b[0;0A"), "", "Two Commands"); | ||
a(t("\x1b[0;0;A"), "", "Two Separated Commands"); | ||
// Base on index tests. | ||
a(t(clc.red('foo')), 'foo', "Foreground"); | ||
a(t(clc.red('foo', 'bar', 3)), 'foo bar 3', "Foreground: Many args"); | ||
a(t(clc.red.yellow('foo', 'bar', 3)), 'foo bar 3', "Foreground: Overriden"); | ||
a(t(clc.bgRed('foo', 'bar')), 'foo bar', "Background"); | ||
a(t(clc.bgRed.bgYellow('foo', 'bar', 3)), 'foo bar 3', "Background: Overriden"); | ||
a(t(clc.red("foo")), "foo", "Foreground"); | ||
a(t(clc.red("foo", "bar", 3)), "foo bar 3", "Foreground: Many args"); | ||
a(t(clc.red.yellow("foo", "bar", 3)), "foo bar 3", "Foreground: Overriden"); | ||
a(t(clc.bgRed("foo", "bar")), "foo bar", "Background"); | ||
a(t(clc.bgRed.bgYellow("foo", "bar", 3)), "foo bar 3", "Background: Overriden"); | ||
a(t(clc.blue.bgYellow('foo', 'bar')), 'foo bar', "Foreground & Background"); | ||
a(t(clc.blue.bgYellow.red.bgMagenta('foo', 'bar')), | ||
'foo bar', | ||
a(t(clc.blue.bgYellow("foo", "bar")), "foo bar", "Foreground & Background"); | ||
a(t(clc.blue.bgYellow.red.bgMagenta("foo", "bar")), | ||
"foo bar", | ||
"Foreground & Background: Overriden"); | ||
a(t(clc.bold('foo', 'bar')), 'foo bar', "Format"); | ||
a(t(clc.blink('foobar')), 'foobar', "Format: blink"); | ||
a(t(clc.bold.blue('foo', 'bar', 3)), 'foo bar 3', "Foreground & Format"); | ||
a(t(clc.bold("foo", "bar")), "foo bar", "Format"); | ||
a(t(clc.blink("foobar")), "foobar", "Format: blink"); | ||
a(t(clc.bold.blue("foo", "bar", 3)), "foo bar 3", "Foreground & Format"); | ||
a(t(clc.redBright('foo', 'bar')), 'foo bar', "Bright"); | ||
a(t(clc.bgRedBright('foo', 3)), 'foo 3', "Bright background"); | ||
a(t(clc.redBright("foo", "bar")), "foo bar", "Bright"); | ||
a(t(clc.bgRedBright("foo", 3)), "foo 3", "Bright background"); | ||
a(t(clc.blueBright.bgYellowBright.red.bgMagenta('foo', 'bar')), | ||
'foo bar', | ||
a(t(clc.blueBright.bgYellowBright.red.bgMagenta("foo", "bar")), | ||
"foo bar", | ||
"Foreground & Background: Bright: Overriden"); | ||
a(t(clc.red.blue('foo')), 'foo', "Prioritize the Last Color: Blue"); | ||
a(t(clc.blue.red('foo')), 'foo', "Prioritize the Last Color: Red"); | ||
a(t(clc.bgRed.bgBlue('foo')), 'foo', "Prioritize the Last Background Color: Blue"); | ||
a(t(clc.bgBlue.bgRed('foo')), 'foo', "Prioritize the Last Background Color: Red"); | ||
a(t(clc.bgRed.red.bgBlue.blue('foo')), 'foo', "Prioritize the Last Mixed Style: Blue"); | ||
a(t(clc.bgBlue.blue.bgRed.red('foo')), 'foo', "Prioritize the Last Mixed Style: Red"); | ||
a(t(clc.bgRed.blue.bgBlue.red('foo')), | ||
'foo', | ||
a(t(clc.red.blue("foo")), "foo", "Prioritize the Last Color: Blue"); | ||
a(t(clc.blue.red("foo")), "foo", "Prioritize the Last Color: Red"); | ||
a(t(clc.bgRed.bgBlue("foo")), "foo", "Prioritize the Last Background Color: Blue"); | ||
a(t(clc.bgBlue.bgRed("foo")), "foo", "Prioritize the Last Background Color: Red"); | ||
a(t(clc.bgRed.red.bgBlue.blue("foo")), "foo", "Prioritize the Last Mixed Style: Blue"); | ||
a(t(clc.bgBlue.blue.bgRed.red("foo")), "foo", "Prioritize the Last Mixed Style: Red"); | ||
a(t(clc.bgRed.blue.bgBlue.red("foo")), | ||
"foo", | ||
"Prioritize the Last Mixed Style: BG Blue and Red"); | ||
a(t(clc.bgBlue.red.bgRed.blue('foo')), | ||
'foo', | ||
a(t(clc.bgBlue.red.bgRed.blue("foo")), | ||
"foo", | ||
"Prioritize the Last Mixed Style: BG Red and Blue"); | ||
a(t(x('foo', 'red') + ' ' + y('foo', 'boldred')), | ||
'foo red foo boldred', | ||
a(t(x("foo", "red") + " " + y("foo", "boldred")), | ||
"foo red foo boldred", | ||
"Detached extension"); | ||
a(t(clc.erase.screen).replace(/\n/g, ''), '', "Reset"); | ||
a(t(clc.erase.screen).replace(/\n/g, ""), "", "Reset"); | ||
a(t(clc.move.up()), '', "Up: No argument"); | ||
a(t(clc.move.up({})), '', "Up: Not a number"); | ||
a(t(clc.move.up(-34)), '', "Up: Negative"); | ||
a(t(clc.move.up(34)), '', "Up: Positive"); | ||
a(t(clc.move.up()), "", "Up: No argument"); | ||
a(t(clc.move.up({})), "", "Up: Not a number"); | ||
a(t(clc.move.up(-34)), "", "Up: Negative"); | ||
a(t(clc.move.up(34)), "", "Up: Positive"); | ||
a(t(clc.move.down()), '', "Down: No argument"); | ||
a(t(clc.move.down({})), '', "Down: Not a number"); | ||
a(t(clc.move.down(-34)), '', "Down: Negative"); | ||
a(t(clc.move.down(34)), '', "Down: Positive"); | ||
a(t(clc.move.down()), "", "Down: No argument"); | ||
a(t(clc.move.down({})), "", "Down: Not a number"); | ||
a(t(clc.move.down(-34)), "", "Down: Negative"); | ||
a(t(clc.move.down(34)), "", "Down: Positive"); | ||
a(t(clc.move.right()), '', "Right: No argument"); | ||
a(t(clc.move.right({})), '', "Right: Not a number"); | ||
a(t(clc.move.right(-34)), '', "Right: Negative"); | ||
a(t(clc.move.right(34)), '', "Right: Positive"); | ||
a(t(clc.move.right()), "", "Right: No argument"); | ||
a(t(clc.move.right({})), "", "Right: Not a number"); | ||
a(t(clc.move.right(-34)), "", "Right: Negative"); | ||
a(t(clc.move.right(34)), "", "Right: Positive"); | ||
a(t(clc.move.left()), '', "Left: No argument"); | ||
a(t(clc.move.left({})), '', "Left: Not a number"); | ||
a(t(clc.move.left(-34)), '', "Left: Negative"); | ||
a(t(clc.move.left(34)), '', "Left: Positive"); | ||
a(t(clc.move.left()), "", "Left: No argument"); | ||
a(t(clc.move.left({})), "", "Left: Not a number"); | ||
a(t(clc.move.left(-34)), "", "Left: Negative"); | ||
a(t(clc.move.left(34)), "", "Left: Positive"); | ||
a(t(clc.move()), '', "Move: No arguments"); | ||
a(t(clc.move({}, {})), '', "Move: Bad arguments"); | ||
a(t(clc.move({}, 12)), '', "Move: One direction"); | ||
a(t(clc.move(0, -12)), '', "Move: One negative direction"); | ||
a(t(clc.move(-42, -2)), '', "Move: two negatives"); | ||
a(t(clc.move(2, 35)), '', "Move: two positives"); | ||
a(t(clc.move()), "", "Move: No arguments"); | ||
a(t(clc.move({}, {})), "", "Move: Bad arguments"); | ||
a(t(clc.move({}, 12)), "", "Move: One direction"); | ||
a(t(clc.move(0, -12)), "", "Move: One negative direction"); | ||
a(t(clc.move(-42, -2)), "", "Move: two negatives"); | ||
a(t(clc.move(2, 35)), "", "Move: two positives"); | ||
a(t(clc.move.to()), '', "MoveTo: No arguments"); | ||
a(t(clc.move.to({}, {})), '', "MoveTo: Bad arguments"); | ||
a(t(clc.move.to({}, 12)), '', "MoveTo: One direction"); | ||
a(t(clc.move.to(2, -12)), '', "MoveTo: One negative direction"); | ||
a(t(clc.move.to(-42, -2)), '', "MoveTo: two negatives"); | ||
a(t(clc.move.to(2, 35)), '', "MoveTo: two positives"); | ||
a(t(clc.move.to()), "", "MoveTo: No arguments"); | ||
a(t(clc.move.to({}, {})), "", "MoveTo: Bad arguments"); | ||
a(t(clc.move.to({}, 12)), "", "MoveTo: One direction"); | ||
a(t(clc.move.to(2, -12)), "", "MoveTo: One negative direction"); | ||
a(t(clc.move.to(-42, -2)), "", "MoveTo: two negatives"); | ||
a(t(clc.move.to(2, 35)), "", "MoveTo: two positives"); | ||
a(t(clc.beep), clc.beep, "Beep"); | ||
a(t('test'), 'test', "Plain"); | ||
a(t("test"), "test", "Plain"); | ||
}; |
@@ -1,20 +0,16 @@ | ||
'use strict'; | ||
"use strict"; | ||
var startsWith = require('es5-ext/string/#/starts-with') | ||
, spawn = require('child_process').spawn | ||
, resolve = require('path').resolve | ||
, pg = resolve(__dirname, '__playground'); | ||
var startsWith = require("es5-ext/string/#/starts-with") | ||
, spawn = require("child_process").spawn | ||
, resolve = require("path").resolve; | ||
var pg = resolve(__dirname, "__playground"); | ||
module.exports = { | ||
"": function (a, d) { | ||
var t = spawn('node', [resolve(pg, 'throbber.js')]) | ||
, out = [], err = ''; | ||
var t = spawn("node", [resolve(pg, "throbber.js")]), out = [], err = ""; | ||
t.stdout.on('data', function (data) { | ||
out.push(data); | ||
}); | ||
t.stderr.on('data', function (data) { | ||
err += data; | ||
}); | ||
t.on('exit', function () { | ||
t.stdout.on("data", function (data) { out.push(data); }); | ||
t.stderr.on("data", function (data) { err += data; }); | ||
t.on("exit", function () { | ||
a.ok(out.length > 4, "Interval"); | ||
@@ -26,17 +22,17 @@ a(startsWith.call(out.join(""), "START-\b\\\b|\b/\b-\b"), true, "Output"); | ||
}, | ||
Formatted: function (a, d) { | ||
var t = spawn('node', [resolve(pg, 'throbber.formatted.js')]) | ||
, out = [], err = ''; | ||
"Formatted": function (a, d) { | ||
var t = spawn("node", [resolve(pg, "throbber.formatted.js")]), out = [], err = ""; | ||
t.stdout.on('data', function (data) { | ||
out.push(data); | ||
}); | ||
t.stderr.on('data', function (data) { | ||
err += data; | ||
}); | ||
t.on('exit', function () { | ||
t.stdout.on("data", function (data) { out.push(data); }); | ||
t.stderr.on("data", function (data) { err += data; }); | ||
t.on("exit", function () { | ||
a.ok(out.length > 4, "Interval"); | ||
a(startsWith.call(out.join(""), "START\x1b[31m-\x1b[39m\x1b[31m\b\\\x1b" + | ||
"[39m\x1b[31m\b|\x1b[39m\x1b[31m\b/\x1b[39m\x1b[31m\b-\x1b[39m"), | ||
true, "Output"); | ||
a( | ||
startsWith.call( | ||
out.join(""), | ||
"START\x1b[31m-\x1b[39m\x1b[31m\b\\\x1b" + | ||
"[39m\x1b[31m\b|\x1b[39m\x1b[31m\b/\x1b[39m\x1b[31m\b-\x1b[39m" | ||
), | ||
true, "Output" | ||
); | ||
a(err, "", "No stderr output"); | ||
@@ -43,0 +39,0 @@ d(); |
@@ -1,21 +0,15 @@ | ||
'use strict'; | ||
"use strict"; | ||
var clc = require('./') | ||
var clc = require("./"); | ||
, colors = [ 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white' ]; | ||
var colors = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"]; | ||
// Write some message. | ||
function w(message) { | ||
process.stdout.write(message); | ||
} | ||
var w = function (message) { process.stdout.write(message); }; | ||
// Print colors. | ||
function printColors(title, style) { | ||
var j = colors.length | ||
, color | ||
, colorText | ||
, tint | ||
, i; | ||
var printColors = function (title, style) { | ||
var j = colors.length, color, colorText, tint, i; | ||
w(' > ' + clc.whiteBright(title) + ' '); | ||
w(" > " + clc.whiteBright(title) + " "); | ||
for (i = 0; i < j; i++) { | ||
@@ -26,6 +20,6 @@ tint = clc; | ||
if (style === 'foreground') { | ||
if (style === "foreground") { | ||
tint = tint[color]; | ||
if (color === 'black') { | ||
if (color === "black") { | ||
tint = tint.bgBlackBright; | ||
@@ -35,10 +29,10 @@ } | ||
if (style === 'foregroundBright') { | ||
tint = tint[color + 'Bright']; | ||
if (style === "foregroundBright") { | ||
tint = tint[color + "Bright"]; | ||
} | ||
if (style === 'background') { | ||
tint = tint['bg' + color.slice(0, 1).toUpperCase() + color.slice(1)]; | ||
if (style === "background") { | ||
tint = tint["bg" + color.slice(0, 1).toUpperCase() + color.slice(1)]; | ||
if (color === 'white') { | ||
if (color === "white") { | ||
tint = tint.whiteBright; | ||
@@ -48,10 +42,10 @@ } | ||
if (style === 'backgroundBright') { | ||
tint = tint['bg' + color.slice(0, 1).toUpperCase() + color.slice(1) + 'Bright']; | ||
if (style === "backgroundBright") { | ||
tint = tint["bg" + color.slice(0, 1).toUpperCase() + color.slice(1) + "Bright"]; | ||
} | ||
w(tint(colorText) + ' '); | ||
w(tint(colorText) + " "); | ||
} | ||
w('\n'); | ||
} | ||
w("\n"); | ||
}; | ||
@@ -61,3 +55,3 @@ // Smile test. | ||
w('\n SMILE TEST\n\n'); | ||
w("\n SMILE TEST\n\n"); | ||
@@ -103,22 +97,21 @@ // Yellow face. | ||
// Colors test. | ||
w('\n COLORS TESTS\n'); | ||
printColors('FOREGROUNDS (DEFAULT)', 'foreground'); | ||
printColors('FOREGROUNDS (BRIGHT) ', 'foregroundBright'); | ||
printColors('BACKGROUNDS (DEFAULT)', 'background'); | ||
printColors('BACKGROUNDS (BRIGHT) ', 'backgroundBright'); | ||
w("\n COLORS TESTS\n"); | ||
printColors("FOREGROUNDS (DEFAULT)", "foreground"); | ||
printColors("FOREGROUNDS (BRIGHT) ", "foregroundBright"); | ||
printColors("BACKGROUNDS (DEFAULT)", "background"); | ||
printColors("BACKGROUNDS (BRIGHT) ", "backgroundBright"); | ||
// // Art test. | ||
w('\n ART TESTS\n\n'); | ||
w(clc.art('\t.01111111112.\n' + | ||
'\t.3.........3.\n' + | ||
'\t.3.........3.\n' + | ||
'\t.41111111115.\n', { | ||
"0": clc.bgBlue.yellowBright('\u2554'), | ||
"1": clc.bgBlue.yellowBright('\u2550'), | ||
"2": clc.bgBlue.yellowBright('\u2557'), | ||
"3": clc.bgBlue.yellowBright('\u2551'), | ||
"4": clc.bgBlue.yellowBright('\u255A'), | ||
"5": clc.bgBlue.yellowBright('\u255D'), | ||
".": clc.bgBlue(' ') | ||
})); | ||
w("\n ART TESTS\n\n"); | ||
w( | ||
clc.art("\t.01111111112.\n\t.3.........3.\n\t.3.........3.\n\t.41111111115.\n", { | ||
"0": clc.bgBlue.yellowBright("\u2554"), | ||
"1": clc.bgBlue.yellowBright("\u2550"), | ||
"2": clc.bgBlue.yellowBright("\u2557"), | ||
"3": clc.bgBlue.yellowBright("\u2551"), | ||
"4": clc.bgBlue.yellowBright("\u255A"), | ||
"5": clc.bgBlue.yellowBright("\u255D"), | ||
".": clc.bgBlue(" ") | ||
}) | ||
); | ||
w(clc.move(11, -3)); | ||
@@ -129,2 +122,2 @@ w(clc.bgBlue.whiteBright("Hello")); | ||
w(clc.move(0, 2)); | ||
w('\n'); | ||
w("\n"); |
@@ -1,8 +0,8 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = function (t, a) { | ||
a(typeof t.width, 'number', "Width"); | ||
a(typeof t.height, 'number', "Height"); | ||
a(typeof t.width, "number", "Width"); | ||
a(typeof t.height, "number", "Height"); | ||
a(t.width >= 0, true); | ||
a(t.height >= 0, true); | ||
}; |
@@ -1,11 +0,13 @@ | ||
'use strict'; | ||
"use strict"; | ||
var compose = require('es5-ext/function/#/compose') | ||
, callable = require('es5-ext/object/valid-callable') | ||
, d = require('d') | ||
, validTimeout = require('timers-ext/valid-timeout') | ||
var compose = require("es5-ext/function/#/compose") | ||
, callable = require("es5-ext/object/valid-callable") | ||
, d = require("d") | ||
, validTimeout = require("timers-ext/valid-timeout"); | ||
, chars = '-\\|/', l = chars.length, ThrobberIterator; | ||
var chars = "-\\|/", l = chars.length, ThrobberIterator; | ||
ThrobberIterator = function () {}; | ||
ThrobberIterator = function () { | ||
// no setup needed | ||
}; | ||
Object.defineProperties(ThrobberIterator.prototype, { | ||
@@ -15,11 +17,11 @@ index: d(-1), | ||
next: d(function () { | ||
var str = this.running ? '\u0008' : ''; | ||
var str = this.running ? "\u0008" : ""; | ||
if (!this.running) this.running = true; | ||
return str + chars[this.index = ((this.index + 1) % l)]; | ||
return str + chars[this.index = (this.index + 1) % l]; | ||
}), | ||
reset: d(function () { | ||
if (!this.running) return ''; | ||
if (!this.running) return ""; | ||
this.index = -1; | ||
this.running = false; | ||
return '\u0008'; | ||
return "\u0008"; | ||
}) | ||
@@ -51,2 +53,2 @@ }); | ||
Object.defineProperty(exports, 'Iterator', d(ThrobberIterator)); | ||
Object.defineProperty(exports, "Iterator", d(ThrobberIterator)); |
@@ -1,8 +0,8 @@ | ||
'use strict'; | ||
"use strict"; | ||
var d = require('d'); | ||
var d = require("d"); | ||
Object.defineProperties(exports, { | ||
width: d.gs('ce', function () { return process.stdout.columns || 0; }), | ||
height: d.gs('ce', function () { return process.stdout.rows || 0; }) | ||
width: d.gs("ce", function () { return process.stdout.columns || 0; }), | ||
height: d.gs("ce", function () { return process.stdout.rows || 0; }) | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
93325
1346
707
2
Updatedes5-ext@^0.10.46
Updatedes6-iterator@^2.0.3
Updatedmemoizee@^0.4.14
Updatedtimers-ext@^0.1.5