summaryrefslogtreecommitdiffstats
path: root/src/gram.y
diff options
context:
space:
mode:
authorPim Snel <pim@lingewoud.nl>2020-02-05 02:06:03 +0100
committerPim Snel <pim@lingewoud.nl>2020-02-05 02:06:03 +0100
commit865883702c211d882b16afce1c3503a1297926d2 (patch)
tree9d79b84b7555f963cfdc08f667bb73b59c7fdfc5 /src/gram.y
parentabdc22cb5730bf6c846d6e71d363d4bb8e476728 (diff)
add EXECUTE command for making non-interactive scripts more powerfull
Diffstat (limited to 'src/gram.y')
-rwxr-xr-xsrc/gram.y27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gram.y b/src/gram.y
index 5b208ac..f971535 100755
--- a/src/gram.y
+++ b/src/gram.y
@@ -26,6 +26,8 @@
#include "plot.h"
#include "subtotal.h"
+#include "cmds_command.h"
+
void yyerror(char *err); // error routine for yacc (gram.y)
int yylex();
@@ -189,6 +191,7 @@ token S_YANKCOL
%token S_GETFMT
%token S_GETFORMAT
%token S_RECALC
+%token S_EXECUTE
%token S_QUIT
%token S_REBUILD_GRAPH
%token S_PRINT_GRAPH
@@ -699,6 +702,30 @@ command:
eval_result = eval(NULL, $2);
efree($2);
}
+ | S_EXECUTE STRING {
+
+ inputline[0]=L'\0';
+
+ #ifdef HISTORY_FILE
+ commandline_history = (struct history *) create_history(':');
+ load_history(commandline_history, ':'); // load the command history file
+ #endif
+ #ifdef INS_HISTORY_FILE
+ insert_history = (struct history *) create_history('=');
+ load_history(insert_history, '='); // load the insert history file
+ #endif
+
+ (void) swprintf(inputline, BUFFERSIZE, L"%s", $2);
+
+ struct block * auxb = (struct block *) create_buf();
+ addto_buf(auxb, OKEY_ENTER);
+ do_commandmode(auxb);
+ flush_buf(auxb);
+ erase_buf(auxb);
+ auxb = NULL;
+ inputline[0]=L'\0';
+ scxfree($2);
+ }
| S_QUIT {
printf("quitting. unsaved changes will be lost.\n");
shall_quit = 2; // unsaved changes are lost!