solarized.py 4.0 KB

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