mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Windows color console support. update for pull request #252.
This commit is contained in:
parent
6fc7a1ac3c
commit
6ab7a2cbec
1
CHANGES
1
CHANGES
@ -39,6 +39,7 @@ New features
|
|||||||
submodule documentation. Thanks to Wes Turner and Luc Saffre.
|
submodule documentation. Thanks to Wes Turner and Luc Saffre.
|
||||||
* #1434: Provide non-minified JS files for jquery.js and underscore.js to
|
* #1434: Provide non-minified JS files for jquery.js and underscore.js to
|
||||||
clarify the source of the minified files.
|
clarify the source of the minified files.
|
||||||
|
* PR#252: Windows color console support. Thanks to meu31.
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
3
setup.py
3
setup.py
@ -49,6 +49,9 @@ requires = [
|
|||||||
'six', 'Jinja2>=2.3', 'Pygments>=1.2', 'docutils>=0.10', 'snowballstemmer>=1.1'
|
'six', 'Jinja2>=2.3', 'Pygments>=1.2', 'docutils>=0.10', 'snowballstemmer>=1.1'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
requires.append('colorama')
|
||||||
|
|
||||||
# Provide a "compile_catalog" command that also creates the translated
|
# Provide a "compile_catalog" command that also creates the translated
|
||||||
# JavaScript files if Babel is available.
|
# JavaScript files if Babel is available.
|
||||||
|
|
||||||
|
@ -13,6 +13,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
try:
|
||||||
|
# check if colorama is installed to support color on Windows
|
||||||
|
import colorama
|
||||||
|
except ImportError:
|
||||||
|
colorama = None
|
||||||
|
|
||||||
_ansi_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
|
_ansi_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
|
||||||
codes = {}
|
codes = {}
|
||||||
|
|
||||||
@ -42,6 +48,9 @@ def term_width_line(text):
|
|||||||
return text.ljust(_tw + len(text) - len(_ansi_re.sub('', text))) + '\r'
|
return text.ljust(_tw + len(text) - len(_ansi_re.sub('', text))) + '\r'
|
||||||
|
|
||||||
def color_terminal():
|
def color_terminal():
|
||||||
|
if sys.platform == 'win32' and colorama is not None:
|
||||||
|
colorama.init()
|
||||||
|
return True
|
||||||
if not hasattr(sys.stdout, 'isatty'):
|
if not hasattr(sys.stdout, 'isatty'):
|
||||||
return False
|
return False
|
||||||
if not sys.stdout.isatty():
|
if not sys.stdout.isatty():
|
||||||
@ -55,12 +64,7 @@ def color_terminal():
|
|||||||
|
|
||||||
|
|
||||||
def nocolor():
|
def nocolor():
|
||||||
# check if colorama is installed to support color on Windows
|
codes.clear()
|
||||||
try:
|
|
||||||
import colorama
|
|
||||||
colorama.init()
|
|
||||||
except ImportError:
|
|
||||||
codes.clear()
|
|
||||||
|
|
||||||
def coloron():
|
def coloron():
|
||||||
codes.update(_orig_codes)
|
codes.update(_orig_codes)
|
||||||
|
Loading…
Reference in New Issue
Block a user