diff --git a/src/cgmnlm.c b/src/cgmnlm.c
index 5bf7dfdbea9a60cd610d76b82bb8e9bc3d5ffa1d..39be8ad24bdf97f87c3e51f4b5ce92e8bf1b421b 100644
--- a/src/cgmnlm.c
+++ b/src/cgmnlm.c
@@ -67,11 +67,9 @@ PROMPT_NEXT,
};
const char *default_bookmarks =
- "# Welcome to gmni\n\n"
+ "# Welcome to cgmnlm\n\n"
"Links:\n\n"
- // TODO: sub out the URL for the appropriate geminispace version once
- // sr.ht supports gemini
- "=> https://sr.ht/~sircmpwn/gmni The gmni browser\n"
+ "=> https://src.clttr.info/rwa/cgmnlm The cgmnlm browser\n"
"=> gemini://gemini.circumlunar.space The gemini protocol\n\n"
"This file can be found at %s and may be edited at your pleasure.\n\n"
"Bookmarks:\n"
@@ -79,24 +77,25 @@ ;
const char *help_msg =
"The following commands are available:\n\n"
- "q\tQuit\n"
- "[N]\tFollow Nth link (where N is a number)\n"
- "u[N]\tShow URL of Nth link (where N is a number)\n"
- "e[N]\tSend URL of Nth link in external default program\n"
- "b\tBack (in the page history)\n"
- "f\tForward (in the page history)\n"
- "H\tView all page history\n"
- "a\tSave bookmark\n"
- "B\tBrowse bookmarks\n"
- "r\tReload the page\n"
+ "<Enter>\t\tread more lines (if available)\n"
+ "<url>\t\tgo to url\n"
+ "[N]\t\tFollow Nth link (where N is a number)\n"
+ "u[N]\t\tShow URL of Nth link (where N is a number)\n"
+ "e[N]\t\tSend URL of Nth link in external default program\n"
+ "t[N]\t\tDownload content of Nth link to a temporary file\n"
+ "b\t\tBack (in the page history)\n"
+ "f\t\tForward (in the page history)\n"
+ "H\t\tView all page history\n"
+ "a\t\tSave bookmark\n"
+ "B\t\tBrowse bookmarks\n"
+ "r\t\tReload the page\n"
+ "/<text>\t\tsearch for text (POSIX regular expression)\n"
+ "n\t\tjump to next search match\n"
"d <path>\tDownload page to <path>\n"
- "|<prog>\tPipe page into program\n"
+ "|<prog>\t\tPipe page into program\n"
"[N]|<prog>\tPipe content of Nth link into program\n"
+ "q\t\tQuit\n"
"\n"
- "Other commands include:\n\n"
- "<Enter>\tread more lines\n"
- "<url>\tgo to url\n"
- "/<text>\tsearch for text (POSIX regular expression)\n"
;
static void
@@ -598,6 +597,7 @@ goto exit;
}
case 'e':
case 'u':
+ case 't':
if (!in[1]) break;
linksel = (int)strtol(in+1, &endptr, 10);
if (!endptr[0] && linksel >= 0) {
@@ -614,6 +614,24 @@ if (in[0] == 'e') {
char xdgopen[4096];
snprintf(xdgopen, sizeof(xdgopen), "xdg-open %s", link->url);
if ( !system(xdgopen) ) fprintf(browser->tty, "Link send to xdg-open\n");
+ }
+ if (in[0] == 't') {
+ struct gemini_response resp;
+ char url[1024] = {0};
+ strncpy(&url[0], browser->plain_url, sizeof(link->url)-1);
+ set_url(browser, link->url, &browser->history);
+ // XXX: may affect history, do we care?
+ enum gemini_result res = do_requests(browser, &resp);
+ if (res != GEMINI_OK) {
+ fprintf(stderr, "Error: %s\n",
+ gemini_strerr(res, &resp));
+ } else {
+ char tempfile[] = "/tmp/cgmnlm_XXXXXX";
+ mkstemp(tempfile);
+ download_resp(browser->tty, resp, tempfile, link->url);
+ }
+ gemini_response_finish(&resp);
+ set_url(browser, url, NULL);
}
fprintf(browser->tty, "\n");
}