Пример #1
0
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;
}
Пример #2
0
static gint
luaH_webview_clear_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")));
    webkit_web_view_unmark_text_matches(view);
    return 0;
}
Пример #3
0
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);
}
Пример #4
0
static void
search_bar_update_highlights (ESearchBar *search_bar)
{
	EWebView *web_view;

	web_view = e_search_bar_get_web_view (search_bar);

	webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (web_view));

	e_search_bar_changed (search_bar);
}
Пример #5
0
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);
    }
}
Пример #6
0
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;
}
Пример #7
0
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);
}
Пример #8
0
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;
}
Пример #9
0
void sc_abort(Browser *b, const Arg *arg)
{
	/* stop loading website */
	webkit_web_view_stop_loading(b->UI.view);

	/* reset to NORMAL mode */
	browser_change_mode(b, NORMAL);

	/* hide inputbar */
	gtk_widget_hide(GTK_WIDGET(b->UI.inputbar));

	/* unmark search results */
	webkit_web_view_unmark_text_matches(b->UI.view);

	gtk_widget_grab_focus(GTK_WIDGET(b->UI.scrolled_window));
}
Пример #10
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);
}
Пример #11
0
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);
    }
}
Пример #12
0
static void
search_bar_show (GtkWidget *widget)
{
	ESearchBar *search_bar;
	EWebView *web_view;

	search_bar = E_SEARCH_BAR (widget);

	/* Chain up to parent's show() method. */
	GTK_WIDGET_CLASS (e_search_bar_parent_class)->show (widget);

	gtk_widget_grab_focus (search_bar->priv->entry);

	web_view = e_search_bar_get_web_view (search_bar);
	webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (web_view));

	search_bar_find (search_bar, TRUE);
}
Пример #13
0
static gboolean
search_entry_key_press (GtkWidget   *entry,
                        GdkEventKey *event)
{
  switch (event->keyval)
    {
    case GDK_KEY_Escape:
      gtk_widget_hide (searchbar);
      webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view));
      return TRUE;

    case GDK_KEY_Return:
    case GDK_KEY_KP_Enter:
    case GDK_KEY_ISO_Enter:
      search (gtk_entry_get_text (GTK_ENTRY (entry)), TRUE);
      return TRUE;
    }

  return FALSE;
}
Пример #14
0
static void
search_bar_clear (ESearchBar *search_bar)
{
	WebKitWebView *web_view;

	g_free (search_bar->priv->active_search);
	search_bar->priv->active_search = NULL;

	gtk_entry_set_text (GTK_ENTRY (search_bar->priv->entry), "");

	gtk_widget_hide (search_bar->priv->wrapped_next_box);
	gtk_widget_hide (search_bar->priv->wrapped_prev_box);
	gtk_widget_hide (search_bar->priv->matches_label);

	search_bar_update_highlights (search_bar);

	web_view = WEBKIT_WEB_VIEW (search_bar->priv->web_view);
	webkit_web_view_unmark_text_matches (web_view);

	g_object_notify (G_OBJECT (search_bar), "active-search");
}
Пример #15
0
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;
}
Пример #16
0
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);
}
Пример #17
0
static void
search_close_clicked (GtkWidget *button)
{
  gtk_widget_hide (searchbar);
  webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view));
}
Пример #18
0
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);
}