Mercurial > public > mercurial-scm > hg-stable
diff mercurial/color.py @ 30991:bb6385882cfa
color: move configstyles into the core module
The extension is getting thinner as we speak!
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 22 Dec 2016 02:34:22 +0100 |
parents | 683606a829e8 |
children | a3c7e42c7a1f |
line wrap: on
line diff
--- a/mercurial/color.py Thu Dec 22 02:30:03 2016 +0100 +++ b/mercurial/color.py Thu Dec 22 02:34:22 2016 +0100 @@ -7,6 +7,8 @@ from __future__ import absolute_import +from .i18n import _ + try: import curses # Mapping from effect name to terminfo attribute name (or raw code) or @@ -114,6 +116,22 @@ def loadcolortable(ui, extname, colortable): _styles.update(colortable) +def configstyles(ui): + for status, cfgeffects in ui.configitems('color'): + if '.' not in status or status.startswith(('color.', 'terminfo.')): + continue + cfgeffects = ui.configlist('color', status) + if cfgeffects: + good = [] + for e in cfgeffects: + if valideffect(e): + good.append(e) + else: + ui.warn(_("ignoring unknown color/effect %r " + "(configured in color.%s)\n") + % (e, status)) + _styles[status] = ' '.join(good) + def valideffect(effect): 'Determine if the effect is valid or not.' return ((not _terminfo_params and effect in _effects)