ThirdParty/Pygments/pygments/style.py

changeset 4172
4f20dba37ab6
parent 3079
0233bbe9a9c4
child 4697
c2e9bf425554
equal deleted inserted replaced
4170:8bc578136279 4172:4f20dba37ab6
3 pygments.style 3 pygments.style
4 ~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~
5 5
6 Basic style object. 6 Basic style object.
7 7
8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 from pygments.token import Token, STANDARD_TYPES 12 from pygments.token import Token, STANDARD_TYPES
13 13 from pygments.util import add_metaclass
14 def with_metaclass(meta, base=object):
15 """
16 Python independent version to create a base class with a metaclass.
17 Taken from six 1.3.0 (http://pythonhosted.org/six)
18 """
19 return meta("NewBase", (base,), {})
20 14
21 15
22 class StyleMeta(type): 16 class StyleMeta(type):
23 background_color = '#ffffff'
24
25 #: highlight background color
26 highlight_color = '#ffffcc'
27
28 #: Style definitions for individual token types.
29 styles = {}
30 17
31 def __new__(mcs, name, bases, dct): 18 def __new__(mcs, name, bases, dct):
32 obj = type.__new__(mcs, name, bases, dct) 19 obj = type.__new__(mcs, name, bases, dct)
33 for token in STANDARD_TYPES: 20 for token in STANDARD_TYPES:
34 if token not in obj.styles: 21 if token not in obj.styles:
116 103
117 def __len__(cls): 104 def __len__(cls):
118 return len(cls._styles) 105 return len(cls._styles)
119 106
120 107
121 class Style(with_metaclass(StyleMeta, object)): 108 @add_metaclass(StyleMeta)
122 pass 109 class Style(object):
110
111 #: overall background color (``None`` means transparent)
112 background_color = '#ffffff'
113
114 #: highlight background color
115 highlight_color = '#ffffcc'
116
117 #: Style definitions for individual token types.
118 styles = {}

eric ide

mercurial