This commit is contained in:
Philipp Kunz 2017-01-21 18:26:22 +01:00
parent 995c64525e
commit 0318cd2686
3 changed files with 21 additions and 15 deletions

2
dist/index.d.ts vendored
View File

@ -2,7 +2,7 @@ import 'typings-global';
/** /**
* all the color names that are available for proper xterm translation * all the color names that are available for proper xterm translation
*/ */
export declare type TColorName = 'black' | 'blue' | 'brown' | 'cyan' | 'green' | 'red' | 'orange' | 'white'; export declare type TColorName = 'black' | 'black' | 'blue' | 'brown' | 'cyan' | 'green' | 'orange' | 'pink' | 'red' | 'white';
export interface IRGB { export interface IRGB {
r: number; r: number;
b: number; b: number;

16
dist/index.js vendored
View File

@ -6,20 +6,22 @@ const ansiColors = require("ansi-256-colors");
*/ */
let colorTranslator = (colorArg) => { let colorTranslator = (colorArg) => {
switch (colorArg) { switch (colorArg) {
case 'black':
return { r: 0, g: 0, b: 0 };
case 'blue': case 'blue':
return { r: 0, g: 1, b: 5 }; return { r: 0, g: 1, b: 5 };
case 'brown':
return { r: 1, g: 0, b: 0 };
case 'cyan': case 'cyan':
return { r: 0, g: 4, b: 4 }; return { r: 0, g: 4, b: 4 };
case 'green': case 'green':
return { r: 2, g: 5, b: 0 }; return { r: 2, g: 5, b: 0 };
case 'red':
return { r: 5, g: 0, b: 0 };
case 'orange': case 'orange':
return { r: 5, g: 3, b: 0 }; return { r: 5, g: 3, b: 0 };
case 'brown': case 'pink':
return { r: 1, g: 0, b: 0 }; return { r: 5, g: 0, b: 5 };
case 'black': case 'red':
return { r: 0, g: 0, b: 0 }; return { r: 5, g: 0, b: 0 };
case 'white': case 'white':
return { r: 5, g: 5, b: 5 }; return { r: 5, g: 5, b: 5 };
default: default:
@ -51,4 +53,4 @@ exports.coloredString = (stringArg, colorFontArg, colorBackgroundArg) => {
returnString = returnString + ansiColors.reset; returnString = returnString + ansiColors.reset;
return returnString; return returnString;
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb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DQUFBO0lBQzlDLE1BQU0sQ0FBQyxZQUFZLENBQUE7QUFDdkIsQ0FBQyxDQUFBIn0=

View File

@ -5,12 +5,14 @@ import * as ansiColors from 'ansi-256-colors'
* all the color names that are available for proper xterm translation * all the color names that are available for proper xterm translation
*/ */
export type TColorName = 'black' | export type TColorName = 'black' |
'black' |
'blue' | 'blue' |
'brown' | 'brown' |
'cyan' | 'cyan' |
'green' | 'green' |
'red' |
'orange' | 'orange' |
'pink' |
'red' |
'white' 'white'
export interface IRGB { export interface IRGB {
@ -24,20 +26,22 @@ export interface IRGB {
*/ */
let colorTranslator = (colorArg: TColorName): IRGB => { let colorTranslator = (colorArg: TColorName): IRGB => {
switch (colorArg) { switch (colorArg) {
case 'black':
return {r: 0, g: 0, b: 0}
case 'blue': case 'blue':
return {r: 0, g: 1, b: 5} return {r: 0, g: 1, b: 5}
case 'brown':
return {r: 1, g: 0 , b: 0}
case 'cyan': case 'cyan':
return {r: 0,g: 4, b: 4} return {r: 0,g: 4, b: 4}
case 'green': case 'green':
return {r: 2, g: 5, b: 0} return {r: 2, g: 5, b: 0}
case 'red':
return {r: 5, g: 0, b: 0}
case 'orange': case 'orange':
return {r: 5, g: 3, b: 0} return {r: 5, g: 3, b: 0}
case 'brown': case 'pink':
return {r: 1, g: 0 , b: 0} return {r: 5, g: 0, b: 5}
case 'black': case 'red':
return {r: 0, g: 0, b: 0} return {r: 5, g: 0, b: 0}
case 'white': case 'white':
return {r: 5, g: 5, b: 5} return {r: 5, g: 5, b: 5}
default: default: