highlighting update

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-03-31 14:23:19 +00:00
parent 33dc4ff2e3
commit 3f895ac112
1 changed files with 10 additions and 2 deletions

View File

@ -23,11 +23,19 @@ class Highlighter:
def display(self, token_colors={}, debug=False): def display(self, token_colors={}, debug=False):
for group in self.tokens: for group in self.tokens:
for token in group: for token in group:
if token.name in token_colors: color_name = None
color_name = token_colors[token.name] name_parts = token.name.split('.')
for i in range(0, len(name_parts)):
if '.'.join(name_parts[i:]) in token_colors:
color_name = token_colors['.'.join(name_parts[i:])]
break
if color_name is not None:
sys.stdout.write(color_dict[color_name]) sys.stdout.write(color_dict[color_name])
elif debug: elif debug:
raise Exception, "no highlighting for %r" % token.name raise Exception, "no highlighting for %r" % token.name
else:
color_name = 'white'
sys.stdout.write(color_dict[color_name])
sys.stdout.write(token.string) sys.stdout.write(token.string)
sys.stdout.write('\n') sys.stdout.write('\n')