diff options
author | tsxv478 <vt0451@yandex.ru> | 2022-09-27 11:43:58 +0300 |
---|---|---|
committer | tsxv478 <vt0451@yandex.ru> | 2022-09-27 11:43:58 +0300 |
commit | c52e6bfc2a9df4ee17d10664e78850f4378629cf (patch) | |
tree | a14c9f76fe241d34d70c4e8a5ef1ba94c10ee955 /surf.c | |
parent | 938efa500e6d29520e82602900ca26fbbf0995d5 (diff) |
search engines
Diffstat (limited to 'surf.c')
-rw-r--r-- | surf.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -133,6 +133,11 @@ typedef struct { } Button; typedef struct { + char *token; + char *uri; +} SearchEngine; + +typedef struct { const char *uri; Parameter config[ParameterLast]; regex_t re; @@ -219,6 +224,7 @@ static void webprocessterminated(WebKitWebView *v, Client *c); static void closeview(WebKitWebView *v, Client *c); static void destroywin(GtkWidget* w, Client *c); +static gchar *parseuri(const gchar *uri); /* Hotkeys */ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); @@ -581,7 +587,7 @@ loaduri(Client *c, const Arg *a) url = g_strdup_printf("file://%s", path); free(path); } else { - url = g_strdup_printf("http://%s", uri); + url = parseuri(uri); } if (apath != uri) free(apath); @@ -1792,6 +1798,20 @@ destroywin(GtkWidget* w, Client *c) gtk_main_quit(); } +gchar * +parseuri(const gchar *uri) +{ + guint i; + + for (i = 0; i < LENGTH(searchengines); i++) { + if (g_str_has_prefix(uri, searchengines[i].token)) + return g_strdup_printf(searchengines[i].uri, + uri + strlen(searchengines[i].token)); + } + + return g_strdup_printf("http://%s", uri); +} + void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) { |