Introduction
Introduction Statistics Contact Development Disclaimer Help
surf-0.7-searchengines.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
surf-0.7-searchengines.diff (1764B)
---
1 diff --git a/surf.c b/surf.c
2 index f2170a4..8803c64 100644
3 --- a/surf.c
4 +++ b/surf.c
5 @@ -91,6 +91,12 @@ typedef struct {
6 G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
7
8 typedef struct {
9 + char *token;
10 + char *uri;
11 +} SearchEngine;
12 +
13 +
14 +typedef struct {
15 char *regex;
16 char *style;
17 regex_t re;
18 @@ -178,6 +184,7 @@ static void loaduri(Client *c, const Arg *arg);
19 static void navigate(Client *c, const Arg *arg);
20 static Client *newclient(void);
21 static void newwindow(Client *c, const Arg *arg, gboolean noembed);
22 +static gchar *parseuri(const gchar *uri);
23 static void pasteuri(GtkClipboard *clipboard, const char *text, gpointe…
24 static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
25 WebKitHitTestResult *target, gboolean keybo…
26 @@ -838,8 +845,7 @@ loaduri(Client *c, const Arg *arg)
27 u = g_strdup_printf("file://%s", rp);
28 free(rp);
29 } else {
30 - u = g_strrstr(uri, "://") ? g_strdup(uri)
31 - : g_strdup_printf("http://%s", uri);
32 + u = parseuri(uri);
33 }
34
35 setatom(c, AtomUri, uri);
36 @@ -1172,6 +1178,21 @@ menuactivate(GtkMenuItem *item, Client *c)
37 }
38 }
39
40 +static gchar *
41 +parseuri(const gchar *uri) {
42 + guint i;
43 +
44 + for (i = 0; i < LENGTH(searchengines); i++) {
45 + if (searchengines[i].token == NULL || searchengines[i].uri == NU…
46 + *(uri + strlen(searchengines[i].token)) != ' ')
47 + continue;
48 + if (g_str_has_prefix(uri, searchengines[i].token))
49 + return g_strdup_printf(searchengines[i].uri, uri + strlen(se…
50 + }
51 +
52 + return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http…
53 +}
54 +
55 void
56 pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
57 {
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.