Add better Windows color support using colorama

This commit is contained in:
Allan Chain 2019-04-27 06:55:40 +08:00
parent 553e0c17c2
commit c5df4e0234

12
buku
View File

@ -4323,7 +4323,9 @@ def read_in(msg):
disable_sigint_handler()
message = None
try:
message = input(msg)
# Delibrately dong this to better support Windows colorizing
print(msg, end='')
message = input()
except KeyboardInterrupt:
print('Interrupted.')
@ -4853,8 +4855,12 @@ POSITIONAL ARGUMENTS:
# only ConEmu is supported. If the user does not use ConEmu, colors are
# disabled unless --colors or %BUKU_COLORS% is specified.
if sys.platform == 'win32' and os.environ.get('ConemuDir') is None:
if args.colorstr is None and colorstr_env is not None:
args.nc = True
try:
import colorama
colorama.init()
except ImportError:
if args.colorstr is None and colorstr_env is not None:
args.nc = True
# Handle color output preference
if args.nc: