diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 02:45:56 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 02:54:09 +0100 |
commit | 2789e5da50987b908a4aa5758a17c86570d94d63 (patch) | |
tree | a60f11f3b82ff3d7ff0a07bf576f851f68165266 /src/parser.cpp | |
parent | 4aa51b925f5364511173c74277b78d2984e37218 (diff) | |
download | sciteco-2789e5da50987b908a4aa5758a17c86570d94d63.tar.gz |
cleaned up usage of the escape control character: introduced CTL_KEY_ESC and CTL_KEY_ESC_STR
* the reason for the CTL_KEY() macro is to get the control character
resulting from a CTRL+Key press -- at least this is how SciTECO
presents these key presses.
It is also a macro and may be resolved to a constant expression,
so it can be used in switch-case statements.
Sometimes it is clearer to use standard C escape sequences (like '\t').
* CTL_KEY('[') for escape is hard to read, so I always used '\x1B' which
is even more cryptic.
Diffstat (limited to 'src/parser.cpp')
-rw-r--r-- | src/parser.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index ce77aaf..1514e24 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -77,7 +77,7 @@ static bool skip_else = false; static gint nest_level = 0; gchar *strings[2] = {NULL, NULL}; -gchar escape_char = '\x1B'; +gchar escape_char = CTL_KEY_ESC; /** * Handles all expected exceptions, converting them to @@ -440,7 +440,7 @@ StateExpectString::custom(gchar chr) undo.push_var(Modifiers::at) = false; switch (escape_char) { - case '\x1B': + case CTL_KEY_ESC: case '{': undo.push_var(escape_char) = g_ascii_toupper(chr); return this; @@ -466,7 +466,7 @@ StateExpectString::custom(gchar chr) undo.push_str(strings[0]) = NULL; if (last) - undo.push_var(escape_char) = '\x1B'; + undo.push_var(escape_char) = CTL_KEY_ESC; nesting = 1; if (string_building) @@ -1024,7 +1024,7 @@ StateStart::custom(gchar chr) "interactive mode"); current_doc_undo_edit(); - QRegisters::globals.edit("\x1B"); + QRegisters::globals.edit(CTL_KEY_ESC_STR); interface.ssm(SCI_BEGINUNDOACTION); interface.ssm(SCI_CLEARALL); @@ -1041,7 +1041,7 @@ StateStart::custom(gchar chr) if (!undo.enabled) throw Error("Command-line editing only possible in " "interactive mode"); - if (QRegisters::current != QRegisters::globals["\x1B"]) + if (QRegisters::current != QRegisters::globals[CTL_KEY_ESC_STR]) throw Error("Command-line replacement only allowed when " "editing the replacement register"); |