[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Wed, 23 Sep 2009 12:05:40 +0000 (UTC)

changeset: 266:c1747ba1b102
tag: tip
user: nils_AT_localhost.localdomain
date: Wed Sep 23 14:05:28 2009 +0200
files: surf.suckless.org/files/searchengines-0.1.diff surf.suckless.org/files/searchengines_patch.md
description:
Adding search engines patch for surf.


diff -r 983a3bbe9b16 -r c1747ba1b102 surf.suckless.org/files/searchengines-0.1.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/surf.suckless.org/files/searchengines-0.1.diff Wed Sep 23 14:05:28 2009 +0200
_AT_@ -0,0 +1,55 @@
+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 983a3bbe9b16 -r c1747ba1b102 surf.suckless.org/files/searchengines_patch.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/surf.suckless.org/files/searchengines_patch.md Wed Sep 23 14:05:28 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 - 14:05:40 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:30:51 CEST