From e6d7baf883ef3e75a9e5bd616a59df9405f63872 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 11 Nov 2012 07:49:06 +0100 Subject: added O...$ GOTO command --- goto.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'goto.cpp') diff --git a/goto.cpp b/goto.cpp index ddbc69f..01786f1 100644 --- a/goto.cpp +++ b/goto.cpp @@ -4,13 +4,15 @@ #include #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_PARSE_ONLY; + } + } + + g_strfreev(labels); + return &States::start; +} -- cgit v1.2.3