styles.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Generated by CoffeeScript 1.9.3
  2. var codes, styles;
  3. module.exports = styles = {};
  4. styles.codes = codes = {
  5. 'none': 0,
  6. 'black': 30,
  7. 'red': 31,
  8. 'green': 32,
  9. 'yellow': 33,
  10. 'blue': 34,
  11. 'magenta': 35,
  12. 'cyan': 36,
  13. 'white': 37,
  14. 'grey': 90,
  15. 'bright-red': 91,
  16. 'bright-green': 92,
  17. 'bright-yellow': 93,
  18. 'bright-blue': 94,
  19. 'bright-magenta': 95,
  20. 'bright-cyan': 96,
  21. 'bright-white': 97,
  22. 'bg-black': 40,
  23. 'bg-red': 41,
  24. 'bg-green': 42,
  25. 'bg-yellow': 43,
  26. 'bg-blue': 44,
  27. 'bg-magenta': 45,
  28. 'bg-cyan': 46,
  29. 'bg-white': 47,
  30. 'bg-grey': 100,
  31. 'bg-bright-red': 101,
  32. 'bg-bright-green': 102,
  33. 'bg-bright-yellow': 103,
  34. 'bg-bright-blue': 104,
  35. 'bg-bright-magenta': 105,
  36. 'bg-bright-cyan': 106,
  37. 'bg-bright-white': 107
  38. };
  39. styles.color = function(str) {
  40. var code;
  41. if (str === 'none') {
  42. return '';
  43. }
  44. code = codes[str];
  45. if (code == null) {
  46. throw Error("Unkown color `" + str + "`");
  47. }
  48. return "\x1b[" + code + "m";
  49. };
  50. styles.bg = function(str) {
  51. var code;
  52. if (str === 'none') {
  53. return '';
  54. }
  55. code = codes['bg-' + str];
  56. if (code == null) {
  57. throw Error("Unkown bg color `" + str + "`");
  58. }
  59. return "\x1B[" + code + "m";
  60. };
  61. styles.none = function(str) {
  62. return "\x1B[" + codes.none + "m";
  63. };