commit 6c02e1ca02c9bd2d626756c6d243a2db6f799e71
Author: Stefan Tatschner <rumpelsepp_AT_sevenbyte.org>
Date: Sat Dec 19 15:32:08 2015 +0100
[surf] Port searchengines patch to version 0.7
diff --git a/surf.suckless.org/patches/searchengines.md b/surf.suckless.org/patches/searchengines.md
index 5ff2e1d..b734b83 100644
--- a/surf.suckless.org/patches/searchengines.md
+++ b/surf.suckless.org/patches/searchengines.md
_AT_@ -31,6 +31,7 @@ Download
* [surf-0.4-searchengines.diff](surf-0.4-searchengines.diff) (2107) (20091204)
* [surf-0.5-searchengines.diff](surf-0.5-searchengines.diff) (1611) (20101028)
* [surf-0.6-searchengines.diff](surf-0.6-searchengines.diff) (20130514)
+* [surf-0.7-searchengines.diff](surf-0.7-searchengines.diff) (20151219)
Author
------
diff --git a/surf.suckless.org/patches/surf-0.7-searchengines.diff b/surf.suckless.org/patches/surf-0.7-searchengines.diff
new file mode 100644
index 0000000..0e5d707
--- /dev/null
+++ b/surf.suckless.org/patches/surf-0.7-searchengines.diff
_AT_@ -0,0 +1,57 @@
+diff --git a/surf.c b/surf.c
+index f2170a4..8803c64 100644
+--- a/surf.c
++++ b/surf.c
+_AT_@ -91,6 +91,12 @@ typedef struct {
+ G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+
+ typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
++
++typedef struct {
+ char *regex;
+ char *style;
+ regex_t re;
+_AT_@ -178,6 +184,7 @@ static void loaduri(Client *c, const Arg *arg);
+ static void navigate(Client *c, const Arg *arg);
+ static Client *newclient(void);
+ static void newwindow(Client *c, const Arg *arg, gboolean noembed);
++static gchar *parseuri(const gchar *uri);
+ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+ static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
+ WebKitHitTestResult *target, gboolean keyboard,
+_AT_@ -838,8 +845,7 @@ loaduri(Client *c, const Arg *arg)
+ u = g_strdup_printf("file://%s", rp);
+ free(rp);
+ } else {
+- u = g_strrstr(uri, "://") ? g_strdup(uri)
+- : g_strdup_printf("
http://%s", uri);
++ u = parseuri(uri);
+ }
+
+ setatom(c, AtomUri, uri);
+_AT_@ -1172,6 +1178,21 @@ menuactivate(GtkMenuItem *item, Client *c)
+ }
+ }
+
++static 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_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("
http://%s", uri);
++}
++
+ void
+ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
+ {
Received on Sat Dec 19 2015 - 15:33:05 CET