- 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(), mostly based on vimb-2.12
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);
#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 */
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;
}
" <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'/>"
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);
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));
}
}