summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2018-05-20 22:44:52 +0200
committerJonathan Slenders <jonathan@slenders.be>2018-05-20 22:44:59 +0200
commit3cb3a12e575be4d25552d413ab9554c4979fd64f (patch)
tree40721f154a3899cb264d80699ab8c8422f0ccbd2
parent55199591a59e45f4f59768ab0219f345d6fb05bc (diff)
Use 4 bit color by default on Windows.
This fixes a bug when true color is not supported. Even when vt100 escape sequences are supported, we don't know whether we can actually use true color.
-rw-r--r--prompt_toolkit/output/color_depth.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/prompt_toolkit/output/color_depth.py b/prompt_toolkit/output/color_depth.py
index 7f58597c..60db04bf 100644
--- a/prompt_toolkit/output/color_depth.py
+++ b/prompt_toolkit/output/color_depth.py
@@ -1,4 +1,5 @@
from __future__ import unicode_literals
+from prompt_toolkit.utils import is_windows
import os
__all__ = [
@@ -38,6 +39,13 @@ class ColorDepth(object):
if term in ('linux', 'eterm-color'):
return cls.DEPTH_4_BIT
+ # For now, always use 4 bit color on Windows 10 by default, even when
+ # vt100 escape sequences with ENABLE_VIRTUAL_TERMINAL_PROCESSING are
+ # supported. We don't have a reliable way yet to know whether our
+ # console supports true color or only 4-bit.
+ if is_windows() and 'PROMPT_TOOLKIT_COLOR_DEPTH' not in os.environ:
+ return cls.DEPTH_4_BIT
+
# Check the `PROMPT_TOOLKIT_COLOR_DEPTH` environment variable.
if os.environ.get('PROMPT_TOOLKIT_COLOR_DEPTH') in cls._ALL:
return os.environ['PROMPT_TOOLKIT_COLOR_DEPTH']