From 3f895ac1124cfeeec5e6e3ad899f6ae736070adf Mon Sep 17 00:00:00 2001 From: moculus Date: Sat, 31 Mar 2007 14:23:19 +0000 Subject: [PATCH] highlighting update --HG-- branch : pmacs2 --- highlight2.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/highlight2.py b/highlight2.py index b12b53b..c01d9f9 100644 --- a/highlight2.py +++ b/highlight2.py @@ -23,11 +23,19 @@ class Highlighter: def display(self, token_colors={}, debug=False): for group in self.tokens: for token in group: - if token.name in token_colors: - color_name = token_colors[token.name] + color_name = None + 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]) elif debug: 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('\n')