[polari/wip/kunaljain/polari-search: 1/2] Improved highlighting.



commit 9dd9f46c6f37b61cdcdf8ecaffee2c5ab8e7d8c1
Author: Kunaal Jain <kunaalus gmail com>
Date:   Sun Jun 12 19:03:35 2016 +0530

    Improved highlighting.

 src/mainWindow.js |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 7703702..0ec5173 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -265,16 +265,17 @@ const MainWindow = new Lang.Class({
     _Log: function(events) {
         log(events);
         let widgetMap = {};
+        let markup_message = '';
         for (let i = 0; i < events.length; i++) {
             let message = events[i].mms;
             let uid = events[i].id;
-
+            let index = 0;
             let row = this._widgetMap[uid];
             for (let j = 0; j < this._keywords.length; j++) {
-                log(this._keywords[j]);
-                print(message.indexOf(this._keywords[j]));
-                message = message.replace(this._keywords[j],"<span 
font_weight='bold'>"+this._keywords[j]+"</span>");
-                print(message);
+                // log(this._keywords[j]);
+                index = message.indexOf(this._keywords[j]);
+                message = message.replace( new RegExp( "(" + this._keywords[j] + ")" , 'gi' ),"<span 
font_weight='bold'>$1</span>");
+                // print(message);
             }
 
             if (row) {
@@ -295,6 +296,7 @@ const MainWindow = new Lang.Class({
                 row.uid = events[i].id;
                 widgetMap[uid] = row;
             }
+            widgetMap[uid].get_children()[0].label = message;
         }
 
         this._widgetMap = widgetMap;
@@ -303,6 +305,7 @@ const MainWindow = new Lang.Class({
 
         for (let i = 0; i < events.length; i++) {
             let row = this._widgetMap[events[i].id];
+            // row.get_children()[0].label = markup_message;
             this._results.add(row);
         }
     },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]