commit 1e9f4501f3585549874b2d4a25682b4ae2dab384
Author: Ivan Tham <pickfire_AT_riseup.net>
Date: Thu Mar 23 11:09:04 2017 +0800
update for latest HEAD 7e02344
diff --git a/surf.suckless.org/patches/searchengines.md b/surf.suckless.org/patches/searchengines.md
index 3b309dc..e87d418 100644
--- a/surf.suckless.org/patches/searchengines.md
+++ b/surf.suckless.org/patches/searchengines.md
_AT_@ -34,6 +34,7 @@ Download
* [surf-0.7-searchengines.diff](surf-0.7-searchengines.diff) (20151219)
* [surf-git-20160127-searchengines.diff](surf-git-20160127-searchengines.diff)
* [surf-0.7-webkit2-searchengines.diff](surf-0.7-webkit2-searchengines.diff) (20160108)
+* [surf-git-20170323-webkit2-searchengines.diff](surf-git-20170323-webkit2-searchengines.diff)
Author
------
diff --git a/surf.suckless.org/patches/surf-git-20170323-webkit2-searchengines.diff b/surf.suckless.org/patches/surf-git-20170323-webkit2-searchengines.diff
new file mode 100644
index 0000000..a8de97c
--- /dev/null
+++ b/surf.suckless.org/patches/surf-git-20170323-webkit2-searchengines.diff
_AT_@ -0,0 +1,56 @@
+diff --git a/surf.c b/surf.c
+index 93a1629..eb2af97 100644
+--- a/surf.c
++++ b/surf.c
+_AT_@ -129,6 +129,11 @@ typedef struct {
+ } Button;
+
+ typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
++typedef struct {
+ const char *uri;
+ Parameter config[ParameterLast];
+ regex_t re;
+_AT_@ -202,6 +207,7 @@ static void responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c);
+ static void download(Client *c, WebKitURIResponse *r);
+ static void closeview(WebKitWebView *v, Client *c);
+ static void destroywin(GtkWidget* w, Client *c);
++static gchar *parseuri(const gchar *uri);
+
+ /* Hotkeys */
+ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+_AT_@ -477,7 +483,7 @@ loaduri(Client *c, const Arg *a)
+ url = g_strdup_printf("file://%s", path);
+ free(path);
+ } else {
+- url = g_strdup_printf("
http://%s", uri);
++ url = parseuri(uri);
+ }
+
+ setatom(c, AtomUri, url);
+_AT_@ -1461,6 +1467,22 @@ destroywin(GtkWidget* w, Client *c)
+ gtk_main_quit();
+ }
+
++gchar *
++parseuri(const gchar *uri) {
++ guint i;
++
++ for (i = 0; i < LENGTH(searchengines); i++) {
++ if (searchengines[i].token == NULL || searchengines[i].uri == NULL ||
++ *(uri + strlen(searchengines[i].token)) != ' ')
++ continue;
++ if (g_str_has_prefix(uri, searchengines[i].token))
++ return g_strdup_printf(searchengines[i].uri,
++ uri + strlen(searchengines[i].token) + 1);
++ }
++
++ return g_strdup_printf("
http://%s", uri);
++}
++
+ void
+ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
+ {
Received on Thu Mar 23 2017 - 04:20:10 CET