# HG changeset patch
# User Matt Harbison <matt_harbi...@yahoo.com>
# Date 1495506038 14400
#      Mon May 22 22:20:38 2017 -0400
# Node ID 95ef3de9a9883c388dc80bb841fd0f7c41dac06a
# Parent  58dbbf67bd726092374403b2805d9ef9f5118ebe
color: enable ANSI support on Windows 10

This will display color if "color.mode=ansi", and default to 'ansi' if the mode
is set to 'auto'.  The 'debugcolor' command also reflects this policy.
Previously, "color.mode=ansi" mode on Windows printed jibberish around the
normal text.  Using ANSI color is better, as it avoids the normal loss of color
when the default pager is enabled on Windows.  See also issue5570.

When the underlying function fails (e.g. when run on older Windows), 'auto'
still falls back to 'win32'.

diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -227,12 +227,15 @@
             # gibberish, we error on the side of selecting "win32". However, if
             # w32effects is not defined, we almost certainly don't support
             # "win32", so don't even try.
-            if (term and 'xterm' in term) or not w32effects:
+            if ((term and 'xterm' in term) or util.enablevtmode()
+                 or not w32effects):
                 realmode = 'ansi'
             else:
                 realmode = 'win32'
         else:
             realmode = 'ansi'
+    elif mode =='ansi':
+        util.enablevtmode()
 
     def modewarn():
         # only warn if color.mode was explicitly set and we're in
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to