gboolean command_search(const Arg *arg) { static short dir; /* last direction 1 forward, -1 backward*/ const char *query; static gboolean newsearch = true; gboolean forward; 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; } /* copy search query for later use */ if (arg->s) { /* set search direction only when the searching is started */ dir = arg->i > 0 ? 1 : -1; query = arg->s; /* add new search query to history and search register */ vb_register_add('/', query); history_add(HISTORY_SEARCH, query, NULL); } else { /* no search phrase given - continue a previous search */ query = vb_register_get('/'); } forward = (arg->i * dir) > 0; if (query) { unsigned int count = abs(arg->i); if (newsearch) { #ifdef FEATURE_SEARCH_HIGHLIGHT /* highlight matches if the search is started new or continued * after switch to normal mode which calls this function with * COMMAND_SEARCH_OFF */ 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 */ if (count) { count -= 1; } } while (count--) { if (!webkit_web_view_search_text(vb.gui.webview, query, false, forward, true)) { break; } }; } return true; }
void browser_update_search_highlight(Browser *b, char *search_text) { /* remove previous highlighting */ webkit_web_view_unmark_text_matches(b->UI.view); /* highlight all occurrences of search text */ webkit_web_view_mark_text_matches(b->UI.view, search_text, FALSE, 0); webkit_web_view_set_highlight_text_matches(b->UI.view, TRUE); }
static void search_text (WebKitWebView *page, const char *param) { if ((param) && (param[0] != '\0')) { strcpy(uzbl.state.searchtx, param); } if (uzbl.state.searchtx[0] != '\0') { printf ("Searching: %s\n", uzbl.state.searchtx); webkit_web_view_unmark_text_matches (page); webkit_web_view_mark_text_matches (page, uzbl.state.searchtx, FALSE, 0); webkit_web_view_set_highlight_text_matches (page, TRUE); webkit_web_view_search_text (page, uzbl.state.searchtx, FALSE, TRUE, TRUE); } }
gboolean ygtk_html_wrap_search (GtkWidget *widget, const gchar *text) { WebKitWebView *view = WEBKIT_WEB_VIEW (widget); webkit_web_view_unmark_text_matches (view); if (*text) { gboolean found = webkit_web_view_mark_text_matches (view, text, FALSE, -1); webkit_web_view_set_highlight_text_matches (view, TRUE); if (found) ygtk_html_wrap_search_next (widget, text); return found; } // we want to un-select previous search (no such api though) return TRUE; }
void win_find(Win *w, gboolean b) { char buf[BUFSIZ]; unsigned char *p; webkit_web_view_unmark_text_matches(w->web); if(!atom_get(w, atoms[_OWL_FIND], XA_STRING, sizeof(buf), &p) || !p) return; memset(&buf, '\0', sizeof(buf)); strncpy(buf, (char*)p, sizeof(buf)); XFree(p); webkit_web_view_mark_text_matches(w->web, buf, CASEFIND, 0); webkit_web_view_set_highlight_text_matches(w->web, TRUE); webkit_web_view_search_text(w->web, buf, CASEFIND, b, TRUE); }
static gint luaH_webview_search(lua_State *L) { widget_t *w = luaH_checkudata(L, 1, &widget_class); WebKitWebView *view = WEBKIT_WEB_VIEW(GTK_WIDGET(g_object_get_data(G_OBJECT(w->widget), "webview"))); const gchar *text = luaL_checkstring(L, 2); gboolean case_sensitive = luaH_checkboolean(L, 3); gboolean forward = luaH_checkboolean(L, 4); gboolean wrap = luaH_checkboolean(L, 5); webkit_web_view_unmark_text_matches(view); webkit_web_view_search_text(view, text, case_sensitive, forward, wrap); webkit_web_view_mark_text_matches(view, text, case_sensitive, 0); webkit_web_view_set_highlight_text_matches(view, TRUE); return 0; }
static void ephy_find_toolbar_mark_matches (EphyFindToolbar *toolbar) { EphyFindToolbarPrivate *priv = toolbar->priv; WebKitWebView *web_view = priv->web_view; gboolean case_sensitive; case_sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->case_sensitive)); webkit_web_view_unmark_text_matches (web_view); if (priv->find_string != NULL && priv->find_string[0] != '\0') webkit_web_view_mark_text_matches (web_view, priv->find_string, case_sensitive, 0); webkit_web_view_set_highlight_text_matches (web_view, TRUE); }
void search_text (WebKitWebView *page, const gchar *key, const gboolean forward) { if (key && (*key != '\0')) { if (g_strcmp0 (uzbl.state.searchtx, key) != 0) { webkit_web_view_unmark_text_matches (page); webkit_web_view_mark_text_matches (page, key, FALSE, 0); g_free (uzbl.state.searchtx); uzbl.state.searchtx = g_strdup (key); } } if (uzbl.state.searchtx) { if (uzbl.state.verbose) printf ("Searching: %s\n", uzbl.state.searchtx); webkit_web_view_set_highlight_text_matches (page, TRUE); webkit_web_view_search_text (page, uzbl.state.searchtx, FALSE, forward, TRUE); } }
long wxWebViewWebKit::Find(const wxString& text, int flags) { bool newSearch = false; if(text != m_findText || (flags & wxWEBVIEW_FIND_MATCH_CASE) != (m_findFlags & wxWEBVIEW_FIND_MATCH_CASE)) { newSearch = true; //If it is a new search we need to clear existing highlights webkit_web_view_unmark_text_matches(m_web_view); webkit_web_view_set_highlight_text_matches(m_web_view, false); } m_findFlags = flags; m_findText = text; //If the search string is empty then we clear any selection and highlight if(text == "") { webkit_web_view_unmark_text_matches(m_web_view); webkit_web_view_set_highlight_text_matches(m_web_view, false); ClearSelection(); return wxNOT_FOUND; } bool wrap = false, matchCase = false, forward = true; if(flags & wxWEBVIEW_FIND_WRAP) wrap = true; if(flags & wxWEBVIEW_FIND_MATCH_CASE) matchCase = true; if(flags & wxWEBVIEW_FIND_BACKWARDS) forward = false; if(newSearch) { //Initially we mark the matches to know how many we have m_findCount = webkit_web_view_mark_text_matches(m_web_view, wxGTK_CONV(text), matchCase, 0); //In this case we return early to match IE behaviour m_findPosition = -1; return m_findCount; } else { if(forward) m_findPosition++; else m_findPosition--; if(m_findPosition < 0) m_findPosition += m_findCount; if(m_findPosition > m_findCount) m_findPosition -= m_findCount; } //Highlight them if needed bool highlight = flags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT ? true : false; webkit_web_view_set_highlight_text_matches(m_web_view, highlight); if(!webkit_web_view_search_text(m_web_view, wxGTK_CONV(text), matchCase, forward, wrap)) { m_findPosition = -1; ClearSelection(); return wxNOT_FOUND; } return newSearch ? m_findCount : m_findPosition; }
static void search_bar_find (ESearchBar *search_bar, gboolean search_forward) { EWebView *web_view; GtkWidget *widget; gboolean case_sensitive; gboolean wrapped = FALSE; gboolean success; gchar *text; guint matches; web_view = e_search_bar_get_web_view (search_bar); case_sensitive = e_search_bar_get_case_sensitive (search_bar); text = e_search_bar_get_text (search_bar); if (text == NULL || *text == '\0') { e_search_bar_clear (search_bar); g_free (text); return; } webkit_web_view_unmark_text_matches ( WEBKIT_WEB_VIEW (web_view)); matches = webkit_web_view_mark_text_matches ( WEBKIT_WEB_VIEW (web_view), text, case_sensitive, 0); webkit_web_view_set_highlight_text_matches ( WEBKIT_WEB_VIEW (web_view), TRUE); search_bar_update_matches (search_bar, matches); success = webkit_web_view_search_text ( WEBKIT_WEB_VIEW (web_view), text, case_sensitive, search_forward, FALSE); if (!success) wrapped = webkit_web_view_search_text ( WEBKIT_WEB_VIEW (web_view), text, case_sensitive, search_forward, TRUE); g_free (search_bar->priv->active_search); search_bar->priv->active_search = text; gtk_widget_set_sensitive (search_bar->priv->next_button, matches != 0); gtk_widget_set_sensitive (search_bar->priv->prev_button, matches != 0); g_object_notify (G_OBJECT (search_bar), "active-search"); /* Update wrapped label visibility. */ widget = search_bar->priv->wrapped_next_box; if (wrapped && search_forward) gtk_widget_show (widget); else gtk_widget_hide (widget); widget = search_bar->priv->wrapped_prev_box; if (wrapped && !search_forward) gtk_widget_show (widget); else gtk_widget_hide (widget); }
static void searchText(WebKitWebView* webView, gchar* searchString) { webkit_web_view_unmark_text_matches(webView); webkit_web_view_search_text(webView, searchString, false, true, true); webkit_web_view_mark_text_matches(webView, searchString, false, 0); webkit_web_view_set_highlight_text_matches(webView, true); }