fix indention
This commit is contained in:
parent
166ae81795
commit
9043933be5
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -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' | 'black' | 'blue' | 'brown' | 'cyan' | 'green' | 'orange' | 'pink' | 'red' | 'white';
|
export declare type TColorName = 'black' | 'blue' | 'brown' | 'cyan' | 'green' | 'orange' | 'pink' | 'red' | 'white';
|
||||||
export interface IRGB {
|
export interface IRGB {
|
||||||
r: number;
|
r: number;
|
||||||
b: number;
|
b: number;
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -54,4 +54,4 @@ exports.coloredString = (stringArg, colorFontArg, colorBackgroundArg) => {
|
|||||||
returnString = returnString + ansiColors.reset;
|
returnString = returnString + ansiColors.reset;
|
||||||
return returnString;
|
return returnString;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qiw4Q0FBNkM7QUFzQjdDOztHQUVHO0FBQ0gsSUFBSSxlQUFlLEdBQUcsQ0FBQyxRQUFvQjtJQUN2QyxNQUFNLENBQUMsQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDO1FBQ2YsS0FBSyxPQUFPO1lBQ1IsTUFBTSxDQUFDLEVBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUMsQ0FBQTtRQUM3QixLQUFLLE1BQU07WUFDUCxNQUFNLENBQUMsRUFBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENB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UsT0FBTyxDQUFDLENBQUMsQ0FBQyxHQUFHLFNBQVMsQ0FBQTtBQUMxRSxDQUFDLENBQUE7QUFFRDs7R0FFRztBQUNILElBQUksaUJBQWlCLEdBQUcsQ0FBQyxTQUFpQixFQUFFLFFBQW9CO0lBQzlELElBQUksT0FBTyxHQUFHLGVBQWUsQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUN2QyxNQUFNLENBQUMsVUFBVSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxPQUFPLENBQUMsQ0FBQyxFQUFFLE9BQU8sQ0FBQyxDQUFDLENBQUMsR0FBRyxTQUFTLENBQUE7QUFDMUUsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLGFBQWEsR0FBRyxDQUFDLFNBQWlCLEVBQUUsWUFBd0IsRUFBRSxrQkFBK0I7SUFDdEcsSUFBSSxZQUFZLEdBQUcsV0FBVyxDQUFDLFNBQVMsRUFBRSxZQUFZLENBQUMsQ0FBQTtJQUN2RCxFQUFFLENBQUMsQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDLENBQUM7UUFDdkIsWUFBWSxHQUFHLGlCQUFpQixDQUFDLFlBQVksRUFBRSxrQkFBa0IsQ0FBQyxDQUFBO0lBQ3BFLENBQUM7SUFDRCxZQUFZLEdBQUcsWUFBWSxHQUFHLFVBQVUsQ0FBQyxLQUFLLENBQUE7SUFDOUMsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUNyQixDQUFDLENBQUEifQ==
|
90
ts/index.ts
90
ts/index.ts
@ -4,75 +4,75 @@ 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' |
|
||||||
'orange' |
|
'orange' |
|
||||||
'pink' |
|
'pink' |
|
||||||
'red' |
|
'red' |
|
||||||
'white'
|
'white'
|
||||||
|
|
||||||
export interface IRGB {
|
export interface IRGB {
|
||||||
r: number,
|
r: number,
|
||||||
b: number,
|
b: number,
|
||||||
g: number
|
g: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the color translator function
|
* the color translator function
|
||||||
*/
|
*/
|
||||||
let colorTranslator = (colorArg: TColorName): IRGB => {
|
let colorTranslator = (colorArg: TColorName): IRGB => {
|
||||||
switch (colorArg) {
|
switch (colorArg) {
|
||||||
case 'black':
|
case 'black':
|
||||||
return {r: 0, g: 0, b: 0}
|
return { r: 0, g: 0, b: 0 }
|
||||||
case 'blue':
|
case 'blue':
|
||||||
return {r: 0, g: 2, b: 5}
|
return { r: 0, g: 2, b: 5 }
|
||||||
case 'brown':
|
case 'brown':
|
||||||
return {r: 1, g: 0 , b: 0}
|
return { r: 1, g: 0, b: 0 }
|
||||||
case 'cyan':
|
case 'cyan':
|
||||||
return {r: 2,g: 4, b: 4}
|
return { r: 2, g: 4, b: 4 }
|
||||||
case 'green':
|
case 'green':
|
||||||
return {r: 2, g: 4, b: 1}
|
return { r: 2, g: 4, b: 1 }
|
||||||
case 'orange':
|
case 'orange':
|
||||||
return {r: 5, g: 3, b: 1}
|
return { r: 5, g: 3, b: 1 }
|
||||||
case 'pink':
|
case 'pink':
|
||||||
return {r: 3, g: 2, b: 4}
|
return { r: 3, g: 2, b: 4 }
|
||||||
case 'red':
|
case 'red':
|
||||||
return {r: 5, 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:
|
||||||
return {r: 5, g: 5, b: 5}
|
return { r: 5, g: 5, b: 5 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* colors the font of a string
|
* colors the font of a string
|
||||||
*/
|
*/
|
||||||
let coloredFont = (stringArg: string, colorArg: TColorName) => {
|
let coloredFont = (stringArg: string, colorArg: TColorName) => {
|
||||||
let rgbCode: IRGB = colorTranslator(colorArg)
|
let rgbCode: IRGB = colorTranslator(colorArg)
|
||||||
return ansiColors.fg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg
|
return ansiColors.fg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* colors the back of a string
|
* colors the back of a string
|
||||||
*/
|
*/
|
||||||
let coloredBackground = (stringArg: string, colorArg: TColorName) => {
|
let coloredBackground = (stringArg: string, colorArg: TColorName) => {
|
||||||
let rgbCode = colorTranslator(colorArg)
|
let rgbCode = colorTranslator(colorArg)
|
||||||
return ansiColors.bg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg
|
return ansiColors.bg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* color a string with xterm
|
* color a string with xterm
|
||||||
*/
|
*/
|
||||||
export let coloredString = (stringArg: string, colorFontArg: TColorName, colorBackgroundArg?: TColorName): string => {
|
export let coloredString = (stringArg: string, colorFontArg: TColorName, colorBackgroundArg?: TColorName): string => {
|
||||||
let returnString = coloredFont(stringArg, colorFontArg)
|
let returnString = coloredFont(stringArg, colorFontArg)
|
||||||
if (colorBackgroundArg) {
|
if (colorBackgroundArg) {
|
||||||
returnString = coloredBackground(returnString, colorBackgroundArg)
|
returnString = coloredBackground(returnString, colorBackgroundArg)
|
||||||
}
|
}
|
||||||
returnString = returnString + ansiColors.reset
|
returnString = returnString + ansiColors.reset
|
||||||
return returnString
|
return returnString
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user