summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/vimb.1.txt7
-rw-r--r--src/command.c37
-rw-r--r--src/command.h24
-rw-r--r--src/config.h1
-rw-r--r--src/hints.c4
-rw-r--r--src/hints.h3
6 files changed, 53 insertions, 23 deletions
diff --git a/doc/vimb.1.txt b/doc/vimb.1.txt
index 0e865c1..cdf8d35 100644
--- a/doc/vimb.1.txt
+++ b/doc/vimb.1.txt
@@ -226,6 +226,10 @@ given, print this into the inputbox, default ';i' and ';I'.
.BI "hint-editor [" PREFIX "]"
Start hinting to open inputboxes or textareas with external editor. If
\fIPREFIX\fP is given, print this into the inputbox, default ';e'.
+.TP
+.BI "hint-save [" PREFIX "]"
+Start hinting to download hinted links into configured download directory. If
+\fIPREFIX\fP is given, print this into the inputbox, default ';s'.
.SS Yank
.TP
@@ -529,6 +533,9 @@ Start hinting to open images into new window.
.B ;\-e
Start hinting to open editable form fileds with external editor.
.TP
+.B ;\-s
+Start hinting to download the linkes resource.
+.TP
.B y
Yank the URI or current page into clipboard.
.TP
diff --git a/src/command.c b/src/command.c
index 9fb39c6..b22619a 100644
--- a/src/command.c
+++ b/src/command.c
@@ -29,25 +29,6 @@
#include "bookmark.h"
#include "dom.h"
-/*
-bitmap
-1: primary cliboard
-2: secondary cliboard
-3: yank uri
-4: yank selection
-*/
-enum {
- COMMAND_YANK_URI = (VB_CLIPBOARD_SECONDARY<<1),
- COMMAND_YANK_SELECTION = (VB_CLIPBOARD_SECONDARY<<2)
-};
-
-enum {
- COMMAND_ZOOM_OUT,
- COMMAND_ZOOM_IN,
- COMMAND_ZOOM_FULL = (1<<1),
- COMMAND_ZOOM_RESET = (1<<2)
-};
-
typedef struct {
char *file;
Element *element;
@@ -112,6 +93,7 @@ static CommandInfo cmd_list[] = {
{"hint-image-open", NULL, command_hints, {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN, ";i"}},
{"hint-image-tabopen", NULL, command_hints, {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN | HINTS_OPEN_NEW, ";I"}},
{"hint-editor", NULL, command_hints, {HINTS_TYPE_EDITABLE, ";e"}},
+ {"hint-save", NULL, command_hints, {HINTS_TYPE_LINK | HINTS_PROCESS_SAVE, ";s"}},
{"yank-uri", "yu", command_yank, {VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY | COMMAND_YANK_URI}},
{"yank-selection", "ys", command_yank, {VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY | COMMAND_YANK_SELECTION}},
{"search-forward", NULL, command_search, {VB_SEARCH_FORWARD}},
@@ -134,7 +116,7 @@ static CommandInfo cmd_list[] = {
{"prev", "p", command_nextprev, {1}},
{"descent", NULL, command_descent, {0}},
{"descent!", NULL, command_descent, {1}},
- {"save", NULL, command_save, {0}},
+ {"save", NULL, command_save, {COMMAND_SAVE_CURRENT}},
};
static void editor_resume(GPid pid, int status, OpenEditorData *data);
@@ -745,14 +727,25 @@ gboolean command_descent(const Arg *arg)
gboolean command_save(const Arg *arg)
{
WebKitDownload *download;
- const char *uri = webkit_web_view_get_uri(vb.gui.webview);
+ const char *uri, *path = NULL;
+
+ vb_set_mode(VB_MODE_NORMAL, false);
+ if (arg->i == COMMAND_SAVE_CURRENT) {
+ uri = webkit_web_view_get_uri(vb.gui.webview);
+ /* given string is the path to save the download to */
+ if (arg->s && *(arg->s) != '\0') {
+ path = arg->s;
+ }
+ } else {
+ uri = arg->s;
+ }
if (!uri || *uri == '\0') {
return false;
}
download = webkit_download_new(webkit_network_request_new(uri));
- vb_download(vb.gui.webview, download, arg->s ? arg->s : NULL);
+ vb_download(vb.gui.webview, download, path);
return true;
}
diff --git a/src/command.h b/src/command.h
index ac41d21..326d5cb 100644
--- a/src/command.h
+++ b/src/command.h
@@ -20,6 +20,30 @@
#ifndef _COMMAND_H
#define _COMMAND_H
+/*
+bitmap
+1: primary cliboard
+2: secondary cliboard
+3: yank uri
+4: yank selection
+*/
+enum {
+ COMMAND_YANK_URI = (VB_CLIPBOARD_SECONDARY<<1),
+ COMMAND_YANK_SELECTION = (VB_CLIPBOARD_SECONDARY<<2)
+};
+
+enum {
+ COMMAND_ZOOM_OUT,
+ COMMAND_ZOOM_IN,
+ COMMAND_ZOOM_FULL = (1<<1),
+ COMMAND_ZOOM_RESET = (1<<2)
+};
+
+enum {
+ COMMAND_SAVE_CURRENT,
+ COMMAND_SAVE_URI
+};
+
void command_init(void);
GList *command_get_by_prefix(const char *prefix);
void command_cleanup(void);
diff --git a/src/config.h b/src/config.h
index 57b3ded..beb36bc 100644
--- a/src/config.h
+++ b/src/config.h
@@ -76,6 +76,7 @@ const char *default_config[] = {
"nmap ;i=hint-image-open",
"nmap ;I=hint-image-tabopen",
"nmap ;e=hint-editor",
+ "nmap ;s=hint-save",
"nmap y=yank-uri",
"nmap Y=yank-selection",
"nmap p=open-clipboard",
diff --git a/src/hints.c b/src/hints.c
index 2df9f17..0ebe2a7 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -164,6 +164,10 @@ static void run_script(char *js)
a.s = g_strconcat((mode & HINTS_OPEN_NEW) ? ":tabopen " : ":open ", v, NULL);
command_input(&a);
g_free(a.s);
+ } else if (mode & HINTS_PROCESS_SAVE) {
+ a.s = v;
+ a.i = COMMAND_SAVE_URI;
+ command_save(&a);
} else {
a.i = VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY;
a.s = v;
diff --git a/src/hints.h b/src/hints.h
index 5146036..52d4220 100644
--- a/src/hints.h
+++ b/src/hints.h
@@ -31,7 +31,8 @@ enum {
HINTS_PROCESS_INPUT = (1 << 2),
HINTS_PROCESS_YANK = (1 << 3),
HINTS_PROCESS_OPEN = (1 << 4),
- HINTS_OPEN_NEW = (1 << 5),
+ HINTS_PROCESS_SAVE = (1 << 5),
+ HINTS_OPEN_NEW = (1 << 6),
};
void hints_init(WebKitWebFrame *frame);