1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

SMJS: Add elinks.vs

E.g., elinks.vs.plain = 0; elinks.action.rerender(); forces ELinks to
rerender the current document as HTML.
This commit is contained in:
Miciah Dashiel Butler Masters 2006-06-10 18:02:10 +00:00 committed by Miciah Dashiel Butler Masters
parent 1df39d5068
commit 355cbebaad
3 changed files with 40 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "scripting/smjs/globhist.h" #include "scripting/smjs/globhist.h"
#include "scripting/smjs/keybinding.h" #include "scripting/smjs/keybinding.h"
#include "scripting/smjs/load_uri.h" #include "scripting/smjs/load_uri.h"
#include "scripting/smjs/view_state_object.h"
#include "session/location.h" #include "session/location.h"
#include "session/session.h" #include "session/session.h"
#include "session/task.h" #include "session/task.h"
@ -155,6 +156,7 @@ smjs_init_elinks_object(void)
smjs_init_globhist_interface(); smjs_init_globhist_interface();
smjs_init_keybinding_interface(); smjs_init_keybinding_interface();
smjs_init_load_uri_interface(); smjs_init_load_uri_interface();
smjs_init_view_state_interface();
} }
/* If elinks.<method> is defined, call it with the given arguments, /* If elinks.<method> is defined, call it with the given arguments,

View File

@ -10,8 +10,12 @@
#include "ecmascript/spidermonkey/util.h" #include "ecmascript/spidermonkey/util.h"
#include "protocol/uri.h" #include "protocol/uri.h"
#include "scripting/smjs/elinks_object.h"
#include "scripting/smjs/view_state_object.h" #include "scripting/smjs/view_state_object.h"
#include "scripting/smjs/core.h" #include "scripting/smjs/core.h"
#include "session/history.h"
#include "session/location.h"
#include "session/session.h"
#include "util/error.h" #include "util/error.h"
#include "util/memory.h" #include "util/memory.h"
#include "viewer/text/vs.h" #include "viewer/text/vs.h"
@ -107,3 +111,35 @@ smjs_get_view_state_object(struct view_state *vs)
return view_state_object; return view_state_object;
} }
static JSBool
smjs_elinks_get_view_state(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *vs_obj;
struct view_state *vs;
*vp = JSVAL_NULL;
if (!smjs_ses) return JS_TRUE;
vs = &cur_loc(smjs_ses)->vs;
if (!vs) return JS_TRUE;
vs_obj = smjs_get_view_state_object(vs);
if (!vs_obj) return JS_TRUE;
*vp = OBJECT_TO_JSVAL(vs_obj);
return JS_TRUE;
}
void
smjs_init_view_state_interface(void)
{
if (!smjs_ctx || !smjs_elinks_object)
return;
JS_DefineProperty(smjs_ctx, smjs_elinks_object, "vs", JSVAL_NULL,
smjs_elinks_get_view_state, JS_PropertyStub,
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
}

View File

@ -5,5 +5,7 @@ struct view_state;
JSObject *smjs_get_view_state_object(struct view_state *vs); JSObject *smjs_get_view_state_object(struct view_state *vs);
void smjs_init_view_state_interface(void);
#endif #endif