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

Loading…
Cancel
Save