2017-01-21 17:10:27 +00:00
|
|
|
"use strict";
|
2017-08-16 08:42:48 +00:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2017-01-21 17:10:27 +00:00
|
|
|
require("typings-global");
|
|
|
|
const ansiColors = require("ansi-256-colors");
|
|
|
|
/**
|
|
|
|
* the color translator function
|
|
|
|
*/
|
|
|
|
let colorTranslator = (colorArg) => {
|
|
|
|
switch (colorArg) {
|
2017-01-21 17:26:22 +00:00
|
|
|
case 'black':
|
|
|
|
return { r: 0, g: 0, b: 0 };
|
2017-01-21 17:10:27 +00:00
|
|
|
case 'blue':
|
2017-01-21 19:30:53 +00:00
|
|
|
return { r: 0, g: 2, b: 5 };
|
2017-01-21 17:26:22 +00:00
|
|
|
case 'brown':
|
|
|
|
return { r: 1, g: 0, b: 0 };
|
2017-01-21 17:10:27 +00:00
|
|
|
case 'cyan':
|
2017-01-21 18:46:51 +00:00
|
|
|
return { r: 2, g: 4, b: 4 };
|
2017-01-21 17:10:27 +00:00
|
|
|
case 'green':
|
2017-01-21 19:27:25 +00:00
|
|
|
return { r: 2, g: 4, b: 1 };
|
2017-01-21 17:10:27 +00:00
|
|
|
case 'orange':
|
2017-01-21 19:27:25 +00:00
|
|
|
return { r: 5, g: 3, b: 1 };
|
2017-01-21 17:26:22 +00:00
|
|
|
case 'pink':
|
2017-01-21 19:27:25 +00:00
|
|
|
return { r: 3, g: 2, b: 4 };
|
2017-01-21 17:26:22 +00:00
|
|
|
case 'red':
|
|
|
|
return { r: 5, g: 0, b: 0 };
|
2017-01-21 17:10:27 +00:00
|
|
|
case 'white':
|
|
|
|
return { r: 5, g: 5, b: 5 };
|
|
|
|
default:
|
|
|
|
return { r: 5, g: 5, b: 5 };
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* colors the font of a string
|
|
|
|
*/
|
|
|
|
let coloredFont = (stringArg, colorArg) => {
|
|
|
|
let rgbCode = colorTranslator(colorArg);
|
|
|
|
return ansiColors.fg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* colors the back of a string
|
|
|
|
*/
|
|
|
|
let coloredBackground = (stringArg, colorArg) => {
|
|
|
|
let rgbCode = colorTranslator(colorArg);
|
|
|
|
return ansiColors.bg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* color a string with xterm
|
|
|
|
*/
|
|
|
|
exports.coloredString = (stringArg, colorFontArg, colorBackgroundArg) => {
|
|
|
|
let returnString = coloredFont(stringArg, colorFontArg);
|
|
|
|
if (colorBackgroundArg) {
|
|
|
|
returnString = coloredBackground(returnString, colorBackgroundArg);
|
|
|
|
}
|
|
|
|
returnString = returnString + ansiColors.reset;
|
|
|
|
return returnString;
|
|
|
|
};
|
2017-08-16 10:14:49 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qiw4Q0FBNkM7QUFzQjdDOztHQUVHO0FBQ0gsSUFBSSxlQUFlLEdBQUcsQ0FBQyxRQUFvQjtJQUN6QyxNQUFNLENBQUMsQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDO1FBQ2pCLEtBQUssT0FBTztZQUNWLE1BQU0sQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUE7UUFDN0IsS0FBSyxNQUFNO1lBQ1QsTUFBTSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQTtRQ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