For search highlighting, use pango attrlists instead of markup

This commit is contained in:
René Stadler 2007-11-30 10:54:32 +02:00 committed by Stefan Sauer
parent 80263e1416
commit 99c871ba4a

View file

@ -728,23 +728,21 @@ class MessageColumn (TextColumn):
def get_data_func (self): def get_data_func (self):
from pango import AttrList, AttrBackground, AttrForeground
highlight = self.highlight highlight = self.highlight
escape = gobject.markup_escape_text
def message_data_func (props, value, path): def message_data_func (props, value, path):
line_index = path[0] line_index = path[0]
if line_index in highlight:
props.text = None
start, end = highlight[line_index]
props.markup = escape (value[:start]) + \
"<span background='blue' foreground='white'>" + \
escape (value[start:end]) + \
"</span>" + \
escape (value[end:])
else:
props.markup = None
props.text = value props.text = value
if line_index in highlight:
start, end = highlight[line_index]
attrlist = AttrList ()
attrlist.insert (AttrBackground (0, 0, 65535, start, end))
attrlist.insert (AttrForeground (65535, 65535, 65535, start, end))
props.attributes = attrlist
else:
props.attributes = None
return message_data_func return message_data_func