Skip to content
Snippets Groups Projects
Commit ddc80d17 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

color: move 'valideffect' function into the core module

parent 0d2a58a0
No related branches found
No related tags found
No related merge requests found
......@@ -332,16 +332,6 @@
stop = _effect_str('none')
return ''.join([start, text, stop])
def valideffect(effect):
'Determine if the effect is valid or not.'
good = False
if not color._terminfo_params and effect in color._effects:
good = True
elif (effect in color._terminfo_params
or effect[:-11] in color._terminfo_params):
good = True
return good
def configstyles(ui):
for status, cfgeffects in ui.configitems('color'):
if '.' not in status or status.startswith(('color.', 'terminfo.')):
......@@ -350,7 +340,7 @@
if cfgeffects:
good = []
for e in cfgeffects:
if valideffect(e):
if color.valideffect(e):
good.append(e)
else:
ui.warn(_("ignoring unknown color/effect %r "
......@@ -412,7 +402,7 @@
s = color._styles.get(l, '')
if s:
effects.append(s)
elif valideffect(l):
elif color.valideffect(l):
effects.append(l)
effects = ' '.join(effects)
if effects:
......
......@@ -113,3 +113,13 @@
def loadcolortable(ui, extname, colortable):
_styles.update(colortable)
def valideffect(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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment