From 59eb0628db77e1145db797406e4de9f97b70d8e2 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 11 Nov 2012 20:28:12 +0100 Subject: Xq command, automatic profile munging, explicit munging, commandline option processing, unhandled commandline options in default buffer --- parser.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'parser.cpp') diff --git a/parser.cpp b/parser.cpp index 83a94d5..6365277 100644 --- a/parser.cpp +++ b/parser.cpp @@ -2,6 +2,7 @@ #include #include +#include #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, ¯o, 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 -- cgit v1.2.3