@@ -267,23 +267,86 @@ ObjectDefineProperty(inspect, 'defaultOptions', {
267
267
}
268
268
} ) ;
269
269
270
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
270
+ // Set Graphics Rendition http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
271
+ // Each color consists of an array with the color code as first entry and the
272
+ // reset code as second entry.
273
+ const defaultFG = 39 ;
274
+ const defaultBG = 49 ;
271
275
inspect . colors = ObjectAssign ( ObjectCreate ( null ) , {
276
+ reset : [ 0 , 0 ] ,
272
277
bold : [ 1 , 22 ] ,
278
+ dim : [ 2 , 22 ] , // Alias: faint
273
279
italic : [ 3 , 23 ] ,
274
280
underline : [ 4 , 24 ] ,
275
- inverse : [ 7 , 27 ] ,
276
- white : [ 37 , 39 ] ,
277
- grey : [ 90 , 39 ] ,
278
- black : [ 30 , 39 ] ,
279
- blue : [ 34 , 39 ] ,
280
- cyan : [ 36 , 39 ] ,
281
- green : [ 32 , 39 ] ,
282
- magenta : [ 35 , 39 ] ,
283
- red : [ 31 , 39 ] ,
284
- yellow : [ 33 , 39 ]
281
+ blink : [ 5 , 25 ] ,
282
+ // Swap forground and background colors
283
+ inverse : [ 7 , 27 ] , // Alias: swapcolors, swapColors
284
+ hidden : [ 8 , 28 ] , // Alias: conceal
285
+ strikethrough : [ 9 , 29 ] , // Alias: strikeThrough, crossedout, crossedOut
286
+ doubleunderline : [ 21 , 24 ] , // Alias: doubleUnderline
287
+ black : [ 30 , defaultFG ] ,
288
+ red : [ 31 , defaultFG ] ,
289
+ green : [ 32 , defaultFG ] ,
290
+ yellow : [ 33 , defaultFG ] ,
291
+ blue : [ 34 , defaultFG ] ,
292
+ magenta : [ 35 , defaultFG ] ,
293
+ cyan : [ 36 , defaultFG ] ,
294
+ white : [ 37 , defaultFG ] ,
295
+ bgBlack : [ 40 , defaultBG ] ,
296
+ bgRed : [ 41 , defaultBG ] ,
297
+ bgGreen : [ 42 , defaultBG ] ,
298
+ bgYellow : [ 43 , defaultBG ] ,
299
+ bgBlue : [ 44 , defaultBG ] ,
300
+ bgMagenta : [ 45 , defaultBG ] ,
301
+ bgCyan : [ 46 , defaultBG ] ,
302
+ bgWhite : [ 47 , defaultBG ] ,
303
+ framed : [ 51 , 54 ] ,
304
+ overlined : [ 53 , 55 ] ,
305
+ gray : [ 90 , defaultFG ] , // Alias: grey, blackBright
306
+ redBright : [ 91 , defaultFG ] ,
307
+ greenBright : [ 92 , defaultFG ] ,
308
+ yellowBright : [ 93 , defaultFG ] ,
309
+ blueBright : [ 94 , defaultFG ] ,
310
+ magentaBright : [ 95 , defaultFG ] ,
311
+ cyanBright : [ 96 , defaultFG ] ,
312
+ whiteBright : [ 97 , defaultFG ] ,
313
+ bgGray : [ 100 , defaultBG ] , // Alias: bgGrey, bgBlackBright
314
+ bgRedBright : [ 101 , defaultBG ] ,
315
+ bgGreenBright : [ 102 , defaultBG ] ,
316
+ bgYellowBright : [ 103 , defaultBG ] ,
317
+ bgBlueBright : [ 104 , defaultBG ] ,
318
+ bgMagentaBright : [ 105 , defaultBG ] ,
319
+ bgCyanBright : [ 106 , defaultBG ] ,
320
+ bgWhiteBright : [ 107 , defaultBG ] ,
285
321
} ) ;
286
322
323
+ function defineColorAlias ( target , alias ) {
324
+ ObjectDefineProperty ( inspect . colors , alias , {
325
+ get ( ) {
326
+ return this [ target ] ;
327
+ } ,
328
+ set ( value ) {
329
+ this [ target ] = value ;
330
+ } ,
331
+ configurable : true ,
332
+ enumerable : false
333
+ } ) ;
334
+ }
335
+
336
+ defineColorAlias ( 'gray' , 'grey' ) ;
337
+ defineColorAlias ( 'gray' , 'blackBright' ) ;
338
+ defineColorAlias ( 'bgGray' , 'bgGrey' ) ;
339
+ defineColorAlias ( 'bgGray' , 'bgBlackBright' ) ;
340
+ defineColorAlias ( 'dim' , 'faint' ) ;
341
+ defineColorAlias ( 'strikethrough' , 'crossedout' ) ;
342
+ defineColorAlias ( 'strikethrough' , 'strikeThrough' ) ;
343
+ defineColorAlias ( 'strikethrough' , 'crossedOut' ) ;
344
+ defineColorAlias ( 'hidden' , 'conceal' ) ;
345
+ defineColorAlias ( 'inverse' , 'swapColors' ) ;
346
+ defineColorAlias ( 'inverse' , 'swapcolors' ) ;
347
+ defineColorAlias ( 'doubleunderline' , 'doubleUnderline' ) ;
348
+
349
+ // TODO(BridgeAR): Add function style support for more complex styles.
287
350
// Don't use 'blue' not visible on cmd.exe
288
351
inspect . styles = ObjectAssign ( ObjectCreate ( null ) , {
289
352
special : 'cyan' ,
@@ -296,6 +359,7 @@ inspect.styles = ObjectAssign(ObjectCreate(null), {
296
359
symbol : 'green' ,
297
360
date : 'magenta' ,
298
361
// "name": intentionally not styling
362
+ // TODO(BridgeAR): Highlight regular expressions properly.
299
363
regexp : 'red' ,
300
364
module : 'underline'
301
365
} ) ;
0 commit comments