Browse Source

using the (user|group|tag)_regexp

master
Julio Biason 15 years ago
parent
commit
aa1ac95e57
  1. 24
      mitterlib/ui/helpers/gtk_messagegrid.py
  2. 35
      mitterlib/ui/ui_pygtk.py

24
mitterlib/ui/helpers/gtk_messagegrid.py

@ -107,6 +107,9 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
self.avatars = avatar_cache
self.link_color = '#0000ff'
self.user_color = '#00ff00'
self.tag_color = '#ff0000'
self.group_color = '#ffff00'
self.unread_char = '(o)'
self.favorite_char = '(F)'
self.unfavorite_char = '( )'
@ -184,6 +187,27 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
message_values['message'] = URL_RE.sub(mask,
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'])
# 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'])
# 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'])
# use a different highlight for the current user
# TODO: How to handle this with several networks?
#message = re.sub(r'(@'+self.twitter.username+')',

35
mitterlib/ui/ui_pygtk.py

@ -94,6 +94,10 @@ class Interface(object):
# the messages grid
messages = MessageGrid(self._avatars)
messages.link_color = self._options[self.NAMESPACE]['link_color']
messages.user_color = self._options[self.NAMESPACE]['user_color']
messages.group_color = self._options[self.NAMESPACE]['group_color']
messages.tag_color = self._options[self.NAMESPACE]['tag_color']
messages.unread_char = self._options[self.NAMESPACE]['unread_char']
messages.favorite_char = (
self._options[self.NAMESPACE]['favorite_char'])
@ -107,6 +111,10 @@ class Interface(object):
# replies grid
replies = MessageGrid(self._avatars)
replies.link_color = self._options[self.NAMESPACE]['link_color']
replies.user_color = self._options[self.NAMESPACE]['user_color']
replies.group_color = self._options[self.NAMESPACE]['group_color']
replies.tag_color = self._options[self.NAMESPACE]['tag_color']
replies.unread_char = self._options[self.NAMESPACE]['unread_char']
replies.favorite_char = (
self._options[self.NAMESPACE]['favorite_char'])
@ -1141,6 +1149,33 @@ class Interface(object):
default='blue',
conflict_group='interface',
is_cmd_option=False)
options.add_option(
group=self.NAMESPACE,
option='user_color',
help='Color for usernames',
type='str',
metavar='COLOR',
default='green',
conflict_group='interface',
is_cmd_option=False)
options.add_option(
group=self.NAMESPACE,
option='group_color',
help='Color for group names',
type='str',
metavar='COLOR',
default='red',
conflict_group='interface',
is_cmd_option=False)
options.add_option(
group=self.NAMESPACE,
option='tag_color',
help='Color for tags',
type='str',
metavar='COLOR',
default='goldenrod',
conflict_group='interface',
is_cmd_option=False)
options.add_option(
group=self.NAMESPACE,
option='spell_check',

Loading…
Cancel
Save