---
config.h | 2 ++
main.c | 25 ++++++++++++++++++++++++-
vimprobable2.1 | 4 ++++
3 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/config.h b/config.h
index b2f8e78..c0c618b 100644
--- a/config.h
+++ b/config.h
@@ -120,6 +120,8 @@ Command commands[COMMANDSIZE] = {
{ "bma", bookmark, {0} },
{ "bookmark", bookmark, {0} },
{ "source", view_source, {0} },
+ { "w", save_page, {0} },
+ { "write", save_page, {0} },
{ "set", browser_settings, {0} },
{ "map", mappings, {0} },
{ "jumpleft", scroll, {ScrollJumpTo | DirectionLeft} },
diff --git a/main.c b/main.c
index f106245..99ccad7 100644
--- a/main.c
+++ b/main.c
@@ -77,6 +77,7 @@ static gboolean yank(const Arg *arg);
static gboolean view_source(const Arg * arg);
static gboolean zoom(const Arg *arg);
static gboolean fake_key_event(const Arg *arg);
+static gboolean save_page(const Arg *arg);
static void update_url(const char *uri);
static void setup_modkeys(void);
@@ -280,7 +281,9 @@ webview_download_cb(WebKitWebView *webview, WebKitDownload *download, gpointer u
WebKitDownloadStatus status;
filename = webkit_download_get_suggested_filename(download);
- if (filename == NULL || strlen(filename) == 0) {
+ if (user_data) {
+ filename = (const char*)user_data;
+ } else if (filename == NULL || strlen(filename) == 0) {
filename = "vimprobable_download";
}
path = g_build_filename(g_strdup_printf(DOWNLOADS_PATH), filename, NULL);
@@ -1637,6 +1640,26 @@ fake_key_event(const Arg *a) {
return TRUE;
}
+gboolean
+save_page(const Arg *arg) {
+ WebKitNetworkRequest *request;
+ WebKitDownload *download;
+ const char *uri = webkit_web_view_get_uri(webview);
+ const char *destination = NULL;
+
+ if (uri == NULL || *uri == '\0') {
+ set_error("No URI found to save.");
+ return FALSE;
+ }
+
+ request = webkit_network_request_new(uri);
+ download = webkit_download_new(request);
+ if (arg->s && *arg->s) {
+ destination = arg->s;
+ }
+ webview_download_cb(webview, download, (gpointer *)destination);
+ return TRUE;
+}
gboolean
commandhistoryfetch(const Arg *arg) {
diff --git a/vimprobable2.1 b/vimprobable2.1
index a780e6a..0a8cb79 100644
--- a/vimprobable2.1
+++ b/vimprobable2.1
@@ -254,6 +254,10 @@ Shortcut: d
Print the current URL
+.IP ":w[rite] [filename]"
+
+Save the current document.
+
.SH MODES
Vimprobable is a modal browser. By default, it is in command mode, meaning that
--
1.7.2.5
|