aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-11 18:17:51 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-11 18:17:51 +0100
commit669bdf6ea9739a26d92e745b71945fea43968dea (patch)
tree6dbb0516b7d0ca168a9e01cfc86d39f50e2c34e3
parent891ee79bc292705dd56035a5dca20d8ff6371e50 (diff)
downloadsciteco-669bdf6ea9739a26d92e745b71945fea43968dea.tar.gz
States::is_string() to check whether current state is a string-state
-rw-r--r--src/cmdline.cpp15
-rw-r--r--src/parser.h6
2 files changed, 14 insertions, 7 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index a2362bd..2e43e40 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -107,9 +107,10 @@ cmdline_keypress(gchar key)
macro_pc = repl_pos-1;
} else {
/*
- * Undo tokens may have been emitted (or had to be)
- * before the exception is thrown. They must be
- * executed so as if the character had never been
+ * Undo tokens may have been emitted
+ * (or had to be) before the exception
+ * is thrown. They must be executed so
+ * as if the character had never been
* inserted.
*/
undo.pop(cmdline_pos);
@@ -153,18 +154,18 @@ process_edit_cmd(gchar key)
break;
case CTL_KEY('W'):
- if (dynamic_cast<StateExpectString *>(States::current)) {
+ if (States::is_string()) {
gchar wchars[interface.ssm(SCI_GETWORDCHARS)];
interface.ssm(SCI_GETWORDCHARS, 0, (sptr_t)wchars);
/* rubout non-word chars */
do
undo.pop(macro_pc--);
- while (dynamic_cast<StateExpectString *>(States::current) &&
+ while (States::is_string() &&
!strchr(wchars, cmdline[macro_pc-1]));
/* rubout word chars */
- while (dynamic_cast<StateExpectString *>(States::current) &&
+ while (States::is_string() &&
strchr(wchars, cmdline[macro_pc-1]))
undo.pop(macro_pc--);
} else if (cmdline_len) {
@@ -177,7 +178,7 @@ process_edit_cmd(gchar key)
break;
case CTL_KEY('T'):
- if (dynamic_cast<StateExpectString *>(States::current)) {
+ if (States::is_string()) {
const gchar *filename = last_occurrence(strings[0]);
gchar *new_chars = filename_complete(filename);
diff --git a/src/parser.h b/src/parser.h
index e810fa4..13b99d4 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -242,6 +242,12 @@ namespace States {
extern StateInsert insert;
extern State *current;
+
+ static inline bool
+ is_string()
+ {
+ return dynamic_cast<StateExpectString *>(current);
+ }
}
extern enum Mode {