console-toolkit 1.2.15 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/llms-full.txt +64 -4
- package/package.json +6 -6
- package/src/alphanumeric/arrows.js +0 -23
- package/src/alphanumeric/fractions.js +0 -49
- package/src/alphanumeric/number-formatters.js +0 -44
- package/src/alphanumeric/roman.js +0 -12
- package/src/alphanumeric/unicode-cultural-numbers.js +0 -1
- package/src/alphanumeric/unicode-letters.js +0 -8
- package/src/alphanumeric/unicode-numbers.js +0 -21
- package/src/alphanumeric/utils.js +0 -26
- package/src/ansi/csi.js +0 -49
- package/src/ansi/sgr-state.js +7 -50
- package/src/ansi/sgr.js +0 -420
- package/src/box.d.ts +4 -1
- package/src/box.js +15 -115
- package/src/charts/bars/block-frac-grouped.js +0 -6
- package/src/charts/bars/block-frac.js +1 -14
- package/src/charts/bars/block-grouped.js +0 -6
- package/src/charts/bars/block.js +1 -14
- package/src/charts/bars/draw-grouped.js +0 -4
- package/src/charts/bars/draw-stacked.js +0 -4
- package/src/charts/bars/frac-grouped.js +2 -14
- package/src/charts/bars/plain-grouped.js +0 -6
- package/src/charts/bars/plain.js +1 -28
- package/src/charts/columns/block-frac-grouped.js +0 -6
- package/src/charts/columns/block-frac.js +0 -13
- package/src/charts/columns/block-grouped.js +0 -6
- package/src/charts/columns/block.js +0 -13
- package/src/charts/columns/draw-grouped.js +1 -5
- package/src/charts/columns/draw-stacked.js +0 -4
- package/src/charts/columns/frac-grouped.js +1 -13
- package/src/charts/columns/plain-grouped.js +0 -6
- package/src/charts/columns/plain.js +0 -13
- package/src/charts/themes/default.js +0 -1
- package/src/charts/themes/rainbow-reversed.js +0 -1
- package/src/charts/themes/rainbow.js +0 -1
- package/src/charts/utils.js +2 -28
- package/src/draw-block-frac.js +0 -14
- package/src/draw-block.js +0 -24
- package/src/meta.js +0 -64
- package/src/output/show.d.ts +8 -3
- package/src/output/show.js +7 -38
- package/src/output/updater.d.ts +8 -3
- package/src/output/updater.js +4 -51
- package/src/output/writer.js +1 -53
- package/src/panel.d.ts +16 -10
- package/src/panel.js +21 -276
- package/src/plot/bitmap.js +5 -33
- package/src/plot/draw-line.js +0 -8
- package/src/plot/draw-rect.js +25 -103
- package/src/plot/index.js +0 -22
- package/src/plot/to-quads.js +3 -6
- package/src/spinner/spin.js +23 -20
- package/src/spinner/spinner.d.ts +16 -2
- package/src/spinner/spinner.js +22 -34
- package/src/spinner/spinners.js +0 -16
- package/src/strings/clip.js +0 -10
- package/src/strings/parse.js +0 -7
- package/src/strings/split.js +0 -15
- package/src/strings.d.ts +2 -0
- package/src/strings.js +2 -32
- package/src/style.js +2 -58
- package/src/symbols.js +0 -84
- package/src/table/draw-borders.js +0 -9
- package/src/table/index.d.ts +1 -1
- package/src/table/index.js +0 -1
- package/src/table/table.js +3 -58
- package/src/themes/blocks/unicode-half.js +0 -1
- package/src/themes/blocks/unicode-thin.js +0 -1
- package/src/themes/lines/ascii-compact.js +5 -9
- package/src/themes/lines/ascii-dots.js +2 -7
- package/src/themes/lines/ascii-girder.js +4 -7
- package/src/themes/lines/ascii-github.js +5 -9
- package/src/themes/lines/ascii-reddit.js +5 -9
- package/src/themes/lines/ascii-rounded.js +5 -9
- package/src/themes/lines/ascii.js +5 -9
- package/src/themes/lines/unicode-bold.js +8 -14
- package/src/themes/lines/unicode-rounded.js +8 -14
- package/src/themes/lines/unicode.js +8 -14
- package/src/themes/utils.d.ts +6 -0
- package/src/themes/utils.js +6 -7
- package/src/turtle/draw-line-art.js +26 -18
- package/src/turtle/draw-unicode.js +0 -8
- package/src/turtle/index.d.ts +1 -1
- package/src/turtle/index.js +0 -8
- package/src/turtle/turtle.js +0 -120
package/src/ansi/sgr.js
CHANGED
|
@@ -5,17 +5,10 @@
|
|
|
5
5
|
// See https://en.wikipedia.org/wiki/ANSI_escape_code for more details.
|
|
6
6
|
|
|
7
7
|
// matcher
|
|
8
|
-
/** RegExp matching SGR (Select Graphics Rendition) escape sequences.
|
|
9
|
-
* @type {RegExp}
|
|
10
|
-
*/
|
|
11
8
|
export const matchSgr = /\x1B\[([\x30-\x3F]*)([\x20-\x2F]*)m/g;
|
|
12
9
|
|
|
13
|
-
/** Standard color name-to-number mapping.
|
|
14
|
-
* @type {{BLACK: 0, RED: 1, GREEN: 2, YELLOW: 3, BLUE: 4, MAGENTA: 5, CYAN: 6, WHITE: 7, DEFAULT: 9}}
|
|
15
|
-
*/
|
|
16
10
|
export const Colors = {BLACK: 0, RED: 1, GREEN: 2, YELLOW: 3, BLUE: 4, MAGENTA: 5, CYAN: 6, WHITE: 7, DEFAULT: 9};
|
|
17
11
|
|
|
18
|
-
/** SGR command code constants (e.g., BOLD='1', UNDERLINE='4'). */
|
|
19
12
|
export const Commands = {
|
|
20
13
|
RESET_ALL: '0',
|
|
21
14
|
BOLD: '1',
|
|
@@ -56,36 +49,21 @@ export const Commands = {
|
|
|
56
49
|
RESET_DECORATION_COLOR: '59'
|
|
57
50
|
};
|
|
58
51
|
|
|
59
|
-
/** Color format identifiers for extended colors.
|
|
60
|
-
* @type {{COLOR_256: string, TRUE_COLOR: string}}
|
|
61
|
-
*/
|
|
62
52
|
export const ColorFormat = {COLOR_256: '5', TRUE_COLOR: '2'};
|
|
63
|
-
/** Maps color format identifiers to their parameter count.
|
|
64
|
-
* @type {Record<string, number>}
|
|
65
|
-
*/
|
|
66
53
|
export const ColorFormatSize = {[ColorFormat.COLOR_256]: 3, [ColorFormat.TRUE_COLOR]: 5};
|
|
67
54
|
|
|
68
|
-
/** Foreground color configuration.
|
|
69
|
-
* @type {import('./sgr.js').ColorOptions}
|
|
70
|
-
*/
|
|
71
55
|
export const FgColorOptions = {
|
|
72
56
|
base: 30,
|
|
73
57
|
brightBase: 90,
|
|
74
58
|
default: Commands.DEFAULT_COLOR,
|
|
75
59
|
extended: Commands.EXTENDED_COLOR
|
|
76
60
|
};
|
|
77
|
-
/** Background color configuration.
|
|
78
|
-
* @type {import('./sgr.js').ColorOptions}
|
|
79
|
-
*/
|
|
80
61
|
export const BgColorOptions = {
|
|
81
62
|
base: 40,
|
|
82
63
|
brightBase: 100,
|
|
83
64
|
default: Commands.BG_DEFAULT_COLOR,
|
|
84
65
|
extended: Commands.BG_EXTENDED_COLOR
|
|
85
66
|
};
|
|
86
|
-
/** Decoration (underline) color configuration.
|
|
87
|
-
* @type {import('./sgr.js').ColorOptions}
|
|
88
|
-
*/
|
|
89
67
|
export const DecorationColorOptions = {
|
|
90
68
|
base: 0,
|
|
91
69
|
brightBase: 100,
|
|
@@ -101,27 +79,11 @@ for (const [k, v] of Object.entries(Commands)) {
|
|
|
101
79
|
resetCommands[Commands[cmd]] = v;
|
|
102
80
|
}
|
|
103
81
|
|
|
104
|
-
/** Checks if a command is a foreground color command.
|
|
105
|
-
* @param {string} command
|
|
106
|
-
* @returns {boolean}
|
|
107
|
-
*/
|
|
108
82
|
export const isFgColorCommand = command => (command >= '30' && command <= '37') || (command >= '90' && command <= '97');
|
|
109
|
-
/** Checks if a command is a background color command.
|
|
110
|
-
* @param {string} command
|
|
111
|
-
* @returns {boolean}
|
|
112
|
-
*/
|
|
113
83
|
export const isBgColorCommand = command =>
|
|
114
84
|
(command >= '40' && command <= '47') || (command >= '100' && command <= '107');
|
|
115
|
-
/** Checks if a command is a font command.
|
|
116
|
-
* @param {string} command
|
|
117
|
-
* @returns {boolean}
|
|
118
|
-
*/
|
|
119
85
|
export const isFontCommand = command => command >= '10' && command <= '20';
|
|
120
86
|
|
|
121
|
-
/** Returns the reset command for a given SGR command.
|
|
122
|
-
* @param {string} command - The SGR command string or name.
|
|
123
|
-
* @returns {string|undefined} The reset command, or undefined if not found.
|
|
124
|
-
*/
|
|
125
87
|
export const reset = command => {
|
|
126
88
|
command = String(command).toUpperCase();
|
|
127
89
|
if (Commands.hasOwnProperty(command)) {
|
|
@@ -134,16 +96,8 @@ export const reset = command => {
|
|
|
134
96
|
// return undefined in all other cases
|
|
135
97
|
};
|
|
136
98
|
|
|
137
|
-
/** Creates an SGR escape sequence from one or more commands.
|
|
138
|
-
* @param {string|string[]|number[]} commands - Command(s) to encode.
|
|
139
|
-
* @returns {string} The SGR escape sequence.
|
|
140
|
-
*/
|
|
141
99
|
export const setCommands = commands => `\x1B[${Array.isArray(commands) ? commands.join(';') : commands}m`;
|
|
142
100
|
|
|
143
|
-
/** Converts a color name or number to a standard color number (0-9).
|
|
144
|
-
* @param {string|number} color - Color name or number.
|
|
145
|
-
* @returns {number} The color number.
|
|
146
|
-
*/
|
|
147
101
|
export const colorNumber = color => {
|
|
148
102
|
if (typeof color == 'string') {
|
|
149
103
|
if (/^\d+$/.test(color)) {
|
|
@@ -155,127 +109,29 @@ export const colorNumber = color => {
|
|
|
155
109
|
}
|
|
156
110
|
return typeof color == 'number' && color >= 0 && color <= 9 ? color : 0;
|
|
157
111
|
};
|
|
158
|
-
/** Converts RGB values to a standard color number.
|
|
159
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
160
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
161
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
162
|
-
* @returns {number} a color number from 0 to 7
|
|
163
|
-
*/
|
|
164
112
|
export const colorStdRgb = (r, g, b) => (r ? 1 : 0) + (g ? 2 : 0) + (b ? 4 : 0);
|
|
165
113
|
|
|
166
|
-
/** Returns the foreground color SGR code.
|
|
167
|
-
* @param {string|number} color - Color name or number.
|
|
168
|
-
* @returns {number}
|
|
169
|
-
*/
|
|
170
114
|
export const getColor = color => 30 + colorNumber(color);
|
|
171
|
-
/** Returns the background color SGR code.
|
|
172
|
-
* @param {string|number} color - Color name or number.
|
|
173
|
-
* @returns {number}
|
|
174
|
-
*/
|
|
175
115
|
export const getBgColor = color => 40 + colorNumber(color);
|
|
176
|
-
/** Returns the bright foreground color SGR code.
|
|
177
|
-
* @param {string|number} color - Color name or number.
|
|
178
|
-
* @returns {number}
|
|
179
|
-
*/
|
|
180
116
|
export const getBrightColor = color => 90 + colorNumber(color);
|
|
181
|
-
/** Returns the bright background color SGR code.
|
|
182
|
-
* @param {string|number} color - Color name or number.
|
|
183
|
-
* @returns {number}
|
|
184
|
-
*/
|
|
185
117
|
export const getBgBrightColor = color => 100 + colorNumber(color);
|
|
186
|
-
/** Returns the foreground standard RGB color SGR code.
|
|
187
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
188
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
189
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
190
|
-
* @returns {number}
|
|
191
|
-
*/
|
|
192
118
|
export const getStdRgb = (r, g, b) => getColor(colorStdRgb(r, g, b));
|
|
193
|
-
/** Returns the background standard RGB color SGR code.
|
|
194
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
195
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
196
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
197
|
-
* @returns {number}
|
|
198
|
-
*/
|
|
199
119
|
export const getBgStdRgb = (r, g, b) => getBgColor(colorStdRgb(r, g, b));
|
|
200
|
-
/** Returns the bright foreground standard RGB color SGR code.
|
|
201
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
202
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
203
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
204
|
-
* @returns {number}
|
|
205
|
-
*/
|
|
206
120
|
export const getBrightStdRgb = (r, g, b) => getBrightColor(colorStdRgb(r, g, b));
|
|
207
|
-
/** Returns the bright background standard RGB color SGR code.
|
|
208
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
209
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
210
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
211
|
-
* @returns {number}
|
|
212
|
-
*/
|
|
213
121
|
export const getBgBrightStdRgb = (r, g, b) => getBgBrightColor(colorStdRgb(r, g, b));
|
|
214
122
|
|
|
215
|
-
/** Sets the foreground color.
|
|
216
|
-
* @param {string|number} color - Color name or number.
|
|
217
|
-
* @returns {string} SGR escape sequence.
|
|
218
|
-
*/
|
|
219
123
|
export const setColor = color => setCommands(getColor(color));
|
|
220
|
-
/** Sets the background color.
|
|
221
|
-
* @param {string|number} color - Color name or number.
|
|
222
|
-
* @returns {string} SGR escape sequence.
|
|
223
|
-
*/
|
|
224
124
|
export const setBgColor = color => setCommands(getBgColor(color));
|
|
225
|
-
/** Sets the bright foreground color.
|
|
226
|
-
* @param {string|number} color - Color name or number.
|
|
227
|
-
* @returns {string} SGR escape sequence.
|
|
228
|
-
*/
|
|
229
125
|
export const setBrightColor = color => setCommands(getBrightColor(color));
|
|
230
|
-
/** Sets the bright background color.
|
|
231
|
-
* @param {string|number} color - Color name or number.
|
|
232
|
-
* @returns {string} SGR escape sequence.
|
|
233
|
-
*/
|
|
234
126
|
export const setBgBrightColor = color => setCommands(getBgBrightColor(color));
|
|
235
|
-
/** Sets the foreground standard RGB color.
|
|
236
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
237
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
238
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
239
|
-
* @returns {string} SGR escape sequence.
|
|
240
|
-
*/
|
|
241
127
|
export const setStdRgb = (r, g, b) => setCommands(getStdRgb(r, g, b));
|
|
242
|
-
/** Sets the background standard RGB color.
|
|
243
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
244
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
245
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
246
|
-
* @returns {string} SGR escape sequence.
|
|
247
|
-
*/
|
|
248
128
|
export const setBgStdRgb = (r, g, b) => setCommands(getBgStdRgb(r, g, b));
|
|
249
|
-
/** Sets the bright foreground standard RGB color.
|
|
250
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
251
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
252
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
253
|
-
* @returns {string} SGR escape sequence.
|
|
254
|
-
*/
|
|
255
129
|
export const setBrightStdRgb = (r, g, b) => setCommands(getBrightStdRgb(r, g, b));
|
|
256
|
-
/** Sets the bright background standard RGB color.
|
|
257
|
-
* @param {number|boolean} r - Red component (truthy/falsy).
|
|
258
|
-
* @param {number|boolean} g - Green component (truthy/falsy).
|
|
259
|
-
* @param {number|boolean} b - Blue component (truthy/falsy).
|
|
260
|
-
* @returns {string} SGR escape sequence.
|
|
261
|
-
*/
|
|
262
130
|
export const setBgBrightStdRgb = (r, g, b) => setCommands(getBgBrightStdRgb(r, g, b));
|
|
263
131
|
|
|
264
|
-
/** Converts a font number to a valid font index.
|
|
265
|
-
* @param {number} font - Font number.
|
|
266
|
-
* @returns {number} The font index.
|
|
267
|
-
*/
|
|
268
132
|
export const fontNumber = font => (typeof font == 'number' && font >= 0 && font <= 10 ? font : 0);
|
|
269
133
|
|
|
270
|
-
/** Returns the SGR code for a font.
|
|
271
|
-
* @param {number} font - Font number.
|
|
272
|
-
* @returns {number}
|
|
273
|
-
*/
|
|
274
134
|
export const getFont = font => 10 + fontNumber(font);
|
|
275
|
-
/** Sets the font.
|
|
276
|
-
* @param {number} font - Font number.
|
|
277
|
-
* @returns {string} SGR escape sequence.
|
|
278
|
-
*/
|
|
279
135
|
export const setFont = font => setCommands(getFont(font));
|
|
280
136
|
|
|
281
137
|
const oneSixth = 6.0 / 256;
|
|
@@ -286,349 +142,73 @@ const lim = (from, to) => value => Math.max(from, Math.min(to, value)); // inclu
|
|
|
286
142
|
const lim5 = lim(0, 5);
|
|
287
143
|
const lim23 = lim(0, 23);
|
|
288
144
|
|
|
289
|
-
/** Returns foreground 256-color command array for a raw palette index.
|
|
290
|
-
* @param {number} color - Palette index (0-255).
|
|
291
|
-
* @returns {string[]}
|
|
292
|
-
*/
|
|
293
145
|
export const getRawColor256 = color => [Commands.EXTENDED_COLOR, ColorFormat.COLOR_256, color];
|
|
294
|
-
/** Returns foreground 256-color command array for a standard color.
|
|
295
|
-
* @param {string|number} color - Color name or number.
|
|
296
|
-
* @returns {string[]}
|
|
297
|
-
*/
|
|
298
146
|
export const getStdColor256 = color => getRawColor256(colorNumber(color));
|
|
299
|
-
/** Returns foreground 256-color command array for a bright standard color.
|
|
300
|
-
* @param {string|number} color - Color name or number.
|
|
301
|
-
* @returns {string[]}
|
|
302
|
-
*/
|
|
303
147
|
export const getBrightStdColor256 = color => getRawColor256(8 + colorNumber(color));
|
|
304
|
-
/** Returns foreground 256-color command array for a 6x6x6 RGB color.
|
|
305
|
-
* @param {number} r - Red component (0-5).
|
|
306
|
-
* @param {number} g - Green component (0-5).
|
|
307
|
-
* @param {number} b - Blue component (0-5).
|
|
308
|
-
* @returns {string[]}
|
|
309
|
-
*/
|
|
310
148
|
export const getColor6 = (r, g, b) => getRawColor256(16 + 36 * lim5(r) + 6 * lim5(g) + lim5(b));
|
|
311
|
-
/** Returns foreground 256-color command array for an RGB color.
|
|
312
|
-
* @param {number} r - Red (0-255).
|
|
313
|
-
* @param {number} g - Green (0-255).
|
|
314
|
-
* @param {number} b - Blue (0-255).
|
|
315
|
-
* @returns {string[]}
|
|
316
|
-
*/
|
|
317
149
|
export const getColor256 = (r, g, b) => getColor6(get6(r), get6(g), get6(b));
|
|
318
|
-
/** Returns foreground 256-color command array for a hex color.
|
|
319
|
-
* @param {number} hex - Hex color value (e.g., 0xFF0000).
|
|
320
|
-
* @returns {string[]}
|
|
321
|
-
*/
|
|
322
150
|
export const getHexColor256 = hex => getColor256((hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff);
|
|
323
|
-
/** Returns foreground 256-color command array for a 24-shade gray.
|
|
324
|
-
* @param {number} i - Gray index (0-23).
|
|
325
|
-
* @returns {string[]}
|
|
326
|
-
*/
|
|
327
151
|
export const getGrayColor24 = i => getRawColor256(232 + lim23(i));
|
|
328
|
-
/** Returns foreground 256-color command array for a gray by intensity.
|
|
329
|
-
* @param {number} i - Gray intensity (0-255).
|
|
330
|
-
* @returns {string[]}
|
|
331
|
-
*/
|
|
332
152
|
export const getGrayColor256 = i => getGrayColor24(get24(i));
|
|
333
153
|
|
|
334
|
-
/** Sets foreground 256-color by raw palette index.
|
|
335
|
-
* @param {number} color - Palette index (0-255).
|
|
336
|
-
* @returns {string} SGR escape sequence.
|
|
337
|
-
*/
|
|
338
154
|
export const setRawColor256 = color => setCommands(getRawColor256(color));
|
|
339
|
-
/** Sets foreground 256-color by standard color.
|
|
340
|
-
* @param {string|number} color - Color name or number.
|
|
341
|
-
* @returns {string} SGR escape sequence.
|
|
342
|
-
*/
|
|
343
155
|
export const setStdColor256 = color => setCommands(getStdColor256(color));
|
|
344
|
-
/** Sets foreground 256-color by bright standard color.
|
|
345
|
-
* @param {string|number} color - Color name or number.
|
|
346
|
-
* @returns {string} SGR escape sequence.
|
|
347
|
-
*/
|
|
348
156
|
export const setBrightStdColor256 = color => setCommands(getBrightStdColor256(color));
|
|
349
|
-
/** Sets foreground 256-color by 6x6x6 RGB.
|
|
350
|
-
* @param {number} r - Red (0-5).
|
|
351
|
-
* @param {number} g - Green (0-5).
|
|
352
|
-
* @param {number} b - Blue (0-5).
|
|
353
|
-
* @returns {string} SGR escape sequence.
|
|
354
|
-
*/
|
|
355
157
|
export const setColor6 = (r, g, b) => setCommands(getColor6(r, g, b));
|
|
356
|
-
/** Sets foreground 256-color by RGB.
|
|
357
|
-
* @param {number} r - Red (0-255).
|
|
358
|
-
* @param {number} g - Green (0-255).
|
|
359
|
-
* @param {number} b - Blue (0-255).
|
|
360
|
-
* @returns {string} SGR escape sequence.
|
|
361
|
-
*/
|
|
362
158
|
export const setColor256 = (r, g, b) => setCommands(getColor256(r, g, b));
|
|
363
|
-
/** Sets foreground 256-color by hex.
|
|
364
|
-
* @param {number} hex - Hex color value.
|
|
365
|
-
* @returns {string} SGR escape sequence.
|
|
366
|
-
*/
|
|
367
159
|
export const setHexColor256 = hex => setCommands(getHexColor256(hex));
|
|
368
|
-
/** Sets foreground 256-color gray by index.
|
|
369
|
-
* @param {number} i - Gray index (0-23).
|
|
370
|
-
* @returns {string} SGR escape sequence.
|
|
371
|
-
*/
|
|
372
160
|
export const setGrayColor24 = i => setCommands(getGrayColor24(i));
|
|
373
|
-
/** Sets foreground 256-color gray by intensity.
|
|
374
|
-
* @param {number} i - Gray intensity (0-255).
|
|
375
|
-
* @returns {string} SGR escape sequence.
|
|
376
|
-
*/
|
|
377
161
|
export const setGrayColor256 = i => setCommands(getGrayColor256(i));
|
|
378
162
|
|
|
379
|
-
/** Returns background 256-color command array for a raw palette index.
|
|
380
|
-
* @param {number} color - Palette index (0-255).
|
|
381
|
-
* @returns {string[]}
|
|
382
|
-
*/
|
|
383
163
|
export const getBgRawColor256 = color => [Commands.BG_EXTENDED_COLOR, ColorFormat.COLOR_256, color];
|
|
384
|
-
/** Returns background 256-color command array for a standard color.
|
|
385
|
-
* @param {string|number} color - Color name or number.
|
|
386
|
-
* @returns {string[]}
|
|
387
|
-
*/
|
|
388
164
|
export const getBgStdColor256 = color => getBgRawColor256(colorNumber(color));
|
|
389
|
-
/** Returns background 256-color command array for a bright standard color.
|
|
390
|
-
* @param {string|number} color - Color name or number.
|
|
391
|
-
* @returns {string[]}
|
|
392
|
-
*/
|
|
393
165
|
export const getBgBrightStdColor256 = color => getBgStdColor256(8 + colorNumber(color));
|
|
394
|
-
/** Returns background 256-color command array for a 6x6x6 RGB color.
|
|
395
|
-
* @param {number} r - Red (0-5).
|
|
396
|
-
* @param {number} g - Green (0-5).
|
|
397
|
-
* @param {number} b - Blue (0-5).
|
|
398
|
-
* @returns {string[]}
|
|
399
|
-
*/
|
|
400
166
|
export const getBgColor6 = (r, g, b) => getBgRawColor256(16 + 36 * lim5(r) + 6 * lim5(g) + lim5(b));
|
|
401
|
-
/** Returns background 256-color command array for an RGB color.
|
|
402
|
-
* @param {number} r - Red (0-255).
|
|
403
|
-
* @param {number} g - Green (0-255).
|
|
404
|
-
* @param {number} b - Blue (0-255).
|
|
405
|
-
* @returns {string[]}
|
|
406
|
-
*/
|
|
407
167
|
export const getBgColor256 = (r, g, b) => getBgColor6(get6(r), get6(g), get6(b));
|
|
408
|
-
/** Returns background 256-color command array for a hex color.
|
|
409
|
-
* @param {number} hex - Hex color value.
|
|
410
|
-
* @returns {string[]}
|
|
411
|
-
*/
|
|
412
168
|
export const getBgHexColor256 = hex => getBgColor256((hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff);
|
|
413
|
-
/** Returns background 256-color command array for a 24-shade gray.
|
|
414
|
-
* @param {number} i - Gray index (0-23).
|
|
415
|
-
* @returns {string[]}
|
|
416
|
-
*/
|
|
417
169
|
export const getBgGrayColor24 = i => getBgRawColor256(232 + lim23(i));
|
|
418
|
-
/** Returns background 256-color command array for a gray by intensity.
|
|
419
|
-
* @param {number} i - Gray intensity (0-255).
|
|
420
|
-
* @returns {string[]}
|
|
421
|
-
*/
|
|
422
170
|
export const getBgGrayColor256 = i => getBgGrayColor24(get24(i));
|
|
423
171
|
|
|
424
|
-
/** Sets background 256-color by raw palette index.
|
|
425
|
-
* @param {number} color - Palette index (0-255).
|
|
426
|
-
* @returns {string} SGR escape sequence.
|
|
427
|
-
*/
|
|
428
172
|
export const setBgRawColor256 = color => setCommands(getBgRawColor256(color));
|
|
429
|
-
/** Sets background 256-color by standard color.
|
|
430
|
-
* @param {string|number} color - Color name or number.
|
|
431
|
-
* @returns {string} SGR escape sequence.
|
|
432
|
-
*/
|
|
433
173
|
export const setBgStdColor256 = color => setCommands(getBgStdColor256(color));
|
|
434
|
-
/** Sets background 256-color by bright standard color.
|
|
435
|
-
* @param {string|number} color - Color name or number.
|
|
436
|
-
* @returns {string} SGR escape sequence.
|
|
437
|
-
*/
|
|
438
174
|
export const setBgBrightStdColor256 = color => setCommands(getBgBrightStdColor256(color));
|
|
439
|
-
/** Sets background 256-color by 6x6x6 RGB.
|
|
440
|
-
* @param {number} r - Red (0-5).
|
|
441
|
-
* @param {number} g - Green (0-5).
|
|
442
|
-
* @param {number} b - Blue (0-5).
|
|
443
|
-
* @returns {string} SGR escape sequence.
|
|
444
|
-
*/
|
|
445
175
|
export const setBgColor6 = (r, g, b) => setCommands(getBgColor6(r, g, b));
|
|
446
|
-
/** Sets background 256-color by RGB.
|
|
447
|
-
* @param {number} r - Red (0-255).
|
|
448
|
-
* @param {number} g - Green (0-255).
|
|
449
|
-
* @param {number} b - Blue (0-255).
|
|
450
|
-
* @returns {string} SGR escape sequence.
|
|
451
|
-
*/
|
|
452
176
|
export const setBgColor256 = (r, g, b) => setCommands(getBgColor256(r, g, b));
|
|
453
|
-
/** Sets background 256-color by hex.
|
|
454
|
-
* @param {number} hex - Hex color value.
|
|
455
|
-
* @returns {string} SGR escape sequence.
|
|
456
|
-
*/
|
|
457
177
|
export const setBgHexColor256 = hex => setCommands(getBgHexColor256(hex));
|
|
458
|
-
/** Sets background 256-color gray by index.
|
|
459
|
-
* @param {number} i - Gray index (0-23).
|
|
460
|
-
* @returns {string} SGR escape sequence.
|
|
461
|
-
*/
|
|
462
178
|
export const setBgGrayColor24 = i => setCommands(getBgGrayColor24(i));
|
|
463
|
-
/** Sets background 256-color gray by intensity.
|
|
464
|
-
* @param {number} i - Gray intensity (0-255).
|
|
465
|
-
* @returns {string} SGR escape sequence.
|
|
466
|
-
*/
|
|
467
179
|
export const setBgGrayColor256 = i => setCommands(getBgGrayColor256(i));
|
|
468
180
|
|
|
469
|
-
/** Returns the foreground true color (24-bit) SGR command array.
|
|
470
|
-
* @param {number} r - Red (0-255).
|
|
471
|
-
* @param {number} g - Green (0-255).
|
|
472
|
-
* @param {number} b - Blue (0-255).
|
|
473
|
-
* @returns {string[]}
|
|
474
|
-
*/
|
|
475
181
|
export const getTrueColor = (r, g, b) => [Commands.EXTENDED_COLOR, ColorFormat.TRUE_COLOR, r, g, b];
|
|
476
|
-
/** Returns the foreground true color command array from hex.
|
|
477
|
-
* @param {number} hex - Hex color value.
|
|
478
|
-
* @returns {string[]}
|
|
479
|
-
*/
|
|
480
182
|
export const getHexTrueColor = hex => getTrueColor((hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff);
|
|
481
|
-
/** Returns the background true color (24-bit) SGR command array.
|
|
482
|
-
* @param {number} r - Red (0-255).
|
|
483
|
-
* @param {number} g - Green (0-255).
|
|
484
|
-
* @param {number} b - Blue (0-255).
|
|
485
|
-
* @returns {string[]}
|
|
486
|
-
*/
|
|
487
183
|
export const getBgTrueColor = (r, g, b) => [Commands.BG_EXTENDED_COLOR, ColorFormat.TRUE_COLOR, r, g, b];
|
|
488
|
-
/** Returns the background true color command array from hex.
|
|
489
|
-
* @param {number} hex - Hex color value.
|
|
490
|
-
* @returns {string[]}
|
|
491
|
-
*/
|
|
492
184
|
export const getBgHexTrueColor = hex => getBgTrueColor((hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff);
|
|
493
185
|
|
|
494
|
-
/** Sets foreground true color.
|
|
495
|
-
* @param {number} r - Red (0-255).
|
|
496
|
-
* @param {number} g - Green (0-255).
|
|
497
|
-
* @param {number} b - Blue (0-255).
|
|
498
|
-
* @returns {string} SGR escape sequence.
|
|
499
|
-
*/
|
|
500
186
|
export const setTrueColor = (r, g, b) => setCommands(getTrueColor(r, g, b));
|
|
501
|
-
/** Sets foreground true color from hex.
|
|
502
|
-
* @param {number} hex - Hex color value.
|
|
503
|
-
* @returns {string} SGR escape sequence.
|
|
504
|
-
*/
|
|
505
187
|
export const setHexTrueColor = hex => setCommands(getHexTrueColor(hex));
|
|
506
|
-
/** Sets background true color.
|
|
507
|
-
* @param {number} r - Red (0-255).
|
|
508
|
-
* @param {number} g - Green (0-255).
|
|
509
|
-
* @param {number} b - Blue (0-255).
|
|
510
|
-
* @returns {string} SGR escape sequence.
|
|
511
|
-
*/
|
|
512
188
|
export const setBgTrueColor = (r, g, b) => setCommands(getBgTrueColor(r, g, b));
|
|
513
|
-
/** Sets background true color from hex.
|
|
514
|
-
* @param {number} hex - Hex color value.
|
|
515
|
-
* @returns {string} SGR escape sequence.
|
|
516
|
-
*/
|
|
517
189
|
export const setBgHexTrueColor = hex => setCommands(getBgHexTrueColor(hex));
|
|
518
190
|
|
|
519
|
-
/** Returns decoration 256-color command array for a raw palette index.
|
|
520
|
-
* @param {number} color - Palette index (0-255).
|
|
521
|
-
* @returns {string[]}
|
|
522
|
-
*/
|
|
523
191
|
export const getDecorationRawColor256 = color => [Commands.DECORATION_COLOR, ColorFormat.COLOR_256, color];
|
|
524
|
-
/** Returns decoration 256-color command array for a standard color.
|
|
525
|
-
* @param {string|number} color - Color name or number.
|
|
526
|
-
* @returns {string[]}
|
|
527
|
-
*/
|
|
528
192
|
export const getDecorationStdColor256 = color => getDecorationRawColor256(colorNumber(color));
|
|
529
|
-
/** Returns decoration 256-color command array for a bright standard color.
|
|
530
|
-
* @param {string|number} color - Color name or number.
|
|
531
|
-
* @returns {string[]}
|
|
532
|
-
*/
|
|
533
193
|
export const getDecorationBrightStdColor256 = color => getDecorationRawColor256(8 + colorNumber(color));
|
|
534
|
-
/** Returns decoration 256-color command array for a 6x6x6 RGB color.
|
|
535
|
-
* @param {number} r - Red (0-5).
|
|
536
|
-
* @param {number} g - Green (0-5).
|
|
537
|
-
* @param {number} b - Blue (0-5).
|
|
538
|
-
* @returns {string[]}
|
|
539
|
-
*/
|
|
540
194
|
export const getDecorationColor6 = (r, g, b) => getDecorationRawColor256(16 + 36 * lim5(r) + 6 * lim5(g) + lim5(b));
|
|
541
|
-
/** Returns decoration 256-color command array for an RGB color.
|
|
542
|
-
* @param {number} r - Red (0-255).
|
|
543
|
-
* @param {number} g - Green (0-255).
|
|
544
|
-
* @param {number} b - Blue (0-255).
|
|
545
|
-
* @returns {string[]}
|
|
546
|
-
*/
|
|
547
195
|
export const getDecorationColor256 = (r, g, b) => getDecorationColor6(get6(r), get6(g), get6(b));
|
|
548
|
-
/** Returns decoration 256-color command array for a hex color.
|
|
549
|
-
* @param {number} hex - Hex color value.
|
|
550
|
-
* @returns {string[]}
|
|
551
|
-
*/
|
|
552
196
|
export const getDecorationHexColor256 = hex => getDecorationColor256((hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff);
|
|
553
|
-
/** Returns decoration 256-color command array for a 24-shade gray.
|
|
554
|
-
* @param {number} i - Gray index (0-23).
|
|
555
|
-
* @returns {string[]}
|
|
556
|
-
*/
|
|
557
197
|
export const getDecorationGrayColor24 = i => getDecorationRawColor256(232 + lim23(i));
|
|
558
|
-
/** Returns decoration 256-color command array for a gray by intensity.
|
|
559
|
-
* @param {number} i - Gray intensity (0-255).
|
|
560
|
-
* @returns {string[]}
|
|
561
|
-
*/
|
|
562
198
|
export const getDecorationGrayColor256 = i => getDecorationGrayColor24(get24(i));
|
|
563
199
|
|
|
564
|
-
/** Sets decoration 256-color by raw palette index.
|
|
565
|
-
* @param {number} color - Palette index (0-255).
|
|
566
|
-
* @returns {string} SGR escape sequence.
|
|
567
|
-
*/
|
|
568
200
|
export const setDecorationRawColor256 = color => setCommands(getDecorationRawColor256(color));
|
|
569
|
-
/** Sets decoration 256-color by standard color.
|
|
570
|
-
* @param {string|number} color - Color name or number.
|
|
571
|
-
* @returns {string} SGR escape sequence.
|
|
572
|
-
*/
|
|
573
201
|
export const setDecorationStdColor256 = color => setCommands(getDecorationStdColor256(color));
|
|
574
|
-
/** Sets decoration 256-color by bright standard color.
|
|
575
|
-
* @param {string|number} color - Color name or number.
|
|
576
|
-
* @returns {string} SGR escape sequence.
|
|
577
|
-
*/
|
|
578
202
|
export const setDecorationBrightStdColor256 = color => setCommands(getDecorationBrightStdColor256(color));
|
|
579
|
-
/** Sets decoration 256-color by 6x6x6 RGB.
|
|
580
|
-
* @param {number} r - Red (0-5).
|
|
581
|
-
* @param {number} g - Green (0-5).
|
|
582
|
-
* @param {number} b - Blue (0-5).
|
|
583
|
-
* @returns {string} SGR escape sequence.
|
|
584
|
-
*/
|
|
585
203
|
export const setDecorationColor6 = (r, g, b) => setCommands(getDecorationColor6(r, g, b));
|
|
586
|
-
/** Sets decoration 256-color by RGB.
|
|
587
|
-
* @param {number} r - Red (0-255).
|
|
588
|
-
* @param {number} g - Green (0-255).
|
|
589
|
-
* @param {number} b - Blue (0-255).
|
|
590
|
-
* @returns {string} SGR escape sequence.
|
|
591
|
-
*/
|
|
592
204
|
export const setDecorationColor256 = (r, g, b) => setCommands(getDecorationColor256(r, g, b));
|
|
593
|
-
/** Sets decoration 256-color by hex.
|
|
594
|
-
* @param {number} hex - Hex color value.
|
|
595
|
-
* @returns {string} SGR escape sequence.
|
|
596
|
-
*/
|
|
597
205
|
export const setDecorationHexColor256 = hex => setCommands(getDecorationHexColor256(hex));
|
|
598
|
-
/** Sets decoration 256-color gray by index.
|
|
599
|
-
* @param {number} i - Gray index (0-23).
|
|
600
|
-
* @returns {string} SGR escape sequence.
|
|
601
|
-
*/
|
|
602
206
|
export const setDecorationGrayColor24 = i => setCommands(getDecorationGrayColor24(i));
|
|
603
|
-
/** Sets decoration 256-color gray by intensity.
|
|
604
|
-
* @param {number} i - Gray intensity (0-255).
|
|
605
|
-
* @returns {string} SGR escape sequence.
|
|
606
|
-
*/
|
|
607
207
|
export const setDecorationGrayColor256 = i => setCommands(getDecorationGrayColor256(i));
|
|
608
208
|
|
|
609
|
-
/** Returns decoration true color command array.
|
|
610
|
-
* @param {number} r - Red (0-255).
|
|
611
|
-
* @param {number} g - Green (0-255).
|
|
612
|
-
* @param {number} b - Blue (0-255).
|
|
613
|
-
* @returns {string[]}
|
|
614
|
-
*/
|
|
615
209
|
export const getDecorationTrueColor = (r, g, b) => [Commands.DECORATION_COLOR, ColorFormat.TRUE_COLOR, r, g, b];
|
|
616
|
-
/** Returns decoration true color command array from hex.
|
|
617
|
-
* @param {number} hex - Hex color value.
|
|
618
|
-
* @returns {string[]}
|
|
619
|
-
*/
|
|
620
210
|
export const getDecorationHexTrueColor = hex =>
|
|
621
211
|
getDecorationTrueColor((hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff);
|
|
622
212
|
|
|
623
|
-
/** Sets decoration true color.
|
|
624
|
-
* @param {number} r - Red (0-255).
|
|
625
|
-
* @param {number} g - Green (0-255).
|
|
626
|
-
* @param {number} b - Blue (0-255).
|
|
627
|
-
* @returns {string} SGR escape sequence.
|
|
628
|
-
*/
|
|
629
213
|
export const setDecorationTrueColor = (r, g, b) => setCommands(getDecorationTrueColor(r, g, b));
|
|
630
|
-
/** Sets decoration true color from hex.
|
|
631
|
-
* @param {number} hex - Hex color value.
|
|
632
|
-
* @returns {string} SGR escape sequence.
|
|
633
|
-
*/
|
|
634
214
|
export const setDecorationHexTrueColor = hex => setCommands(getDecorationHexTrueColor(hex));
|
package/src/box.d.ts
CHANGED
|
@@ -114,7 +114,10 @@ export class Box {
|
|
|
114
114
|
* @returns A new padded Box.
|
|
115
115
|
*/
|
|
116
116
|
padBottom(n: number, symbol?: string): Box;
|
|
117
|
-
/** Pads using CSS-style shorthand (top, right, bottom, left).
|
|
117
|
+
/** Pads using CSS-style shorthand (top, right, bottom, left). Box renders padding as
|
|
118
|
+
* literal characters, so `symbol` controls the visible padding character;
|
|
119
|
+
* `Panel.pad` has no `symbol` parameter because Panel pads with null cells whose
|
|
120
|
+
* rendering character is set later via `toStrings({emptySymbol})`.
|
|
118
121
|
* @param t - Top padding.
|
|
119
122
|
* @param r - Right padding (or symbol).
|
|
120
123
|
* @param b - Bottom padding (or symbol).
|