summaryrefslogtreecommitdiff
path: root/pygments/formatters/terminal.py
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2009-03-31 10:26:55 -0500
committergbrandl <devnull@localhost>2009-03-31 10:26:55 -0500
commit7b95efab48d9ec79e995bf4d6db10fd049e3395a (patch)
tree48fc9b840dab83976a85af85d1c705dbaa051a0b /pygments/formatters/terminal.py
parentf12c878ed096137c91658a0f62f0070e08c2afea (diff)
downloadpygments-7b95efab48d9ec79e995bf4d6db10fd049e3395a.tar.gz
Port Pygments to Python 3.1.
Diffstat (limited to 'pygments/formatters/terminal.py')
-rw-r--r--pygments/formatters/terminal.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/pygments/formatters/terminal.py b/pygments/formatters/terminal.py
index ba7d35db..fdcc8dcc 100644
--- a/pygments/formatters/terminal.py
+++ b/pygments/formatters/terminal.py
@@ -78,19 +78,20 @@ class TerminalFormatter(Formatter):
def __init__(self, **options):
Formatter.__init__(self, **options)
- self.darkbg = get_choice_opt(options, 'bg', ['light', 'dark'], 'light') == 'dark'
+ self.darkbg = get_choice_opt(options, 'bg',
+ ['light', 'dark'], 'light') == 'dark'
self.colorscheme = options.get('colorscheme', None) or TERMINAL_COLORS
def format(self, tokensource, outfile):
- enc = self.encoding
# hack: if the output is a terminal and has an encoding set,
# use that to avoid unicode encode problems
- if not enc and hasattr(outfile, "encoding") and \
+ if not self.encoding and hasattr(outfile, "encoding") and \
hasattr(outfile, "isatty") and outfile.isatty():
- enc = outfile.encoding
+ self.encoding = outfile.encoding
+ return Formatter.format(self, tokensource, outfile)
+
+ def format_unencoded(self, tokensource, outfile):
for ttype, value in tokensource:
- if enc:
- value = value.encode(enc)
color = self.colorscheme.get(ttype)
while color is None:
ttype = ttype[:-1]