diff options
-rw-r--r-- | cmdline.cpp | 8 | ||||
-rw-r--r-- | parser.cpp | 23 | ||||
-rw-r--r-- | parser.h | 9 | ||||
-rw-r--r-- | sciteco.h | 1 |
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(); @@ -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 @@ -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; @@ -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); |