• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3/*
4 * Info: http://www.termsys.demon.co.uk/vtansi.htm#colors
5 * Following caveats
6 * bright    - brightens the color (bold-blue is same as brigthtBlue)
7 * dim       - nothing on Mac or Linux
8 * italic    - nothing on Mac or Linux
9 * underline - underlines string
10 * blink     - nothing on Mac or linux
11 * inverse   - background becomes foreground and vice versa
12 *
13 * In summary, the only styles that work are:
14 *  - bright, underline and inverse
15 *  - the others are only included for completeness
16 */
17
18var styleNums = {
19    reset     :  [0, 22]
20  , bright    :  [1, 22]
21  , dim       :  [2, 22]
22  , italic    :  [3, 23]
23  , underline :  [4, 24]
24  , blink     :  [5, 25]
25  , inverse   :  [7, 27]
26  }
27  , styles = {}
28  ;
29
30Object.keys(styleNums).forEach(function (k) {
31  styles[k] = function (s) {
32    var open = styleNums[k][0]
33      , close = styleNums[k][1];
34    return '\u001b[' + open + 'm' + s + '\u001b[' + close + 'm';
35  };
36});
37
38module.exports = styles;
39