UNPKG

5.03 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 /**
8 * `undefined` on windows, `✘` on other platforms.
9 */
10 ballotCross?: "✘";
11 ballotDisabled: "☒";
12 ballotOff: "☐";
13 ballotOn: "☑";
14 bullet: "•";
15 bulletWhite: "◦";
16 /**
17 * `√` on windows, `✔` on other platforms.
18 */
19 check: "√" | "✔";
20 /**
21 * `×` on windows, `✖` on other platforms.
22 */
23 cross: "×" | "✖";
24 /**
25 * `...` on windows, `⋯` on other platforms.
26 */
27 ellipsisLarge: "..." | "⋯";
28 /**
29 * `...` on windows, `…` on other platforms.
30 */
31 ellipsis: "..." | "…";
32 fullBlock: "█";
33 heart: "❤";
34 identicalTo: "≡";
35 info: "i" | "ℹ";
36 line: "─";
37 mark: "※";
38 middot: "·";
39 minus: "-";
40 multiplication: "×";
41 obelus: "÷";
42 pencilDownRight: "✎";
43 pencilRight: "✏";
44 pencilUpRight: "✐";
45 percent: "%";
46 pilcrow2: "❡";
47 pilcrow: "¶";
48 plusMinus: "±";
49 /**
50 * `>` on windows, `▸` on linux, and `❯` on other platforms.
51 */
52 pointer: ">" | "▸" | "❯";
53 /**
54 * `»` on windows, `‣` on linux, and `›` on other platforms.
55 */
56 pointerSmall: "»" | "‣" | "›";
57 question: "?";
58 /**
59 * `undefined` on windows, `?` on other platforms.
60 */
61 questionFull?: "?";
62 /**
63 * `?` on windows, `﹖` on other platforms.
64 */
65 questionSmall: "?" | "﹖";
66 /**
67 * `( )` on windows, `◯` on other platforms.
68 */
69 radioOff: "( )" | "◯";
70 /**
71 * `(*)` on windows, `◉` on other platforms.
72 */
73 radioOn: "(*)" | "◉";
74 section: "§";
75 starsOff: "☆";
76 starsOn: "★";
77 upDownArrow: "↕";
78 /**
79 * `‼` on windows, `⚠` on other platforms.
80 */
81 warning: "‼" | "⚠";
82}
83
84type StyleArrayStructure = [number, number];
85interface StyleArrayProperties {
86 open: string;
87 close: string;
88 closeRe: string;
89}
90
91type StyleType = StyleArrayStructure & StyleArrayProperties;
92
93
94interface StylesType<T> {
95 // modifiers
96 reset: T;
97 bold: T;
98 dim: T;
99 italic: T;
100 underline: T;
101 inverse: T;
102 hidden: T;
103 strikethrough: T;
104
105 // colors
106 black: T;
107 red: T;
108 green: T;
109 yellow: T;
110 blue: T;
111 magenta: T;
112 cyan: T;
113 white: T;
114 gray: T;
115 grey: T;
116
117 // bright colors
118 blackBright: T;
119 redBright: T;
120 greenBright: T;
121 yellowBright: T;
122 blueBright: T;
123 magentaBright: T;
124 cyanBright: T;
125 whiteBright: T;
126
127 // background colors
128 bgBlack: T;
129 bgRed: T;
130 bgGreen: T;
131 bgYellow: T;
132 bgBlue: T;
133 bgMagenta: T;
134 bgCyan: T;
135 bgWhite: T;
136
137 // bright background colors
138 bgBlackBright: T;
139 bgRedBright: T;
140 bgGreenBright: T;
141 bgYellowBright: T;
142 bgBlueBright: T;
143 bgMagentaBright: T;
144 bgCyanBright: T;
145 bgWhiteBright: T;
146}
147
148declare namespace ansiColors {
149 interface StyleFunction extends StylesType<StyleFunction> {
150 (s: string): string;
151 }
152
153 // modifiers
154 const reset: StyleFunction;
155 const bold: StyleFunction;
156 const dim: StyleFunction;
157 const italic: StyleFunction;
158 const underline: StyleFunction;
159 const inverse: StyleFunction;
160 const hidden: StyleFunction;
161 const strikethrough: StyleFunction;
162
163 // colors
164 const black: StyleFunction;
165 const red: StyleFunction;
166 const green: StyleFunction;
167 const yellow: StyleFunction;
168 const blue: StyleFunction;
169 const magenta: StyleFunction;
170 const cyan: StyleFunction;
171 const white: StyleFunction;
172 const gray: StyleFunction;
173 const grey: StyleFunction;
174
175 // bright colors
176 const blackBright: StyleFunction;
177 const redBright: StyleFunction;
178 const greenBright: StyleFunction;
179 const yellowBright: StyleFunction;
180 const blueBright: StyleFunction;
181 const magentaBright: StyleFunction;
182 const cyanBright: StyleFunction;
183 const whiteBright: StyleFunction;
184
185 // background colors
186 const bgBlack: StyleFunction;
187 const bgRed: StyleFunction;
188 const bgGreen: StyleFunction;
189 const bgYellow: StyleFunction;
190 const bgBlue: StyleFunction;
191 const bgMagenta: StyleFunction;
192 const bgCyan: StyleFunction;
193 const bgWhite: StyleFunction;
194
195 // bright background colors
196 const bgBlackBright: StyleFunction;
197 const bgRedBright: StyleFunction;
198 const bgGreenBright: StyleFunction;
199 const bgYellowBright: StyleFunction;
200 const bgBlueBright: StyleFunction;
201 const bgMagentaBright: StyleFunction;
202 const bgCyanBright: StyleFunction;
203 const bgWhiteBright: StyleFunction;
204
205 let enabled: boolean;
206 let visible: boolean;
207 const ansiRegex: RegExp;
208
209 /**
210 * Remove styles from string
211 */
212 function stripColor(s: string): string;
213
214 /**
215 * Remove styles from string
216 */
217 function strip(s: string): string;
218
219 /**
220 * Remove styles from string
221 */
222 function unstyle(s: string): string;
223
224 const styles: StylesType<StyleType>;
225 const symbols: SymbolsType;
226
227 /**
228 * Outputs a string with check-symbol as prefix
229 */
230 function ok(...args: string[]): string;
231
232 function create(): typeof ansiColors;
233}
234
235export = ansiColors;