[gnome-builder] search: use gb_str_highlight_fulL()



commit feca82cc0e1d8726fac3cde4d7d9d2659c538b3e
Author: Christian Hergert <christian hergert me>
Date:   Fri Oct 16 12:38:41 2015 -0700

    search: use gb_str_highlight_fulL()
    
    This had it's own highlighting code, which is copied at least 3x in the
    code base. We should start using one or two if possible.

 plugins/file-search/Makefile.am            |    1 +
 plugins/file-search/gb-file-search-index.c |   36 ++-------------------------
 2 files changed, 4 insertions(+), 33 deletions(-)
---
diff --git a/plugins/file-search/Makefile.am b/plugins/file-search/Makefile.am
index 1726265..7449b23 100644
--- a/plugins/file-search/Makefile.am
+++ b/plugins/file-search/Makefile.am
@@ -18,6 +18,7 @@ libfile_search_la_CFLAGS = \
        -I$(top_srcdir)/libide \
        -I$(top_srcdir)/src \
        -I$(top_srcdir)/src/search \
+       -I$(top_srcdir)/src/util \
        -I$(top_srcdir)/src/workbench \
        -I$(top_srcdir)/contrib/search \
        $(NULL)
diff --git a/plugins/file-search/gb-file-search-index.c b/plugins/file-search/gb-file-search-index.c
index 492ca3d..8457d99 100644
--- a/plugins/file-search/gb-file-search-index.c
+++ b/plugins/file-search/gb-file-search-index.c
@@ -22,6 +22,7 @@
 
 #include "gb-file-search-index.h"
 #include "gb-file-search-result.h"
+#include "gb-string.h"
 
 struct _GbFileSearchIndex
 {
@@ -287,38 +288,6 @@ gb_file_search_index_build_finish (GbFileSearchIndex  *self,
   return g_task_propagate_boolean (task, error);
 }
 
-static gchar *
-str_highlight (const gchar *str,
-               const gchar *match)
-{
-  GString *ret;
-  gunichar str_ch;
-  gunichar match_ch;
-
-  ret = g_string_new (NULL);
-
-  for (; *str; str = g_utf8_next_char (str))
-    {
-      str_ch = g_utf8_get_char (str);
-      match_ch = g_utf8_get_char (match);
-
-      if (str_ch == match_ch)
-        {
-          g_string_append (ret, "<u>");
-          g_string_append_unichar (ret, str_ch);
-          g_string_append (ret, "</u>");
-
-          match = g_utf8_next_char (match);
-        }
-      else
-        {
-          g_string_append_unichar (ret, str_ch);
-        }
-    }
-
-  return g_string_free (ret, FALSE);
-}
-
 void
 gb_file_search_index_populate (GbFileSearchIndex *self,
                                IdeSearchContext  *context,
@@ -356,7 +325,8 @@ gb_file_search_index_populate (GbFileSearchIndex *self,
           g_autoptr(GbFileSearchResult) result = NULL;
           g_autofree gchar *markup = NULL;
 
-          markup = str_highlight (match->key, query);
+          markup = gb_str_highlight_full (match->key, query, TRUE,
+                                          (GB_HIGHLIGHT_BOLD | GB_HIGHLIGHT_UNDERLINE));
           result = g_object_new (GB_TYPE_FILE_SEARCH_RESULT,
                                  "context", icontext,
                                  "provider", provider,


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