changeset: 267:390a67498e5c
tag: tip
user: nils_AT_localhost.localdomain
date: Wed Sep 23 15:41:58 2009 +0200
files: surf.suckless.org/files/searchengines-0.1.diff surf.suckless.org/files/searchengines_patch.md surf.suckless.org/patches/searchengines-0.1.diff surf.suckless.org/patches/searchengines_patch.md
description:
Little change to parseuri(). Thanks to cryptix for his patch.
diff -r c1747ba1b102 -r 390a67498e5c surf.suckless.org/files/searchengines-0.1.diff
--- a/surf.suckless.org/files/searchengines-0.1.diff Wed Sep 23 14:05:28 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
_AT_@ -1,55 +0,0 @@
-diff -r fee97b4579f2 config.def.h
---- a/config.def.h Mon Sep 21 03:27:20 2009 +0200
-+++ b/config.def.h Wed Sep 23 01:21:45 2009 +0200
-_AT_@ -30,3 +30,6 @@
- { 0, GDK_Return, hideurl, { 0 }, UrlBar },
- };
-
-+static SearchEngine searchengines[] = {
-+ { NULL, NULL },
-+}
-diff -r fee97b4579f2 surf.c
---- a/surf.c Mon Sep 21 03:27:20 2009 +0200
-+++ b/surf.c Wed Sep 23 01:21:45 2009 +0200
-_AT_@ -58,6 +58,11 @@
- KeyFocus focus;
- } Key;
-
-+typedef struct {
-+ char *token;
-+ char *uri;
-+} SearchEngine;
-+
- static Display *dpy;
- static Atom urlprop;
- static SoupCookieJar *cookiejar;
-_AT_@ -348,14 +353,27 @@
- g_free(uri);
- }
-
-+gchar *
-+parseuri(const gchar *uri) {
-+ guint i;
-+ for (i = 0; i < LENGTH(searchengines); i++) {
-+ if (searchengines[i].token == NULL || searchengines[i].uri == NULL)
-+ continue;
-+ int length = strlen(searchengines[i].token) + 1;
-+ gchar *prefix = g_strdup_printf("%s ", searchengines[i].token);
-+ if(g_str_has_prefix(uri, prefix))
-+ return g_strdup_printf(searchengines[i].uri, uri+length);
-+ }
-+ return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("
http://%s", uri);
-+}
-+
- void
- loaduri(Client *c, const Arg *arg) {
- gchar *u;
- const gchar *uri = (gchar *)arg->v;
- if(!uri)
- uri = gtk_entry_get_text(GTK_ENTRY(c->urlbar));
-- 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);
diff -r c1747ba1b102 -r 390a67498e5c surf.suckless.org/files/searchengines_patch.md
--- a/surf.suckless.org/files/searchengines_patch.md Wed Sep 23 14:05:28 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
_AT_@ -1,32 +0,0 @@
-SEARCH ENGINES
-============
-
-Description
------------
-
-This little patch will allow the use of simple search engines. Put something
-like this in your config.h:
-
- static SearchEngine searchengines[] = {
- { "g", "
http://www.google.de/search?q=%s" },
- { "leo", "
http://dict.leo.org/ende?search=%s" },
- };
-
-This will enable searching in your favorit search engine by simply
-putting the prefix of your search engine in front your keywords:
-
-> "g foo bar"
-
-Or:
-
-> "leo hello"
-
-Download
-------
-
-* [searchengines-0.1.diff](searchengines-0.1.diff) (4K) (20090923)
-
-Author
-------
-
-- Nils Schweinsberg (McManiaC) <[mail_AT_n-sch.de](mailto:mail_AT_n-sch.de)>
diff -r c1747ba1b102 -r 390a67498e5c surf.suckless.org/patches/searchengines-0.1.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/surf.suckless.org/patches/searchengines-0.1.diff Wed Sep 23 15:41:58 2009 +0200
_AT_@ -0,0 +1,62 @@
+diff -r fee97b4579f2 config.def.h
+--- a/config.def.h Mon Sep 21 03:27:20 2009 +0200
++++ b/config.def.h Wed Sep 23 15:00:12 2009 +0200
+_AT_@ -30,3 +30,6 @@
+ { 0, GDK_Return, hideurl, { 0 }, UrlBar },
+ };
+
++static SearchEngine searchengines[] = {
++ { NULL, NULL },
++}
+diff -r fee97b4579f2 surf.c
+--- a/surf.c Mon Sep 21 03:27:20 2009 +0200
++++ b/surf.c Wed Sep 23 15:00:12 2009 +0200
+_AT_@ -58,6 +58,11 @@
+ KeyFocus focus;
+ } Key;
+
++typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
+ static Display *dpy;
+ static Atom urlprop;
+ static SoupCookieJar *cookiejar;
+_AT_@ -92,6 +97,7 @@
+ static Client *newclient(void);
+ static WebKitWebView *newwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c);
+ static void pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d);
++static gchar *parseuri(const gchar *uri);
+ static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
+ static void print(Client *c, const Arg *arg);
+ static void proccookies(SoupMessage *m, Client *c);
+_AT_@ -348,14 +354,26 @@
+ g_free(uri);
+ }
+
++gchar *
++parseuri(const gchar *uri) {
++ guint i;
++ for (i = 0; i < LENGTH(searchengines); i++) {
++ if (searchengines[i].token == NULL || searchengines[i].uri == NULL)
++ 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
+ loaduri(Client *c, const Arg *arg) {
+ gchar *u;
+ const gchar *uri = (gchar *)arg->v;
+ if(!uri)
+ uri = gtk_entry_get_text(GTK_ENTRY(c->urlbar));
+- 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);
diff -r c1747ba1b102 -r 390a67498e5c surf.suckless.org/patches/searchengines_patch.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/surf.suckless.org/patches/searchengines_patch.md Wed Sep 23 15:41:58 2009 +0200
_AT_@ -0,0 +1,32 @@
+SEARCH ENGINES
+============
+
+Description
+-----------
+
+This little patch will allow the use of simple search engines. Put something
+like this in your config.h:
+
+ static SearchEngine searchengines[] = {
+ { "g", "
http://www.google.de/search?q=%s" },
+ { "leo", "
http://dict.leo.org/ende?search=%s" },
+ };
+
+This will enable searching in your favorit search engine by simply
+putting the prefix of your search engine in front your keywords:
+
+ g foo bar
+
+Or:
+
+ leo hello
+
+Download
+------
+
+* [searchengines-0.1.diff](searchengines-0.1.diff) (4K) (20090923)
+
+Author
+------
+
+- Nils Schweinsberg (McManiaC) <[mail_AT_n-sch.de](mailto:mail_AT_n-sch.de)>
Received on Wed Sep 23 2009 - 15:42:05 CEST