eric6/ThirdParty/Pygments/pygments/style.py

changeset 7547
21b0534faebc
parent 6942
2602857055c5
child 7701
25f42e208e08
diff -r bf5f777260a6 -r 21b0534faebc eric6/ThirdParty/Pygments/pygments/style.py
--- a/eric6/ThirdParty/Pygments/pygments/style.py	Tue Apr 21 19:44:19 2020 +0200
+++ b/eric6/ThirdParty/Pygments/pygments/style.py	Tue Apr 21 19:47:10 2020 +0200
@@ -5,33 +5,53 @@
 
     Basic style object.
 
-    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
 from pygments.token import Token, STANDARD_TYPES
-from pygments.util import add_metaclass
 
-# Default mapping of #ansixxx to RGB colors.
+# Default mapping of ansixxx to RGB colors.
 _ansimap = {
     # dark
-    '#ansiblack': '000000',
-    '#ansidarkred': '7f0000',
-    '#ansidarkgreen': '007f00',
-    '#ansibrown': '7f7fe0',
-    '#ansidarkblue': '00007f',
-    '#ansipurple': '7f007f',
-    '#ansiteal': '007f7f',
-    '#ansilightgray': 'e5e5e5',
+    'ansiblack': '000000',
+    'ansired': '7f0000',
+    'ansigreen': '007f00',
+    'ansiyellow': '7f7fe0',
+    'ansiblue': '00007f',
+    'ansimagenta': '7f007f',
+    'ansicyan': '007f7f',
+    'ansigray': 'e5e5e5',
     # normal
-    '#ansidarkgray': '555555',
-    '#ansired': 'ff0000',
-    '#ansigreen': '00ff00',
-    '#ansiyellow': 'ffff00',
-    '#ansiblue': '0000ff',
-    '#ansifuchsia': 'ff00ff',
-    '#ansiturquoise': '00ffff',
-    '#ansiwhite': 'ffffff',
+    'ansibrightblack': '555555',
+    'ansibrightred': 'ff0000',
+    'ansibrightgreen': '00ff00',
+    'ansibrightyellow': 'ffff00',
+    'ansibrightblue': '0000ff',
+    'ansibrightmagenta': 'ff00ff',
+    'ansibrightcyan': '00ffff',
+    'ansiwhite': 'ffffff',
+}
+# mapping of deprecated #ansixxx colors to new color names
+_deprecated_ansicolors = {
+    # dark
+    '#ansiblack': 'ansiblack',
+    '#ansidarkred': 'ansired',
+    '#ansidarkgreen': 'ansigreen',
+    '#ansibrown': 'ansiyellow',
+    '#ansidarkblue': 'ansiblue',
+    '#ansipurple': 'ansimagenta',
+    '#ansiteal': 'ansicyan',
+    '#ansilightgray': 'ansigray',
+    # normal
+    '#ansidarkgray': 'ansibrightblack',
+    '#ansired': 'ansibrightred',
+    '#ansigreen': 'ansibrightgreen',
+    '#ansiyellow': 'ansibrightyellow',
+    '#ansiblue': 'ansibrightblue',
+    '#ansifuchsia': 'ansibrightmagenta',
+    '#ansiturquoise': 'ansibrightcyan',
+    '#ansiwhite': 'ansiwhite',
 }
 ansicolors = set(_ansimap)
 
@@ -52,9 +72,11 @@
                 if len(col) == 6:
                     return col
                 elif len(col) == 3:
-                    return col[0]*2 + col[1]*2 + col[2]*2
+                    return col[0] * 2 + col[1] * 2 + col[2] * 2
             elif text == '':
                 return ''
+            elif text.startswith('var') or text.startswith('calc'):
+                return text
             assert False, "wrong color format %r" % text
 
         _styles = obj._styles = {}
@@ -106,11 +128,15 @@
         t = cls._styles[token]
         ansicolor = bgansicolor = None
         color = t[0]
-        if color.startswith('#ansi'):
+        if color in _deprecated_ansicolors:
+            color = _deprecated_ansicolors[color]
+        if color in ansicolors:
             ansicolor = color
             color = _ansimap[color]
         bgcolor = t[4]
-        if bgcolor.startswith('#ansi'):
+        if bgcolor in _deprecated_ansicolors:
+            bgcolor = _deprecated_ansicolors[color]
+        if bgcolor in ansicolors:
             bgansicolor = bgcolor
             bgcolor = _ansimap[bgcolor]
 
@@ -142,8 +168,7 @@
         return len(cls._styles)
 
 
-@add_metaclass(StyleMeta)
-class Style(object):
+class Style(metaclass=StyleMeta):
 
     #: overall background color (``None`` means transparent)
     background_color = '#ffffff'

eric ide

mercurial