1. Dan Villiom Podlaski Christiansen
  2. Pygments Queue

Commits

Dan Villiom Podlaski Christiansen  committed feefd0d

New patches.

  • Participants
  • Parent commits bd0b6a1
  • Branches default

Comments (0)

Files changed (3)

File auto-term256.diff

View file
+# HG changeset patch
+# Parent 61d106092548d54b36fa4d86e7cb63b3dc8eefce
+# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
+Use the terminal256 formatter by default under a *-color256 terminal.
+
+diff --git a/pygments/cmdline.py b/pygments/cmdline.py
+--- a/pygments/cmdline.py
++++ b/pygments/cmdline.py
+@@ -8,6 +8,7 @@
+     :copyright: Copyright 2006-2011 by the Pygments team, see AUTHORS.
+     :license: BSD, see LICENSE for details.
+ """
++import os
+ import sys
+ import getopt
+ from textwrap import dedent
+@@ -18,7 +19,7 @@ from pygments.lexers import get_all_lexe
+      find_lexer_class, guess_lexer, TextLexer
+ from pygments.formatters import get_all_formatters, get_formatter_by_name, \
+      get_formatter_for_filename, find_formatter_class, \
+-     TerminalFormatter  # pylint:disable-msg=E0611
++     TerminalFormatter, Terminal256Formatter  # pylint:disable-msg=E0611
+ from pygments.filters import get_all_filters, find_filter_class
+ from pygments.styles import get_all_styles, get_style_by_name
+ 
+@@ -340,7 +341,10 @@ def main(args=sys.argv):
+             return 1
+     else:
+         if not fmter:
+-            fmter = TerminalFormatter(**parsed_opts)
++            if os.getenv('TERM', '').endswith('-256color'):
++                fmter = Terminal256Formatter(**parsed_opts)
++            else:
++                fmter = TerminalFormatter(**parsed_opts)
+         outfile = sys.stdout
+ 
+     # select lexer

File default-emacs.diff

View file
+# HG changeset patch
+# Parent ae43491e97c01cb382edd6dcd29054e59b5cc765
+# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
+Use the Emacs style by default.
+
+diff --git a/pygments/formatter.py b/pygments/formatter.py
+--- a/pygments/formatter.py
++++ b/pygments/formatter.py
+@@ -64,7 +64,7 @@ class Formatter(object):
+     unicodeoutput = True
+ 
+     def __init__(self, **options):
+-        self.style = _lookup_style(options.get('style', 'default'))
++        self.style = _lookup_style(options.get('style', 'emacs'))
+         self.full  = get_bool_opt(options, 'full', False)
+         self.title = options.get('title', '')
+         self.encoding = options.get('encoding', None) or None

File series

View file
+auto-term256.diff
+default-emacs.diff
 # Placed by Bitbucket