diff mercurial/color.py @ 30968:0d2a58a04080

color: move '_terminfo_params' into the core 'color' module On step closer to have color in core.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 22 Dec 2016 02:23:23 +0100
parents 20990991d384
children ddc80d1777a6
line wrap: on
line diff
--- a/mercurial/color.py	Fri Nov 18 18:48:38 2016 +0100
+++ b/mercurial/color.py	Thu Dec 22 02:23:23 2016 +0100
@@ -7,6 +7,32 @@
 
 from __future__ import absolute_import
 
+try:
+    import curses
+    # Mapping from effect name to terminfo attribute name (or raw code) or
+    # color number.  This will also force-load the curses module.
+    _terminfo_params = {'none': (True, 'sgr0', ''),
+                        'standout': (True, 'smso', ''),
+                        'underline': (True, 'smul', ''),
+                        'reverse': (True, 'rev', ''),
+                        'inverse': (True, 'rev', ''),
+                        'blink': (True, 'blink', ''),
+                        'dim': (True, 'dim', ''),
+                        'bold': (True, 'bold', ''),
+                        'invisible': (True, 'invis', ''),
+                        'italic': (True, 'sitm', ''),
+                        'black': (False, curses.COLOR_BLACK, ''),
+                        'red': (False, curses.COLOR_RED, ''),
+                        'green': (False, curses.COLOR_GREEN, ''),
+                        'yellow': (False, curses.COLOR_YELLOW, ''),
+                        'blue': (False, curses.COLOR_BLUE, ''),
+                        'magenta': (False, curses.COLOR_MAGENTA, ''),
+                        'cyan': (False, curses.COLOR_CYAN, ''),
+                        'white': (False, curses.COLOR_WHITE, '')}
+except ImportError:
+    curses = None
+    _terminfo_params = {}
+
 # start and stop parameters for effects
 _effects = {'none': 0,
             'black': 30,