Add a patch for experimental normal_view() support. - pkgsrc-localpatches - leot's pkgsrc LOCALPATCHES
(HTM) hg clone https://bitbucket.org/iamleot/pkgsrc-localpatches
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) changeset d23f85ce2e8ffa34e648badb3d2a1e4129137de4
(DIR) parent d53ad3ecba6e07ae7540b093db1dd3ecae455c3d
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Mon, 15 Oct 2018 22:56:31
Add a patch for experimental normal_view() support.
Diffstat:
wip/vimb3-git/patch-normal_view_support.patch | 55 +++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
---
diff -r d53ad3ecba6e -r d23f85ce2e8f wip/vimb3-git/patch-normal_view_support.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wip/vimb3-git/patch-normal_view_support.patch Mon Oct 15 22:56:31 2018 +0200
@@ -0,0 +1,55 @@
+Add experimental support for normal_view_source()
+
+diff --git src/main.h src/main.h
+index 56ba9e0..656a029 100644
+--- src/main.h
++++ src/main.h
+@@ -162,6 +162,7 @@ struct State {
+ guint scroll_percent; /* Current position of the viewport in document (percent). */
+ glong scroll_top; /* Current position of the viewport in document (pixel). */
+ char *title; /* Window title of the client. */
++ gboolean view_source; /* indicates if currently viewing the source */
+
+ char *reg[REG_SIZE]; /* holds the yank buffers */
+ /* TODO rename to reg_{enabled,current} */
+diff --git src/normal.c src/normal.c
+index 02ba27b..b49823b 100644
+--- src/normal.c
++++ src/normal.c
+@@ -743,7 +743,35 @@ 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 */
++ char *js;
++
++ if (c->state.view_source) {
++ js = g_strdup("document.documentElement.innerHTML = " \
++ "document.documentElement.innerHTML" \
++ ".replace(/^<head><\\/head><body><pre><code>/, '')" \
++ ".replace(/&/g, '&')" \
++ ".replace(/</g, '<')" \
++ ".replace(/>/g, '>')" \
++ ".replace(/"/g, '\"')" \
++ ".replace(/'/g, \"'\")" \
++ ".replace(/<\\/code><\\/pre><\\/body>$/, '');");
++ c->state.view_source = FALSE;
++ } else {
++ js = g_strdup("document.documentElement.innerHTML = " \
++ "\"<head><\\/head><body><pre><code>\" + " \
++ "document.documentElement.innerHTML" \
++ ".replace(/&/g, '&')" \
++ ".replace(/</g, '<')" \
++ ".replace(/>/g, '>')" \
++ ".replace(/\"/g, '"')" \
++ ".replace(/'/g, ''');"
++ " + \"</code></pre></body>\"");
++ c->state.view_source = TRUE;
++ }
++
++ ext_proxy_eval_script(c, js, NULL);
++ g_free(js);
++
+ return RESULT_COMPLETE;
+ }
+