mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -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:
parent
97f9b90e27
commit
4433438f92
@ -87,6 +87,24 @@ elinks_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||||||
return JS_TRUE;
|
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 = {
|
static const JSClass elinks_class = {
|
||||||
"elinks",
|
"elinks",
|
||||||
0,
|
0,
|
||||||
@ -97,6 +115,7 @@ static const JSClass elinks_class = {
|
|||||||
|
|
||||||
static const JSFunctionSpec elinks_funcs[] = {
|
static const JSFunctionSpec elinks_funcs[] = {
|
||||||
{ "alert", elinks_alert, 1 },
|
{ "alert", elinks_alert, 1 },
|
||||||
|
{ "execute", elinks_execute, 1 },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user