Show the number of search results in status bar.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 29 Aug 2014 22:12:42 +0000 (00:12 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 29 Aug 2014 22:12:42 +0000 (00:12 +0200)
If search highlight feature is on, show the number of matches in status bar as
(num).

src/command.c
src/main.c
src/main.h

index ed278b3..4e90e09 100644 (file)
@@ -39,6 +39,8 @@ gboolean command_search(const Arg *arg)
     if (arg->i == 0) {
 #ifdef FEATURE_SEARCH_HIGHLIGHT
         webkit_web_view_unmark_text_matches(vb.gui.webview);
+        vb.state.search_matches = 0;
+        vb_update_statusbar();
 #endif
         newsearch = true;
         return true;
@@ -66,10 +68,10 @@ gboolean command_search(const Arg *arg)
             /* highlight matches if the search is started new or continued
              * after switch to normal mode which calls this function with
              * COMMAND_SEARCH_OFF */
-            webkit_web_view_mark_text_matches(vb.gui.webview, query, false, 0);
+            vb.state.search_matches = webkit_web_view_mark_text_matches(vb.gui.webview, query, false, 0);
             webkit_web_view_set_highlight_text_matches(vb.gui.webview, true);
+            vb_update_statusbar();
 #endif
-
             newsearch = false;
             /* skip first search because this is done during typing in ex
              * mode, else the search will mark the next match as active */
index bab1570..a9130a3 100644 (file)
@@ -297,6 +297,13 @@ void vb_update_statusbar()
         g_string_append_printf(status, " %d %s", num, num == 1 ? "download" : "downloads");
     }
 
+#ifdef FEATURE_SEARCH_HIGHLIGHT
+    /* show the number of matches search results */
+    if (vb.state.search_matches) {
+        g_string_append_printf(status, " (%d)", vb.state.search_matches);
+    }
+#endif
+
     /* show load status of page or the downloads */
     if (vb.state.progress != 100) {
 #ifdef FEATURE_WGET_PROGRESS_BAR
index dc513e3..103ac09 100644 (file)
@@ -301,6 +301,9 @@ typedef struct {
     char            *reg[VB_REG_SIZE];      /* holds the yank buffer */
     gboolean        enable_register;        /* indicates if registers are filled */
     gboolean        enable_history;         /* indicates if history entries are written */
+#ifdef FEATURE_SEARCH_HIGHLIGHT
+    int             search_matches;         /* number of matches search results */
+#endif
 } State;
 
 typedef struct {