From: Daniel Carl Date: Fri, 29 Aug 2014 22:12:42 +0000 (+0200) Subject: Show the number of search results in status bar. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=9720463c8c42e51ed436a0e8cde5703ca953e406;p=vimb.git Show the number of search results in status bar. If search highlight feature is on, show the number of matches in status bar as (num). --- diff --git a/src/command.c b/src/command.c index ed278b3..4e90e09 100644 --- a/src/command.c +++ b/src/command.c @@ -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 */ diff --git a/src/main.c b/src/main.c index bab1570..a9130a3 100644 --- a/src/main.c +++ b/src/main.c @@ -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 diff --git a/src/main.h b/src/main.h index dc513e3..103ac09 100644 --- a/src/main.h +++ b/src/main.h @@ -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 {