bugfix: return text if no color, more debug infos
use global colormap_idx
This commit is contained in:
parent
f0ab462fc1
commit
c830a02fec
1 changed files with 14 additions and 9 deletions
|
|
@ -351,7 +351,7 @@ def color_scale( name, text ):
|
||||||
|
|
||||||
# if out of scale, do not color
|
# if out of scale, do not color
|
||||||
if f < scale[0] or f > scale[1]:
|
if f < scale[0] or f > scale[1]:
|
||||||
return text
|
return None
|
||||||
|
|
||||||
# normalize and scale over the nb of colors in cmap
|
# normalize and scale over the nb of colors in cmap
|
||||||
colormap = colormaps[name]
|
colormap = colormaps[name]
|
||||||
|
|
@ -448,7 +448,6 @@ def colorin(text, color="red", style="normal"):
|
||||||
|
|
||||||
assert( type(color) is str )
|
assert( type(color) is str )
|
||||||
|
|
||||||
global colormap_idx
|
|
||||||
global debug
|
global debug
|
||||||
|
|
||||||
# Special characters.
|
# Special characters.
|
||||||
|
|
@ -518,6 +517,7 @@ def colorin(text, color="red", style="normal"):
|
||||||
else:
|
else:
|
||||||
raise UnknownColor(color)
|
raise UnknownColor(color)
|
||||||
|
|
||||||
|
if color_code is not None:
|
||||||
if not debug:
|
if not debug:
|
||||||
return start + style_code + endmarks[m] + color_code + "m" + text + stop
|
return start + style_code + endmarks[m] + color_code + "m" + text + stop
|
||||||
else:
|
else:
|
||||||
|
|
@ -526,6 +526,11 @@ def colorin(text, color="red", style="normal"):
|
||||||
+ " style=" + str(style) + " stylecode=" + style_code \
|
+ " style=" + str(style) + " stylecode=" + style_code \
|
||||||
+ " mode=" + str(m) + ">" \
|
+ " mode=" + str(m) + ">" \
|
||||||
+ text + "</color>" + stop
|
+ text + "</color>" + stop
|
||||||
|
else:
|
||||||
|
if not debug:
|
||||||
|
return text
|
||||||
|
else:
|
||||||
|
return "<none>" + text + "</none>"
|
||||||
|
|
||||||
|
|
||||||
def colorout(text, match, prev_end, color="red", style="normal", group=0):
|
def colorout(text, match, prev_end, color="red", style="normal", group=0):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue