~ubuntu-branches/debian/squeeze/pygments/squeeze

« back to all changes in this revision

Viewing changes to pygments/formatters/terminal256.py

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ożarowski
  • Date: 2009-09-13 10:13:17 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090913101317-2w7g3lf43pginyc7
Tags: 1.1.1+dfsg-1
* New upstream release
  - upstream tarball repackaged: tests/examplefiles removed (at least one
    of example files is not DFSG-free and I'm too lazy to review the rest
    as most of them have different copyright holder and license),
    get-orig-source target added, debian/watch file updated
* use_jinja2_to_generate_docs patch removed (incorporated upstream)
* disable_ez_setup.patch no longer needed
* make_utf8_default.patch updated
* debian/copyright file updated
* Standards-Version bumped to 3.8.3 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
    Formatter version 1.
13
13
 
14
 
    :copyright: 2007 by Artem Egorkine.
15
 
    :license: BSD, see LICENSE for more details.
 
14
    :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS.
 
15
    :license: BSD, see LICENSE for details.
16
16
"""
17
17
 
18
18
# TODO:
124
124
        valuerange = (0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff)
125
125
 
126
126
        for i in range(217):
127
 
            r = valuerange[(i / 36) % 6]
128
 
            g = valuerange[(i / 6) % 6]
 
127
            r = valuerange[(i // 36) % 6]
 
128
            g = valuerange[(i // 6) % 6]
129
129
            b = valuerange[i % 6]
130
130
            self.xterm_colors.append((r, g, b))
131
131
 
182
182
                                             escape.reset_string())
183
183
 
184
184
    def format(self, tokensource, outfile):
185
 
        enc = self.encoding
186
185
        # hack: if the output is a terminal and has an encoding set,
187
186
        # use that to avoid unicode encode problems
188
 
        if not enc and hasattr(outfile, "encoding") and \
 
187
        if not self.encoding and hasattr(outfile, "encoding") and \
189
188
           hasattr(outfile, "isatty") and outfile.isatty():
190
 
            enc = outfile.encoding
 
189
            self.encoding = outfile.encoding
 
190
        return Formatter.format(self, tokensource, outfile)
191
191
 
 
192
    def format_unencoded(self, tokensource, outfile):
192
193
        for ttype, value in tokensource:
193
 
            if enc:
194
 
                value = value.encode(enc)
195
 
 
196
194
            not_found = True
197
195
            while ttype and not_found:
198
196
                try: