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

SMJS: Add execute method to the elinks object

It is similar to lua's execute and let's you run a command line in
'non-blocking' mode. Example:

	elinks.keymaps.main["F"] = function () {
		elinks.execute("firefox " + elinks.location);
	};
This commit is contained in:
Jonas Fonseca 2006-06-06 16:30:24 +02:00 committed by Jonas Fonseca
parent 97f9b90e27
commit 4433438f92

View File

@ -87,6 +87,24 @@ elinks_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
return JS_TRUE;
}
static JSBool
elinks_execute(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
unsigned char *string;
if (argc != 1)
return JS_TRUE;
string = jsval_to_string(ctx, &argv[0]);
if (!*string)
return JS_TRUE;
exec_on_terminal(smjs_ses->tab->term, string, "", 0);
undef_to_jsval(ctx, rval);
return JS_TRUE;
}
static const JSClass elinks_class = {
"elinks",
0,
@ -97,6 +115,7 @@ static const JSClass elinks_class = {
static const JSFunctionSpec elinks_funcs[] = {
{ "alert", elinks_alert, 1 },
{ "execute", elinks_execute, 1 },
{ NULL }
};