t* sacc + cursorline and uri preview URI git clone git://git.codevoid.de/sacc-sdk DIR Log DIR Files DIR Refs DIR LICENSE --- DIR commit 7496bf49839480d471dfc83a0aa7389b4a157e51 DIR parent 27ac9eb2a020670143ff63e4de1508f5c9b44941 URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Thu, 20 Dec 2018 09:00:18 +0100 Update 2018-12-20 09:00 Linux/x86_64 Diffstat: A config.h | 27 +++++++++++++++++++++++++++ M sacc.c | 23 +++++++++++++++++++++-- M ui_ti.c | 4 ++-- 3 files changed, 50 insertions(+), 4 deletions(-) --- DIR diff --git a/config.h b/config.h t@@ -0,0 +1,27 @@ +/* See LICENSE file for copyright and license details. */ + +/* Screen UI navigation keys */ +#define _key_lndown 'j' /* move one line down */ +#define _key_entrydown 'J' /* move to next link */ +#define _key_lnup 'k' /* move one line up */ +#define _key_entryup 'K' /* move to previous link */ +#define _key_pgdown ' ' /* move one screen down */ +#define _key_pgup 'b' /* move one screen up */ +#define _key_home 'g' /* move to the top of page */ +#define _key_end 'G' /* move to the bottom of page */ +#define _key_pgnext 'l' /* view highlighted item */ +#define _key_pgprev 'h' /* view previous item */ +#define _key_uri 'u' /* print item uri */ +#define _key_fetch 'L' /* refetch current item */ +#define _key_help '?' /* display help */ +#define _key_quit 'q' /* exit sacc */ +#define _key_search '/' /* search */ +#define _key_searchnext 'n' /* search same string forward */ +#define _key_searchprev 'N' /* search same string backward */ + +/* default plumber */ +static char *plumber = "rifle"; +static char *browser = "/usr/local/bin/luakit"; + +/* temporary directory */ +static char *tmpdir = "/tmp/sacc"; DIR diff --git a/sacc.c b/sacc.c t@@ -591,6 +591,24 @@ fetchitem(Item *item) } static void +browse(char *url) +{ + switch (fork()) { + case -1: + diag("Couldn't fork."); + return; + case 0: + parent = 0; + dup2(devnullfd, 1); + dup2(devnullfd, 2); + if (execlp(browser,browser, url, NULL) < 0) + _exit(1); + } + + diag("Browsed \"%s\"", url); +} + +static void plumb(char *url) { switch (fork()) { t@@ -622,6 +640,7 @@ plumbitem(Item *item) path = uiprompt("Download %s to (^D cancel, <empty> plumb): ", file); + if (!path) return; t@@ -679,7 +698,7 @@ dig(Item *entry, Item *item) switch (t) { case 'h': /* fallthrough */ if (!strncmp(item->selector, "URL:", 4)) { - plumb(item->selector+4); + browse(item->selector+4); return 0; } case '0': t@@ -956,7 +975,7 @@ setup(void) sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; sa.sa_handler = exit; - sigaction(SIGINT, &sa, NULL); + sigaction(SIGINT|SIGHUP, &sa, NULL); if (mkdir(tmpdir, S_IRWXU) < 0 && errno != EEXIST) die("mkdir: %s: %s", tmpdir, strerror(errno)); DIR diff --git a/ui_ti.c b/ui_ti.c t@@ -212,8 +212,8 @@ displayuri(Item *item) item->selector, item->host, item->port); break; case 'h': - n = snprintf(bufout, sizeof(bufout), "%s: %s", - item->username, item->selector); + n = snprintf(bufout, sizeof(bufout), "%s", + (item->selector + 4)); break; case 'T': n = snprintf(bufout, sizeof(bufout), "tn3270://%s@%s:%s",