From patchwork Mon Apr 7 20:58:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,5] color: extract method for determining a valid effect From: Sean Farley X-Patchwork-Id: 4244 Message-Id: <07cabc89783a8ce2fd22.1396904293@laptop.local> To: mercurial-devel@selenic.com Date: Mon, 07 Apr 2014 15:58:13 -0500 # HG changeset patch # User Sean Farley # Date 1396902796 18000 # Mon Apr 07 15:33:16 2014 -0500 # Node ID 07cabc89783a8ce2fd224b2955fcce6e9ab90c38 # Parent 12f161f08d744f0e4b6eef9c905670afb5c24dd4 color: extract method for determining a valid effect diff --git a/hgext/color.py b/hgext/color.py --- a/hgext/color.py +++ b/hgext/color.py @@ -309,10 +309,19 @@ def render_effects(text, effects): def extstyles(): for name, ext in extensions.extensions(): _styles.update(getattr(ext, 'colortable', {})) +def valid_effect(effect): + 'Determine if the effect is valid or not.' + good = False + if not _terminfo_params and effect in _effects: + good = True + elif effect in _terminfo_params or effect[:-11] in _terminfo_params: + good = True + return good + def configstyles(ui): for status, cfgeffects in ui.configitems('color'): if '.' not in status or status.startswith('color.'): continue cfgeffects = ui.configlist('color', status)