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