UNPKG

3.68 kBTypeScriptView Raw
1// Imported from DefinitelyTyped project.
2// TypeScript definitions for ansi-colors
3// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
4// Integrated by: Jordan Mele <https://github.com/Silic0nS0ldier>
5
6interface SymbolsType {
7 check: string;
8 cross: string;
9 info: string;
10 line: string;
11 pointer: string;
12 pointerSmall: string;
13 question: string;
14 warning: string;
15}
16
17type StyleArrayStructure = [number, number];
18interface StyleArrayProperties {
19 open: string;
20 close: string;
21 closeRe: string;
22}
23
24type StyleType = StyleArrayStructure & StyleArrayProperties;
25
26export interface StyleFunction extends StylesType<StyleFunction> {
27 (s: string): string;
28}
29
30interface StylesType<T> {
31 // modifiers
32 reset: T;
33 bold: T;
34 dim: T;
35 italic: T;
36 underline: T;
37 inverse: T;
38 hidden: T;
39 strikethrough: T;
40
41 // colors
42 black: T;
43 red: T;
44 green: T;
45 yellow: T;
46 blue: T;
47 magenta: T;
48 cyan: T;
49 white: T;
50 gray: T;
51 grey: T;
52
53 // bright colors
54 blackBright: T;
55 redBright: T;
56 greenBright: T;
57 yellowBright: T;
58 blueBright: T;
59 magentaBright: T;
60 cyanBright: T;
61 whiteBright: T;
62
63 // background colors
64 bgBlack: T;
65 bgRed: T;
66 bgGreen: T;
67 bgYellow: T;
68 bgBlue: T;
69 bgMagenta: T;
70 bgCyan: T;
71 bgWhite: T;
72
73 // bright background colors
74 bgBlackBright: T;
75 bgRedBright: T;
76 bgGreenBright: T;
77 bgYellowBright: T;
78 bgBlueBright: T;
79 bgMagentaBright: T;
80 bgCyanBright: T;
81 bgWhiteBright: T;
82}
83
84// modifiers
85export const reset: StyleFunction;
86export const bold: StyleFunction;
87export const dim: StyleFunction;
88export const italic: StyleFunction;
89export const underline: StyleFunction;
90export const inverse: StyleFunction;
91export const hidden: StyleFunction;
92export const strikethrough: StyleFunction;
93
94// colors
95export const black: StyleFunction;
96export const red: StyleFunction;
97export const green: StyleFunction;
98export const yellow: StyleFunction;
99export const blue: StyleFunction;
100export const magenta: StyleFunction;
101export const cyan: StyleFunction;
102export const white: StyleFunction;
103export const gray: StyleFunction;
104export const grey: StyleFunction;
105
106// bright colors
107export const blackBright: StyleFunction;
108export const redBright: StyleFunction;
109export const greenBright: StyleFunction;
110export const yellowBright: StyleFunction;
111export const blueBright: StyleFunction;
112export const magentaBright: StyleFunction;
113export const cyanBright: StyleFunction;
114export const whiteBright: StyleFunction;
115
116// background colors
117export const bgBlack: StyleFunction;
118export const bgRed: StyleFunction;
119export const bgGreen: StyleFunction;
120export const bgYellow: StyleFunction;
121export const bgBlue: StyleFunction;
122export const bgMagenta: StyleFunction;
123export const bgCyan: StyleFunction;
124export const bgWhite: StyleFunction;
125
126// bright background colors
127export const bgBlackBright: StyleFunction;
128export const bgRedBright: StyleFunction;
129export const bgGreenBright: StyleFunction;
130export const bgYellowBright: StyleFunction;
131export const bgBlueBright: StyleFunction;
132export const bgMagentaBright: StyleFunction;
133export const bgCyanBright: StyleFunction;
134export const bgWhiteBright: StyleFunction;
135
136export let enabled: boolean;
137export let visible: boolean;
138export const ansiRegex: RegExp;
139
140/**
141 * Remove styles from string
142 */
143export function stripColor(s: string): string;
144
145/**
146 * Remove styles from string
147 */
148export function strip(s: string): string;
149
150/**
151 * Remove styles from string
152 */
153export function unstyle(s: string): string;
154
155export const styles: StylesType<StyleType>;
156export const symbols: SymbolsType;
157
158/**
159 * Outputs a string with check-symbol as prefix
160 */
161export function ok(...args: string[]): string;