diff --git a/src/js/mujs/window.c b/src/js/mujs/window.c index 0010375b8..d661cddb4 100644 --- a/src/js/mujs/window.c +++ b/src/js/mujs/window.c @@ -56,6 +56,7 @@ #include "viewer/text/draw.h" #include "viewer/text/form.h" #include "viewer/text/link.h" +#include "viewer/text/view.h" #include "viewer/text/vs.h" struct listener { @@ -530,6 +531,23 @@ end: js_pushboolean(J, ret); } +static void +mjs_window_scrollByLines(js_State *J) +{ +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); +#endif + struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J); + struct view_state *vs = interpreter->vs; + struct document_view *doc_view = vs->doc_view; + struct session *ses = doc_view->session; + int steps = js_toint32(J, 1); + + vertical_scroll(ses, doc_view, steps); + + js_pushundefined(J); +} + static void mjs_window_setInterval(js_State *J) { @@ -829,6 +847,7 @@ mjs_window_init(js_State *J) addmethod(J, "window.open", mjs_window_open, 3); addmethod(J, "window.postMessage", mjs_window_postMessage, 3); addmethod(J, "window.removeEventListener", mjs_window_removeEventListener, 3); + addmethod(J, "window.scrollByLines", mjs_window_scrollByLines, 1); addmethod(J, "window.setInterval", mjs_window_setInterval, 2); addmethod(J, "window.setTimeout", mjs_window_setTimeout, 2); addmethod(J, "window.toString", mjs_window_toString, 0); @@ -878,6 +897,7 @@ mjs_push_window(js_State *J, struct view_state *vs) addmethod(J, "window.open", mjs_window_open, 3); addmethod(J, "window.postMessage", mjs_window_postMessage, 3); addmethod(J, "window.removeEventListener", mjs_window_removeEventListener, 3); + addmethod(J, "window.scrollByLines", mjs_window_scrollByLines, 1); addmethod(J, "window.setInterval", mjs_window_setInterval, 2); addmethod(J, "window.setTimeout", mjs_window_setTimeout, 2); addmethod(J, "window.toString", mjs_window_toString, 0);