aboutsummaryrefslogtreecommitdiffhomepage
path: root/goto.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-11 07:49:06 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-11 07:49:06 +0100
commite6d7baf883ef3e75a9e5bd616a59df9405f63872 (patch)
treeec19062976da870780c50bc47056c0ab74c733eb /goto.cpp
parentef8196da650f70758e1366cb7be1a799f1455f8e (diff)
downloadsciteco-e6d7baf883ef3e75a9e5bd616a59df9405f63872.tar.gz
added <n>O...$ GOTO command
Diffstat (limited to 'goto.cpp')
-rw-r--r--goto.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/goto.cpp b/goto.cpp
index ddbc69f..01786f1 100644
--- a/goto.cpp
+++ b/goto.cpp
@@ -4,13 +4,15 @@
#include <glib/gprintf.h>
#include "sciteco.h"
+#include "expressions.h"
#include "parser.h"
#include "undo.h"
#include "rbtree.h"
#include "goto.h"
namespace States {
- StateLabel label;
+ StateLabel label;
+ StateGotoCmd gotocmd;
}
static gchar *skip_label = NULL;
@@ -199,3 +201,32 @@ StateLabel::custom(gchar chr)
return this;
}
+
+State *
+StateGotoCmd::done(const gchar *str)
+{
+ gint64 value;
+ gchar **labels;
+
+ BEGIN_EXEC(&States::start);
+
+ value = expressions.pop_num_calc();
+ labels = g_strsplit(str, ",", -1);
+
+ if (value > 0 && value <= g_strv_length(labels) && *labels[value-1]) {
+ gint pc = table.find(labels[value-1]);
+
+ if (pc >= 0) {
+ macro_pc = pc;
+ } else {
+ /* skip till label is defined */
+ undo.push_str(skip_label);
+ skip_label = g_strdup(labels[value-1]);
+ undo.push_var<Mode>(mode);
+ mode = MODE_PARSE_ONLY;
+ }
+ }
+
+ g_strfreev(labels);
+ return &States::start;
+}