summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-06-11 00:19:51 +0200
committerportix <none@none>2012-06-11 00:19:51 +0200
commit331574cb4efa3f8b39261325acdfeda5f879b4dc (patch)
treeb2868376caba001460f93c94d9dacb0845eab8b2 /src
parentef555fbbc5d82e848cb145ff104c0426f337b9cf (diff)
downloaddwb-331574cb4efa3f8b39261325acdfeda5f879b4dc.zip
New command eval
Diffstat (limited to 'src')
-rw-r--r--src/commands.c9
-rw-r--r--src/commands.h1
-rw-r--r--src/config.h5
3 files changed, 15 insertions, 0 deletions
diff --git a/src/commands.c b/src/commands.c
index 41a61673..ebb60200 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -29,6 +29,7 @@
#include "adblock.h"
#include "download.h"
#include "js.h"
+#include "scripts.h"
inline static int
dwb_floor(double x) {
@@ -867,4 +868,12 @@ commands_sanitize(KeyMap *km, Arg *arg) {
dwb_set_normal_message(dwb.state.fview, true, "Sanitized %s", arg->p ? arg->p : "all");
return STATUS_OK;
}/*}}}*/
+DwbStatus
+commands_eval(KeyMap *km, Arg *arg) {
+ if (arg->p != NULL) {
+ if (scripts_execute_one(arg->p))
+ return STATUS_OK;
+ }
+ return STATUS_ERROR;
+}
/*}}}*/
diff --git a/src/commands.h b/src/commands.h
index 37c87ece..ce26e0e2 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -92,5 +92,6 @@ DwbStatus commands_cancel_download(KeyMap *, Arg *);
DwbStatus commands_normal_mode(KeyMap *, Arg *);
DwbStatus commands_dump(KeyMap *, Arg *);
DwbStatus commands_sanitize(KeyMap *, Arg *);
+DwbStatus commands_eval(KeyMap *, Arg *);
#endif
diff --git a/src/config.h b/src/config.h
index f9464eef..099167d4 100644
--- a/src/config.h
+++ b/src/config.h
@@ -181,6 +181,7 @@ static KeyValue KEYS[] = {
{ "local_set", { NULL, 0, 0 }, },
{ "dump", { NULL, 0, 0 }, },
{ "sanitize", { NULL, 0, 0 }, },
+ { "eval", { NULL, 0, 0 }, },
};
/* FUNCTION_MAP{{{*/
@@ -201,6 +202,10 @@ static FunctionMap FMAP [] = {
(Func)commands_execute_javascript, NULL, ALWAYS_SM,
{ .p = NULL }, EP_NONE, { "js", "exja", NULL }, },
+ { { "eval", "Execute a javascript snippet that uses the internal jsapi", }, CP_COMMANDLINE,
+ (Func)commands_eval, NULL, ALWAYS_SM,
+ { .p = NULL }, EP_NONE, { NULL }, },
+
{ { "set", "Set a setting", }, CP_COMMANDLINE,
(Func)commands_set, "Invalid value", POST_SM,
{ .p = NULL, .n = SET_GLOBAL }, EP_NONE, { NULL }, },