Sync with view_source_support branch - pkgsrc-localpatches - leot's pkgsrc LOCALPATCHES
(HTM) hg clone https://bitbucket.org/iamleot/pkgsrc-localpatches
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) changeset 9c7e4aefa20f9ded8099381ad7c4d6f94d499849
(DIR) parent 5b9036d29f00ea286ec876fdcb1966c73a361cff
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sun, 21 Oct 2018 14:39:17
Sync with view_source_support branch
Diffstat:
wip/vimb3-git/patch-view_source_support.patch | 50 ++++++++++++++++----------
1 files changed, 30 insertions(+), 20 deletions(-)
---
diff -r 5b9036d29f00 -r 9c7e4aefa20f wip/vimb3-git/patch-view_source_support.patch
--- a/wip/vimb3-git/patch-view_source_support.patch Sun Oct 21 00:52:42 2018 +0200
+++ b/wip/vimb3-git/patch-view_source_support.patch Sun Oct 21 14:39:17 2018 +0200
@@ -321,10 +321,18 @@
+ g_slice_free(ElementEditorData, eed);
}
diff --git src/normal.c src/normal.c
-index 02ba27b..9796877 100644
+index 02ba27b..689bf1b 100644
--- src/normal.c
+++ src/normal.c
-@@ -446,7 +446,7 @@ static VbResult normal_g_cmd(Client *c, const NormalCmdInfo *info)
+@@ -74,6 +74,7 @@ static VbResult normal_search(Client *c, const NormalCmdInfo *info);
+ static VbResult normal_search_selection(Client *c, const NormalCmdInfo *info);
+ static VbResult normal_view_inspector(Client *c, const NormalCmdInfo *info);
+ static VbResult normal_view_source(Client *c, const NormalCmdInfo *info);
++static void normal_view_source_loaded(WebKitWebResource *resource, GAsyncResult *res, Client *c);
+ static VbResult normal_yank(Client *c, const NormalCmdInfo *info);
+ static VbResult normal_zoom(Client *c, const NormalCmdInfo *info);
+
+@@ -446,7 +447,7 @@ static VbResult normal_g_cmd(Client *c, const NormalCmdInfo *info)
return normal_view_inspector(c, info);
case 'f':
@@ -333,32 +341,34 @@
case 'g':
return normal_scroll(c, info);
-@@ -743,8 +743,26 @@ static VbResult normal_view_inspector(Client *c, const NormalCmdInfo *info)
+@@ -743,10 +744,29 @@ static VbResult normal_view_inspector(Client *c, const NormalCmdInfo *info)
static VbResult normal_view_source(Client *c, const NormalCmdInfo *info)
{
- /* TODO the source mode isn't supported anymore use external editor for this */
-- return RESULT_COMPLETE;
-+ gboolean success;
-+ char *text = NULL;
-+ GVariant *jsreturn;
++ WebKitWebResource *resource;
+
-+ /* get the selected input element */
-+ jsreturn = ext_proxy_eval_script_sync(c, "document.documentElement.innerHTML");
-+ g_variant_get(jsreturn, "(bs)", &success, &text);
-+
-+ if (!success || !text) {
-+ goto error;
++ if ((resource = webkit_web_view_get_main_resource(c->webview)) == NULL) {
++ return RESULT_ERROR;
+ }
+
-+ if (command_spawn_editor(c, &((Arg){0, text}), NULL, NULL)) {
-+ g_free(text);
-+ return RESULT_COMPLETE;
-+ }
++ webkit_web_resource_get_data(resource, NULL,
++ (GAsyncReadyCallback)normal_view_source_loaded, c);
+
-+error:
-+ g_free(text);
-+ return RESULT_ERROR;
+ return RESULT_COMPLETE;
}
++static void normal_view_source_loaded(WebKitWebResource *resource,
++ GAsyncResult *res, Client *c)
++{
++ gsize length;
++ guchar *text = NULL;
++
++ text = webkit_web_resource_get_data_finish(resource, res, &length, NULL);
++ command_spawn_editor(c, &((Arg){0, (char *)text}), NULL, NULL);
++ g_free(text);
++}
++
static VbResult normal_yank(Client *c, const NormalCmdInfo *info)
+ {
+ Arg a = {info->key == 'Y' ? COMMAND_YANK_SELECTION : COMMAND_YANK_URI};