Browse Source

check if the regexps exist before trying to use them (lots of "None"s being highlighted because of no checking)"

master
Julio Biason 15 years ago
parent
commit
777b11588e
  1. 33
      mitterlib/ui/helpers/gtk_messagegrid.py

33
mitterlib/ui/helpers/gtk_messagegrid.py

@ -187,25 +187,28 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
message_values['message']) message_values['message'])
# highlight users # highlight users
user_mask = '(%s)' % (data.user_regexp) if data.user_regexp:
user_re = re.compile(user_mask, re.I) user_mask = '(%s)' % (data.user_regexp)
mask = r'<span foreground="%s">\1</span>' % (self.user_color) user_re = re.compile(user_mask, re.I)
message_values['message'] = user_re.sub(mask, mask = r'<span foreground="%s">\1</span>' % (self.user_color)
message_values['message']) message_values['message'] = user_re.sub(mask,
message_values['message'])
# highlight groups # highlight groups
group_mask = '(%s)' % (data.group_regexp) if data.group_regexp:
group_re = re.compile(group_mask, re.I) group_mask = '(%s)' % (data.group_regexp)
mask = r'<span foreground="%s">\1</span>' % (self.group_color) group_re = re.compile(group_mask, re.I)
message_values['message'] = group_re.sub(mask, mask = r'<span foreground="%s">\1</span>' % (self.group_color)
message_values['message']) message_values['message'] = group_re.sub(mask,
message_values['message'])
# highlight tags # highlight tags
tag_mask = '(%s)' % (data.tag_regexp) if data.tag_regexp:
tag_re = re.compile(tag_mask, re.I) tag_mask = '(%s)' % (data.tag_regexp)
mask = r'<span foreground="%s">\1</span>' % (self.tag_color) tag_re = re.compile(tag_mask, re.I)
message_values['message'] = tag_re.sub(mask, mask = r'<span foreground="%s">\1</span>' % (self.tag_color)
message_values['message']) message_values['message'] = tag_re.sub(mask,
message_values['message'])
# use a different highlight for the current user # use a different highlight for the current user
# TODO: How to handle this with several networks? # TODO: How to handle this with several networks?

Loading…
Cancel
Save