[wiki] [sites] [surf][searchengines] Update patch || Ivan Tham

From: <git_AT_suckless.org>
Date: Sun, 18 Oct 2015 06:47:42 +0200

commit 37ea638d39ffd39f68d3b0711efd57b78000f1c7
Author: Ivan Tham <pickfire_AT_riseup.net>
Date: Sun Oct 18 12:47:36 2015 +0800

    [surf][searchengines] Update patch

diff --git a/surf.suckless.org/patches/surf-0.6-searchengines.diff b/surf.suckless.org/patches/surf-0.6-searchengines.diff
index 653453d..da1828f 100644
--- a/surf.suckless.org/patches/surf-0.6-searchengines.diff
+++ b/surf.suckless.org/patches/surf-0.6-searchengines.diff
_AT_@ -1,69 +1,55 @@
-diff --git a/config.def.h b/config.def.h
-index 8185136..6b5144c 100644
---- a/config.def.h
-+++ b/config.def.h
-_AT_@ -101,3 +101,10 @@ static Key keys[] = {
- { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars,{ 0 } },
- { MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } },
- };
-+
-+static SearchEngine searchengines[] = {
-+ { "g", "http://www.google.de/search?q=%s" },
-+ { "en", "http://dict.cc/?s=%s" },
-+ { "ug", "http://%s.uni-goettingen.de" },
-+ { "dict", "http://www.thefreedictionary.com/%s" },
-+};
 diff --git a/surf.c b/surf.c
-index da84e1c..7eff5e8 100644
+index 0fae80b..deb23b7 100644
 --- a/surf.c
 +++ b/surf.c
-_AT_@ -70,6 +70,11 @@ typedef struct {
-
+_AT_@ -92,6 +92,12 @@ typedef struct {
  G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
  
-+typedef struct {
-+ char *token;
-+ char *uri;
+ typedef struct {
++ char *token;
++ char *uri;
 +} SearchEngine;
 +
- static Display *dpy;
- static Atom atoms[AtomLast];
- static Client *clients = NULL;
-_AT_@ -140,6 +145,7 @@ static void loaduri(Client *c, const Arg *arg);
++
++typedef struct {
+ char *regex;
+ char *style;
+ regex_t re;
+_AT_@ -179,6 +185,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 void populatepopup(WebKitWebView *web, GtkMenu *menu, Client *c);
- static void popupactivate(GtkMenuItem *menu, Client *);
-_AT_@ -629,8 +635,8 @@ loaduri(Client *c, const Arg *arg) {
+ static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
+ WebKitHitTestResult *target, gboolean keyboard, Client *c);
+_AT_@ -789,8 +796,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);
-+
          }
  
- /* prevents endless loop */
-_AT_@ -911,6 +917,20 @@ popupactivate(GtkMenuItem *menu, Client *c) {
+ setatom(c, AtomUri, uri);
+_AT_@ -1122,6 +1128,21 @@ menuactivate(GtkMenuItem *item, Client *c) {
          }
  }
  
-+gchar *
++static gchar *
 +parseuri(const gchar *uri) {
-+ guint i;
++ 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);
-+ }
++ 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);
++ return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http://%s", uri);
 +}
 +
  static void
Received on Sun Oct 18 2015 - 06:47:42 CEST

This archive was generated by hypermail 2.3.0 : Sun Oct 18 2015 - 06:48:13 CEST