Add patches for page marks support - pkgsrc-localpatches - leot's pkgsrc LOCALPATCHES
(HTM) hg clone https://bitbucket.org/iamleot/pkgsrc-localpatches
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) changeset fdd8f268f25e439f9fe179eee665a59327361da5
(DIR) parent 365260758a673458fec948b19a1245f66be5dffe
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Mon, 15 Oct 2018 10:57:23
Add patches for page marks support
Also submitted upstream via:
<https://github.com/fanglingsu/vimb/pull/521>
Diffstat:
wip/vimb3-git/mark-support-man.patch | 35 ++++++++
wip/vimb3-git/mark-support.patch | 140 +++++++++++++++++++++++++++++++++++
2 files changed, 175 insertions(+), 0 deletions(-)
---
diff -r 365260758a67 -r fdd8f268f25e wip/vimb3-git/mark-support-man.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wip/vimb3-git/mark-support-man.patch Mon Oct 15 10:57:23 2018 +0200
@@ -0,0 +1,35 @@
+From 77e2d104c3bcd358ba2fd6f81cd5f9c3eb712c57 Mon Sep 17 00:00:00 2001
+From: Leonardo Taccari <iamleot@gmail.com>
+Date: Mon, 15 Oct 2018 03:19:59 +0200
+Subject: [PATCH] Document marks in the man page, from vimb-2.12
+
+---
+ doc/vimb.1 | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git doc/vimb.1 doc/vimb.1
+index 75410da..ec96c3e 100644
+--- doc/vimb.1
++++ doc/vimb.1
+@@ -189,6 +189,18 @@ Scroll page \fIN\fP steps down.
+ .TP
+ .BI [ N ]k
+ Scroll page \fIN\fP steps up.
++.TP
++.BI m{ a-z }
++Set a page mark {\fIa-z\fP} at the current position on the page.
++Such set marks are only available on the current page;
++if the page is left, all marks will be removed.
++.TP
++.BI '{ a-z }
++Jump to the mark {\fIa-z\fP} on the current page.
++.TP
++.B ''
++Jumps to the position before the latest jump, or where the last "m'" command
++was given.
+ .SS Hinting
+ Hinting in Vimb is how you accomplish the tasks that you would do with the
+ mouse in common mouse-driven browsers: open a URI, yank a URI, save a page and
+--
+2.19.1
+
diff -r 365260758a67 -r fdd8f268f25e wip/vimb3-git/mark-support.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wip/vimb3-git/mark-support.patch Mon Oct 15 10:57:23 2018 +0200
@@ -0,0 +1,140 @@
+From 4428a0c875c7f7c7d378127d57107323b3efc7c0 Mon Sep 17 00:00:00 2001
+From: Leonardo Taccari <iamleot@gmail.com>
+Date: Mon, 15 Oct 2018 01:56:58 +0200
+Subject: [PATCH] Add support for marks, based on vimb-2.12
+
+- Introduce a scroll_top field in State, similar to scroll_percent but in pixel
+- Adjust the webextension to communicate and update scroll_top
+- Implement normal_map()
+---
+ src/ext-proxy.c | 5 +++--
+ src/main.h | 5 +++--
+ src/normal.c | 32 +++++++++++++++++++++++++++++++-
+ src/webextension/ext-main.c | 8 +++++---
+ 4 files changed, 42 insertions(+), 8 deletions(-)
+
+diff --git src/ext-proxy.c src/ext-proxy.c
+index 4c99bae..51d2eb0 100644
+--- src/ext-proxy.c
++++ src/ext-proxy.c
+@@ -180,16 +180,17 @@ static void on_vertical_scroll(GDBusConnection *connection,
+ const char *interface_name, const char *signal_name,
+ GVariant *parameters, gpointer data)
+ {
+- glong max;
++ glong max, top;
+ guint percent;
+ guint64 pageid;
+ Client *c;
+
+- g_variant_get(parameters, "(ttq)", &pageid, &max, &percent);
++ g_variant_get(parameters, "(ttqt)", &pageid, &max, &percent, &top);
+ c = vb_get_client_for_page_id(pageid);
+ if (c) {
+ c->state.scroll_max = max;
+ c->state.scroll_percent = percent;
++ c->state.scroll_top = top;
+ }
+
+ vb_statusbar_update(c);
+diff --git src/main.h src/main.h
+index 35681a1..56ba9e0 100644
+--- src/main.h
++++ src/main.h
+@@ -154,12 +154,13 @@ struct State {
+
+ #define PROMPT_SIZE 4
+ char prompt[PROMPT_SIZE];/* current prompt ':', 'g;t', '/' including nul */
+- gdouble marks[MARK_SIZE]; /* holds marks set to page with 'm{markchar}' */
++ glong marks[MARK_SIZE]; /* holds marks set to page with 'm{markchar}' */
+ guint input_timer;
+ MessageType input_type;
+ StatusType status_type;
+ glong scroll_max; /* Maxmimum scrollable height of the document. */
+- guint scroll_percent; /* Current position of the viewport in document. */
++ 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. */
+
+ char *reg[REG_SIZE]; /* holds the yank buffers */
+diff --git src/normal.c src/normal.c
+index a2028a7..02ba27b 100644
+--- src/normal.c
++++ src/normal.c
+@@ -521,7 +521,37 @@ static VbResult normal_input_open(Client *c, const NormalCmdInfo *info)
+
+ static VbResult normal_mark(Client *c, const NormalCmdInfo *info)
+ {
+- /* TODO implement setting of marks - we need to get the position in the pagee from the Webextension */
++ glong current;
++ char *js, *mark;
++ int idx;
++
++ /* check if the second char is a valid mark char */
++ if (!(mark = strchr(MARK_CHARS, info->key2))) {
++ return RESULT_ERROR;
++ }
++
++ /* get the index of the mark char */
++ idx = mark - MARK_CHARS;
++
++ if ('m' == info->key) {
++ c->state.marks[idx] = c->state.scroll_top;
++ } else {
++ /* check if the mark was set */
++ if ((int)(c->state.marks[idx] - .5) < 0) {
++ return RESULT_ERROR;
++ }
++
++ current = c->state.scroll_top;
++
++ /* jump to the location */
++ js = g_strdup_printf("window.scroll(window.screenLeft,%ld);", c->state.marks[idx]);
++ ext_proxy_eval_script(c, js, NULL);
++ g_free(js);
++
++ /* save previous adjust as last position */
++ c->state.marks[MARK_TICK] = current;
++ }
++
+ return RESULT_COMPLETE;
+ }
+
+diff --git src/webextension/ext-main.c src/webextension/ext-main.c
+index 10c525c..998a329 100644
+--- src/webextension/ext-main.c
++++ src/webextension/ext-main.c
+@@ -80,6 +80,7 @@ static const char introspection_xml[] =
+ " <arg type='t' name='page_id' direction='out'/>"
+ " <arg type='t' name='max' direction='out'/>"
+ " <arg type='q' name='percent' direction='out'/>"
++ " <arg type='t' name='top' direction='out'/>"
+ " </signal>"
+ " <method name='SetHeaderSetting'>"
+ " <arg type='s' name='headers' direction='in'/>"
+@@ -249,7 +250,7 @@ static void on_document_scroll(WebKitDOMEventTarget *target, WebKitDOMEvent *eve
+
+ if (doc) {
+ WebKitDOMElement *body, *de;
+- glong max = 0, scrollTop, scrollHeight, clientHeight;
++ glong max = 0, top = 0, scrollTop, scrollHeight, clientHeight;
+ guint percent = 0;
+
+ de = webkit_dom_document_get_document_element(doc);
+@@ -276,10 +277,11 @@ static void on_document_scroll(WebKitDOMEventTarget *target, WebKitDOMEvent *eve
+ max = scrollHeight - clientHeight;
+ if (max > 0) {
+ percent = (guint)(0.5 + (scrollTop * 100 / max));
++ top = scrollTop;
+ }
+
+- dbus_emit_signal("VerticalScroll", g_variant_new("(ttq)",
+- webkit_web_page_get_id(page), max, percent));
++ dbus_emit_signal("VerticalScroll", g_variant_new("(ttqt)",
++ webkit_web_page_get_id(page), max, percent, top));
+ }
+ }
+
+--
+2.19.1
+