Hello,
Fixed the patch for 0.3 this time. Tested, works, hope you'll have fun.
Regards,
Ted
--
===========================================================
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
diff -r 2998ef786732 config.def.h
--- a/config.def.h Wed Oct 28 22:22:20 2009 +0100
+++ b/config.def.h Wed Oct 28 23:26:09 2009 +0100
@@ -44,3 +44,7 @@
{ "Copy URI", clipboard, { .b = FALSE } },
{ "Download", download, { 0 } },
};
+
+static SearchEngine searchengines[] = {
+ { NULL, NULL },
+};
diff -r 2998ef786732 surf.c
--- a/surf.c Wed Oct 28 22:22:20 2009 +0100
+++ b/surf.c Wed Oct 28 23:26:09 2009 +0100
@@ -54,6 +54,11 @@
const Arg arg;
} Key;
+typedef struct {
+ char *token;
+ char *uri;
+} SearchEngine;
+
static Display *dpy;
static Atom uriprop, findprop;
static SoupCookieJar *cookies;
@@ -94,6 +99,7 @@
static void navigate(Client *c, const Arg *arg);
static Client *newclient(void);
static void newwindow(Client *c, const Arg *arg);
+static char *parseuri(const char *uri);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
static void print(Client *c, const Arg *arg);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer
d);
@@ -436,8 +442,7 @@
char *u;
const char *uri = (char *)arg->v;
- u = g_strrstr(uri, "://") ? g_strdup(uri)
- : g_strdup_printf("http://%s", uri);
+ u = parseuri(uri);
webkit_web_view_load_uri(c->view, u);
c->progress = 0;
c->title = copystr(&c->title, u);
@@ -574,6 +579,24 @@
spawn(NULL, &a);
}
+char *
+parseuri(const char *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) {
Arg arg = {.v = text };