Home
add patch for sacc that implements onion-bookmarks - onion-completion - bash-tab-completion for onion adresses HTML git clone git@kroovy.de:onion-completion DIR Log DIR Files DIR Refs DIR README --- DIR commit e471996b842564071cedd879e85cc8d854543478 DIR parent a5d83002005e495fcd9c70561bb55508f6cc751d HTML Author: kroovy <me@kroovy.de> Date: Sat, 23 Sep 2017 12:28:13 +0200 add patch for sacc that implements onion-bookmarks Diffstat: A sacc-onionmarks.patch | 126 +++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+), 0 deletions(-) --- DIR diff --git a/sacc-onionmarks.patch b/sacc-onionmarks.patch @@ -0,0 +1,126 @@ +From d2cbbc988dff27fc57b51d6239843d937311765a Mon Sep 17 00:00:00 2001 +From: kroovy <me@kroovy.de> +Date: Sat, 23 Sep 2017 12:22:47 +0200 +Subject: [PATCH] implement onion-bookmarks + +--- + config.def.h | 4 ++++ + config.mk | 6 +++--- + ui_ti.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 57 insertions(+), 3 deletions(-) + +diff --git a/config.def.h b/config.def.h +index c44147d..6b9344c 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -12,6 +12,7 @@ + #define _key_pgnext 'l' /* view highlighted item */ + #define _key_pgprev 'h' /* view previous item */ + #define _key_uri 'u' /* print item uri */ ++#define _key_onionBM 'o' /* bookmark current onion-uri */ + #define _key_fetch 'L' /* refetch current item */ + #define _key_help '?' /* display help */ + #define _key_quit 'q' /* exit sacc */ +@@ -21,3 +22,6 @@ static char *plumber = "xdg-open"; + + /* temporary directory */ + static char *tmpdir = "/tmp/sacc"; ++ ++/* onion bookmark file */ ++static char *onion_bookmarks = "/home/kroovy/.onion-bookmarks"; +diff --git a/config.mk b/config.mk +index c6fe28d..4015519 100644 +--- a/config.mk ++++ b/config.mk +@@ -3,10 +3,10 @@ PREFIX = /usr/local + + # UI type + # txt (textual) +-UI=txt ++#UI=txt + # ti (screen-oriented) +-#UI=ti +-#UIFLAGS=-lcurses ++UI=ti ++UIFLAGS=-lcurses + + # Stock FLAGS + SACCCFLAGS = -D_DEFAULT_SOURCE $(CFLAGS) +diff --git a/ui_ti.c b/ui_ti.c +index 09f5127..22e2a10 100644 +--- a/ui_ti.c ++++ b/ui_ti.c +@@ -109,6 +109,7 @@ help(Item *entry) + "Right, " S(_key_pgnext) ": view highlighted item.\n" + "Left, " S(_key_pgprev) ": view previous item.\n" + S(_key_uri) ": print item uri.\n" ++ S(_key_onionBM) ": bookmark current onion-uri.\n" + S(_key_help) ": show this help.\n" + "^D, " S(_key_quit) ": exit sacc.\n" + }; +@@ -200,6 +201,52 @@ displayuri(Item *item) + fflush(stdout); + } + ++static void ++onionBM(Item *item) ++{ ++ char buf[64], *line; ++ int i, n, contains = 0, onion = 0; ++ FILE *f; ++ ++ putp(tparm(save_cursor)); ++ putp(tparm(cursor_address, lines-1, 0)); ++ putp(tparm(enter_standout_mode)); ++ ++ f = fopen(onion_bookmarks, "ra+"); ++ ++ if (f == NULL) { ++ printf("Error opening %s", onion_bookmarks); ++ putp(tparm(exit_standout_mode)); ++ putp(tparm(restore_cursor)); ++ fflush(stdout); ++ return; ++ } ++ ++ if (strstr(item->host, ".onion") != NULL) ++ onion = 1; ++ ++ for (i = 0; (line = fgets(buf, sizeof(buf), f)) != NULL; i++) { ++ line[strlen(line)-1] = '\0'; ++ if (strcmp(line, item->host) == 0) ++ contains = 1; ++ } ++ ++ if (!onion) { ++ n = printf("Not an onion-uri!"); ++ } else if (contains) { ++ n = printf("Onion-uri is already stored"); ++ } else { ++ fprintf(f, "%s\n", item->host); ++ n = printf("Onion-uri successfully stored"); ++ } ++ ++ fclose(f); ++ putp(tparm(exit_standout_mode)); ++ printf("%*s", columns-n, " "); ++ putp(tparm(restore_cursor)); ++ fflush(stdout); ++} ++ + void + uidisplay(Item *entry) + { +@@ -454,6 +501,9 @@ uiselectitem(Item *entry) + if (dir) + displayuri(&dir->items[dir->curline]); + continue; ++ case _key_onionBM: ++ onionBM(&dir->items[dir->curline]); ++ continue; + case _key_help: /* FALLTHROUGH */ + return help(entry); + default: +-- +2.12.2 +