solarized.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # -*- coding: utf-8 -*-
  2. """
  3. pygments.styles.solarized
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~
  5. Solarized by Camil Staps
  6. A Pygments style for the Solarized themes (licensed under MIT).
  7. See: https://github.com/altercation/solarized
  8. :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
  9. :license: BSD, see LICENSE for details.
  10. """
  11. from pygments.style import Style
  12. from pygments.token import Comment, Error, Generic, Keyword, Name, Number, \
  13. Operator, String, Token
  14. def make_style(colors):
  15. return {
  16. Token: colors['base0'],
  17. Comment: 'italic ' + colors['base01'],
  18. Comment.Hashbang: colors['base01'],
  19. Comment.Multiline: colors['base01'],
  20. Comment.Preproc: 'noitalic ' + colors['magenta'],
  21. Comment.PreprocFile: 'noitalic ' + colors['base01'],
  22. Keyword: colors['green'],
  23. Keyword.Constant: colors['cyan'],
  24. Keyword.Declaration: colors['cyan'],
  25. Keyword.Namespace: colors['orange'],
  26. Keyword.Type: colors['yellow'],
  27. Operator: colors['base01'],
  28. Operator.Word: colors['green'],
  29. Name.Builtin: colors['blue'],
  30. Name.Builtin.Pseudo: colors['blue'],
  31. Name.Class: colors['blue'],
  32. Name.Constant: colors['blue'],
  33. Name.Decorator: colors['blue'],
  34. Name.Entity: colors['blue'],
  35. Name.Exception: colors['blue'],
  36. Name.Function: colors['blue'],
  37. Name.Function.Magic: colors['blue'],
  38. Name.Label: colors['blue'],
  39. Name.Namespace: colors['blue'],
  40. Name.Tag: colors['blue'],
  41. Name.Variable: colors['blue'],
  42. Name.Variable.Global:colors['blue'],
  43. Name.Variable.Magic: colors['blue'],
  44. String: colors['cyan'],
  45. String.Doc: colors['base01'],
  46. String.Regex: colors['orange'],
  47. Number: colors['cyan'],
  48. Generic.Deleted: colors['red'],
  49. Generic.Emph: 'italic',
  50. Generic.Error: colors['red'],
  51. Generic.Heading: 'bold',
  52. Generic.Subheading: 'underline',
  53. Generic.Inserted: colors['green'],
  54. Generic.Strong: 'bold',
  55. Generic.Traceback: colors['blue'],
  56. Error: 'bg:' + colors['red'],
  57. }
  58. DARK_COLORS = {
  59. 'base03': '#002b36',
  60. 'base02': '#073642',
  61. 'base01': '#586e75',
  62. 'base00': '#657b83',
  63. 'base0': '#839496',
  64. 'base1': '#93a1a1',
  65. 'base2': '#eee8d5',
  66. 'base3': '#fdf6e3',
  67. 'yellow': '#b58900',
  68. 'orange': '#cb4b16',
  69. 'red': '#dc322f',
  70. 'magenta': '#d33682',
  71. 'violet': '#6c71c4',
  72. 'blue': '#268bd2',
  73. 'cyan': '#2aa198',
  74. 'green': '#859900',
  75. }
  76. LIGHT_COLORS = {
  77. 'base3': '#002b36',
  78. 'base2': '#073642',
  79. 'base1': '#586e75',
  80. 'base0': '#657b83',
  81. 'base00': '#839496',
  82. 'base01': '#93a1a1',
  83. 'base02': '#eee8d5',
  84. 'base03': '#fdf6e3',
  85. 'yellow': '#b58900',
  86. 'orange': '#cb4b16',
  87. 'red': '#dc322f',
  88. 'magenta': '#d33682',
  89. 'violet': '#6c71c4',
  90. 'blue': '#268bd2',
  91. 'cyan': '#2aa198',
  92. 'green': '#859900',
  93. }
  94. class SolarizedDarkStyle(Style):
  95. """
  96. The solarized style, dark.
  97. """
  98. styles = make_style(DARK_COLORS)
  99. background_color = DARK_COLORS['base03']
  100. highlight_color = DARK_COLORS['base02']
  101. class SolarizedLightStyle(SolarizedDarkStyle):
  102. """
  103. The solarized style, light.
  104. """
  105. styles = make_style(LIGHT_COLORS)
  106. background_color = LIGHT_COLORS['base03']
  107. highlight_color = LIGHT_COLORS['base02']