sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 1e9f4501f3585549874b2d4a25682b4ae2dab384
parent 03d39c05841efbc7c637059af025388776292cd2
Author: Ivan Tham <pickfire@riseup.net>
Date:   Thu, 23 Mar 2017 11:09:04 +0800

update for latest HEAD 7e02344

Diffstat:
Msurf.suckless.org/patches/searchengines.md | 1+
Asurf.suckless.org/patches/surf-git-20170323-webkit2-searchengines.diff | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/surf.suckless.org/patches/searchengines.md b/surf.suckless.org/patches/searchengines.md @@ -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 @@ -0,0 +1,56 @@ +diff --git a/surf.c b/surf.c +index 93a1629..eb2af97 100644 +--- a/surf.c ++++ b/surf.c +@@ -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; +@@ -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); +@@ -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); +@@ -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) + {