aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-08 04:39:28 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-08 04:39:28 +0100
commit779bb1654d20af6139f17bdaf9a38bcb75d20965 (patch)
treecc403555d0402e369fbaa9770cc4dbe4a383ea1d
parentb58893781bcb8feeba8c4743ae3d5e6083dc010e (diff)
downloadsciteco-779bb1654d20af6139f17bdaf9a38bcb75d20965.tar.gz
EX command
-rw-r--r--cmdline.cpp8
-rw-r--r--parser.cpp23
-rw-r--r--parser.h9
-rw-r--r--sciteco.h1
4 files changed, 40 insertions, 1 deletions
diff --git a/cmdline.cpp b/cmdline.cpp
index b9c58a0..152adc5 100644
--- a/cmdline.cpp
+++ b/cmdline.cpp
@@ -1,4 +1,5 @@
#include <string.h>
+#include <stdlib.h>
#include <glib.h>
#include <glib/gprintf.h>
@@ -13,6 +14,8 @@ static gchar *macro_echo(const gchar *macro, const gchar *prefix = "");
gchar *cmdline = NULL;
+bool quit_requested = false;
+
void
cmdline_keypress(gchar key)
{
@@ -73,7 +76,10 @@ process_edit_cmd(gchar key)
case '\x1B':
if (cmdline && cmdline[cmdline_len - 1] == '\x1B') {
- /* TODO: exit if previously requested */
+ if (quit_requested) {
+ /* FIXME */
+ exit(EXIT_SUCCESS);
+ }
undo.clear();
goto_table_clear();
diff --git a/parser.cpp b/parser.cpp
index df87b32..61e1398 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -169,6 +169,7 @@ StateStart::StateStart() : State()
transitions['!'] = &states.label;
transitions['^'] = &states.control;
+ transitions['E'] = &states.ecommand;
transitions['I'] = &states.insert;
}
@@ -552,6 +553,28 @@ StateControl::custom(gchar chr)
return &states.start;
}
+StateECommand::StateECommand() : State()
+{
+ transitions['\0'] = this;
+}
+
+State *
+StateECommand::custom(gchar chr)
+{
+ switch (g_ascii_toupper(chr)) {
+ case 'X':
+ BEGIN_EXEC(&states.start);
+ undo.push_var<bool>(quit_requested);
+ quit_requested = true;
+ break;
+
+ default:
+ return NULL;
+ }
+
+ return &states.start;
+}
+
/*
* NOTE: cannot support VideoTECO's <n>I because
* beginning and end of strings must be determined
diff --git a/parser.h b/parser.h
index 2798469..edcece7 100644
--- a/parser.h
+++ b/parser.h
@@ -76,6 +76,14 @@ private:
State *custom(gchar chr);
};
+class StateECommand : public State {
+public:
+ StateECommand();
+
+private:
+ State *custom(gchar chr);
+};
+
class StateInsert : public StateExpectString {
private:
void initial(void);
@@ -91,6 +99,7 @@ extern struct States {
StateStart start;
StateLabel label;
StateControl control;
+ StateECommand ecommand;
StateInsert insert;
} states;
diff --git a/sciteco.h b/sciteco.h
index 88b41cc..e35ce92 100644
--- a/sciteco.h
+++ b/sciteco.h
@@ -9,6 +9,7 @@
#include <Scintilla.h>
extern gchar *cmdline;
+extern bool quit_requested;
void message_display(GtkMessageType type,
const gchar *fmt, ...) G_GNUC_PRINTF(2, 3);