For search highlighting, use pango attrlists instead of markup
authorRené Stadler <mail@renestadler.de>
Fri, 30 Nov 2007 08:54:32 +0000 (10:54 +0200)
committerStefan Sauer <ensonic@users.sf.net>
Thu, 11 Sep 2014 18:51:41 +0000 (20:51 +0200)
debug-viewer/GstDebugViewer/GUI.py

index 8e27da9..f685b9d 100755 (executable)
@@ -728,23 +728,21 @@ class MessageColumn (TextColumn):
 
     def get_data_func (self):
 
+        from pango import AttrList, AttrBackground, AttrForeground
         highlight = self.highlight
-        escape = gobject.markup_escape_text
 
         def message_data_func (props, value, path):
 
             line_index = path[0]
+            props.text = value
             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:])
+                attrlist = AttrList ()
+                attrlist.insert (AttrBackground (0, 0, 65535, start, end))
+                attrlist.insert (AttrForeground (65535, 65535, 65535, start, end))
+                props.attributes = attrlist
             else:
-                props.markup = None
-                props.text = value
+                props.attributes = None
 
         return message_data_func