Mercurial > hg
changeset 30967:20990991d384
color: move '_effect' mapping into core
This is the second things we can move into core safely.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 18 Nov 2016 18:48:38 +0100 |
parents | 520af4cc34de |
children | 0d2a58a04080 |
files | hgext/color.py mercurial/color.py |
diffstat | 2 files changed, 29 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/color.py Fri Nov 18 18:43:39 2016 +0100 +++ b/hgext/color.py Fri Nov 18 18:48:38 2016 +0100 @@ -186,30 +186,6 @@ # leave the attribute unspecified. testedwith = 'ships-with-hg-core' -# start and stop parameters for effects -_effects = {'none': 0, - 'black': 30, - 'red': 31, - 'green': 32, - 'yellow': 33, - 'blue': 34, - 'magenta': 35, - 'cyan': 36, - 'white': 37, - 'bold': 1, - 'italic': 3, - 'underline': 4, - 'inverse': 7, - 'dim': 2, - 'black_background': 40, - 'red_background': 41, - 'green_background': 42, - 'yellow_background': 43, - 'blue_background': 44, - 'purple_background': 45, - 'cyan_background': 46, - 'white_background': 47} - def _terminfosetup(ui, mode): '''Initialize terminfo data and the terminal if we're in terminfo mode.''' @@ -298,7 +274,7 @@ if not w32effects: modewarn() return None - _effects.update(w32effects) + color._effects.update(w32effects) elif realmode == 'ansi': _terminfo_params.clear() elif realmode == 'terminfo': @@ -365,9 +341,9 @@ if not text: return text if not _terminfo_params: - start = [str(_effects[e]) for e in ['none'] + effects.split()] + start = [str(color._effects[e]) for e in ['none'] + effects.split()] start = '\033[' + ';'.join(start) + 'm' - stop = '\033[' + str(_effects['none']) + 'm' + stop = '\033[' + str(color._effects['none']) + 'm' else: start = ''.join(_effect_str(effect) for effect in ['none'] + effects.split()) @@ -377,7 +353,7 @@ def valideffect(effect): 'Determine if the effect is valid or not.' good = False - if not _terminfo_params and effect in _effects: + if not _terminfo_params and effect in color._effects: good = True elif effect in _terminfo_params or effect[:-11] in _terminfo_params: good = True @@ -505,7 +481,7 @@ oldstyle = color._styles.copy() try: color._styles.clear() - for effect in _effects.keys(): + for effect in color._effects.keys(): color._styles[effect] = effect if _terminfo_params: for k, v in ui.configitems('color'):
--- a/mercurial/color.py Fri Nov 18 18:43:39 2016 +0100 +++ b/mercurial/color.py Fri Nov 18 18:48:38 2016 +0100 @@ -7,6 +7,30 @@ from __future__ import absolute_import +# start and stop parameters for effects +_effects = {'none': 0, + 'black': 30, + 'red': 31, + 'green': 32, + 'yellow': 33, + 'blue': 34, + 'magenta': 35, + 'cyan': 36, + 'white': 37, + 'bold': 1, + 'italic': 3, + 'underline': 4, + 'inverse': 7, + 'dim': 2, + 'black_background': 40, + 'red_background': 41, + 'green_background': 42, + 'yellow_background': 43, + 'blue_background': 44, + 'purple_background': 45, + 'cyan_background': 46, + 'white_background': 47} + _styles = {'grep.match': 'red bold', 'grep.linenumber': 'green', 'grep.rev': 'green',