diff -r bf4d19a7cade -r c2e9bf425554 ThirdParty/Pygments/pygments/formatters/terminal.py --- a/ThirdParty/Pygments/pygments/formatters/terminal.py Sun Jan 24 16:15:58 2016 +0100 +++ b/ThirdParty/Pygments/pygments/formatters/terminal.py Sun Jan 24 19:28:37 2016 +0100 @@ -5,7 +5,7 @@ Formatter for terminal output with ANSI sequences. - :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -49,6 +49,7 @@ Generic.Inserted: ('darkgreen', 'green'), Generic.Heading: ('**', '**'), Generic.Subheading: ('*purple*', '*fuchsia*'), + Generic.Prompt: ('**', '**'), Generic.Error: ('red', 'red'), Error: ('_red_', '_red_'), @@ -101,51 +102,35 @@ def _write_lineno(self, outfile): self._lineno += 1 - outfile.write("\n%04d: " % self._lineno) - - def _format_unencoded_with_lineno(self, tokensource, outfile): - self._write_lineno(outfile) + outfile.write("%s%04d: " % (self._lineno != 1 and '\n' or '', self._lineno)) - for ttype, value in tokensource: - if value.endswith("\n"): - self._write_lineno(outfile) - value = value[:-1] - color = self.colorscheme.get(ttype) - while color is None: - ttype = ttype[:-1] - color = self.colorscheme.get(ttype) - if color: - color = color[self.darkbg] - spl = value.split('\n') - for line in spl[:-1]: - self._write_lineno(outfile) - if line: - outfile.write(ansiformat(color, line[:-1])) - if spl[-1]: - outfile.write(ansiformat(color, spl[-1])) - else: - outfile.write(value) - - outfile.write("\n") + def _get_color(self, ttype): + # self.colorscheme is a dict containing usually generic types, so we + # have to walk the tree of dots. The base Token type must be a key, + # even if it's empty string, as in the default above. + colors = self.colorscheme.get(ttype) + while colors is None: + ttype = ttype.parent + colors = self.colorscheme.get(ttype) + return colors[self.darkbg] def format_unencoded(self, tokensource, outfile): if self.linenos: - self._format_unencoded_with_lineno(tokensource, outfile) - return + self._write_lineno(outfile) for ttype, value in tokensource: - color = self.colorscheme.get(ttype) - while color is None: - ttype = ttype[:-1] - color = self.colorscheme.get(ttype) - if color: - color = color[self.darkbg] - spl = value.split('\n') - for line in spl[:-1]: - if line: - outfile.write(ansiformat(color, line)) - outfile.write('\n') - if spl[-1]: - outfile.write(ansiformat(color, spl[-1])) - else: - outfile.write(value) + color = self._get_color(ttype) + + for line in value.splitlines(True): + if color: + outfile.write(ansiformat(color, line.rstrip('\n'))) + else: + outfile.write(line.rstrip('\n')) + if line.endswith('\n'): + if self.linenos: + self._write_lineno(outfile) + else: + outfile.write('\n') + + if self.linenos: + outfile.write("\n")