aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-11 20:28:12 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-11 20:28:12 +0100
commit59eb0628db77e1145db797406e4de9f97b70d8e2 (patch)
tree5d797e99a5081e750cf906fe620247d5fa3e7fb7 /parser.cpp
parent8c6c6afe144adca0635edd0438b9889b3c3df6e4 (diff)
downloadsciteco-59eb0628db77e1145db797406e4de9f97b70d8e2.tar.gz
<x,y>Xq command, automatic profile munging, explicit munging, commandline option processing, unhandled commandline options in default buffer
Diffstat (limited to 'parser.cpp')
-rw-r--r--parser.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/parser.cpp b/parser.cpp
index 83a94d5..6365277 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -2,6 +2,7 @@
#include <glib.h>
#include <glib/gprintf.h>
+#include <glib/gstdio.h>
#include "sciteco.h"
#include "undo.h"
@@ -63,6 +64,31 @@ macro_execute(const gchar *macro)
return true;
}
+bool
+file_execute(const gchar *filename)
+{
+ gchar *macro, *p = NULL;
+ bool rc;
+
+ macro_pc = 0;
+ States::current = &States::start;
+
+ if (!g_file_get_contents(filename, &macro, NULL, NULL))
+ return false;
+ /* only when executing files, ignore Hash-Bang line */
+ if (macro[0] == '#')
+ p = MAX(strchr(macro, '\r'), strchr(macro, '\n'));
+
+ rc = macro_execute(p ? p+1 : macro);
+ g_free(macro);
+ if (!rc)
+ return false;
+
+ macro_pc = 0;
+ States::current = &States::start;
+ return true;
+}
+
State::State()
{
for (guint i = 0; i < G_N_ELEMENTS(transitions); i++)
@@ -310,6 +336,7 @@ StateStart::StateStart() : State()
transitions['U'] = &States::setqreginteger;
transitions['%'] = &States::increaseqreg;
transitions['M'] = &States::macro;
+ transitions['X'] = &States::copytoqreg;
}
void