0
0
mirror of https://github.com/rkd77/elinks.git synced 2025-06-30 22:19:29 -04:00

[mujs] scrollByLines

This commit is contained in:
Witold Filipczyk 2025-04-06 19:42:28 +02:00
parent 3d9ec754ac
commit 5e476df4c0

View File

@ -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);