ThirdParty/Pygments/pygments/formatters/terminal256.py

changeset 4172
4f20dba37ab6
parent 3145
a9de05d4a22f
child 4697
c2e9bf425554
--- a/ThirdParty/Pygments/pygments/formatters/terminal256.py	Wed Mar 11 18:25:37 2015 +0100
+++ b/ThirdParty/Pygments/pygments/formatters/terminal256.py	Wed Mar 11 18:32:27 2015 +0100
@@ -11,12 +11,10 @@
 
     Formatter version 1.
 
-    :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+    :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
-from __future__ import unicode_literals
-
 # TODO:
 #  - Options to map style's bold/underline/italic/border attributes
 #    to some ANSI attrbutes (something like 'italic=underline')
@@ -68,6 +66,7 @@
             attrs.append("00")
         return self.escape(attrs)
 
+
 class Terminal256Formatter(Formatter):
     r"""
     Format tokens with ANSI color sequences, for output in a 256-color
@@ -78,7 +77,7 @@
     and converts them to nearest ANSI 256-color escape sequences. Bold and
     underline attributes from the style are preserved (and displayed).
 
-    *New in Pygments 0.9.*
+    .. versionadded:: 0.9
 
     Options accepted:
 
@@ -100,28 +99,28 @@
         self.usebold = 'nobold' not in options
         self.useunderline = 'nounderline' not in options
 
-        self._build_color_table() # build an RGB-to-256 color conversion table
-        self._setup_styles() # convert selected style's colors to term. colors
+        self._build_color_table()  # build an RGB-to-256 color conversion table
+        self._setup_styles()  # convert selected style's colors to term. colors
 
     def _build_color_table(self):
         # colors 0..15: 16 basic colors
 
-        self.xterm_colors.append((0x00, 0x00, 0x00)) # 0
-        self.xterm_colors.append((0xcd, 0x00, 0x00)) # 1
-        self.xterm_colors.append((0x00, 0xcd, 0x00)) # 2
-        self.xterm_colors.append((0xcd, 0xcd, 0x00)) # 3
-        self.xterm_colors.append((0x00, 0x00, 0xee)) # 4
-        self.xterm_colors.append((0xcd, 0x00, 0xcd)) # 5
-        self.xterm_colors.append((0x00, 0xcd, 0xcd)) # 6
-        self.xterm_colors.append((0xe5, 0xe5, 0xe5)) # 7
-        self.xterm_colors.append((0x7f, 0x7f, 0x7f)) # 8
-        self.xterm_colors.append((0xff, 0x00, 0x00)) # 9
-        self.xterm_colors.append((0x00, 0xff, 0x00)) # 10
-        self.xterm_colors.append((0xff, 0xff, 0x00)) # 11
-        self.xterm_colors.append((0x5c, 0x5c, 0xff)) # 12
-        self.xterm_colors.append((0xff, 0x00, 0xff)) # 13
-        self.xterm_colors.append((0x00, 0xff, 0xff)) # 14
-        self.xterm_colors.append((0xff, 0xff, 0xff)) # 15
+        self.xterm_colors.append((0x00, 0x00, 0x00))  # 0
+        self.xterm_colors.append((0xcd, 0x00, 0x00))  # 1
+        self.xterm_colors.append((0x00, 0xcd, 0x00))  # 2
+        self.xterm_colors.append((0xcd, 0xcd, 0x00))  # 3
+        self.xterm_colors.append((0x00, 0x00, 0xee))  # 4
+        self.xterm_colors.append((0xcd, 0x00, 0xcd))  # 5
+        self.xterm_colors.append((0x00, 0xcd, 0xcd))  # 6
+        self.xterm_colors.append((0xe5, 0xe5, 0xe5))  # 7
+        self.xterm_colors.append((0x7f, 0x7f, 0x7f))  # 8
+        self.xterm_colors.append((0xff, 0x00, 0x00))  # 9
+        self.xterm_colors.append((0x00, 0xff, 0x00))  # 10
+        self.xterm_colors.append((0xff, 0xff, 0x00))  # 11
+        self.xterm_colors.append((0x5c, 0x5c, 0xff))  # 12
+        self.xterm_colors.append((0xff, 0x00, 0xff))  # 13
+        self.xterm_colors.append((0x00, 0xff, 0xff))  # 14
+        self.xterm_colors.append((0xff, 0xff, 0xff))  # 15
 
         # colors 16..232: the 6x6x6 color cube
 
@@ -140,7 +139,7 @@
             self.xterm_colors.append((v, v, v))
 
     def _closest_color(self, r, g, b):
-        distance = 257*257*3 # "infinity" (>distance from #000000 to #ffffff)
+        distance = 257*257*3  # "infinity" (>distance from #000000 to #ffffff)
         match = 0
 
         for i in range(0, 254):
@@ -199,7 +198,7 @@
             not_found = True
             while ttype and not_found:
                 try:
-                    #outfile.write( "<" + str(ttype) + ">" )
+                    # outfile.write( "<" + str(ttype) + ">" )
                     on, off = self.style_string[str(ttype)]
 
                     # Like TerminalFormatter, add "reset colors" escape sequence
@@ -213,12 +212,12 @@
                         outfile.write(on + spl[-1] + off)
 
                     not_found = False
-                    #outfile.write( '#' + str(ttype) + '#' )
+                    # outfile.write( '#' + str(ttype) + '#' )
 
                 except KeyError:
-                    #ottype = ttype
+                    # ottype = ttype
                     ttype = ttype[:-1]
-                    #outfile.write( '!' + str(ottype) + '->' + str(ttype) + '!' )
+                    # outfile.write( '!' + str(ottype) + '->' + str(ttype) + '!' )
 
             if not_found:
                 outfile.write(value)

eric ide

mercurial