From 47757191f41251b5de0c84abe891624bde02aa72 Mon Sep 17 00:00:00 2001 From: miguel Date: Mon, 19 Mar 2018 18:08:18 +0100 Subject: paste uri and open in new window --- config.h | 1 + surf.c | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index 4744cec..264727a 100644 --- a/config.h +++ b/config.h @@ -178,6 +178,7 @@ static Key keys[] = { { 0, GDK_KEY_minus, zoom, { .i = -1 } }, { 0, GDK_KEY_equal, zoom, { .i = +1 } }, + { GDK_SHIFT_MASK, GDK_KEY_p, clipboard, { .i = 2 } }, { 0, GDK_KEY_p, clipboard, { .i = 1 } }, { 0, GDK_KEY_y, clipboard, { .i = 0 } }, diff --git a/surf.c b/surf.c index 68a1930..e1420b0 100644 --- a/surf.c +++ b/surf.c @@ -214,6 +214,7 @@ static void destroywin(GtkWidget* w, Client *c); /* Hotkeys */ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); +static void pasteurinew(GtkClipboard *clipboard, const char *text, gpointer d); static void reload(Client *c, const Arg *a); static void print(Client *c, const Arg *a); static void showcert(Client *c, const Arg *a); @@ -1707,7 +1708,22 @@ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) } loaduri((Client *) d, &a); } +} +void +pasteurinew(GtkClipboard *clipboard, const char *text, gpointer d) +{ + char buf[1024]; + Arg a = {.v = text }; + if (text) + { + if (strstr(text, ".") == NULL) { + snprintf(buf,1024,"https://duckduckgo.com/?q=%s",text); + a.v = buf; + printf("%s\n",buf); + } + piper_recv(buf); + } } void @@ -1753,10 +1769,15 @@ showcert(Client *c, const Arg *a) void clipboard(Client *c, const Arg *a) { - if (a->i) { /* load clipboard uri */ + if (a->i==1) { /* load clipboard uri */ gtk_clipboard_request_text(gtk_clipboard_get( GDK_SELECTION_PRIMARY), pasteuri, c); + }else if (a->i==2) { /* load clipboard uri */ + gtk_clipboard_request_text(gtk_clipboard_get( + GDK_SELECTION_PRIMARY), + pasteurinew, c); + } else { /* copy uri */ gtk_clipboard_set_text(gtk_clipboard_get( GDK_SELECTION_PRIMARY), c->targeturi @@ -1931,7 +1952,7 @@ clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h) void piper_recv(char *msg) { - g_print("message from extension: [%s]\n",msg); + g_print("message receieved [%s]\n",msg); Arg a; a.v=msg; @@ -1940,8 +1961,6 @@ piper_recv(char *msg) loaduri(c, &a); updatetitle(c); - - } int -- cgit v1.2.3