aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qregisters.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qregisters.cpp')
-rw-r--r--src/qregisters.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/qregisters.cpp b/src/qregisters.cpp
index 960b728..2083884 100644
--- a/src/qregisters.cpp
+++ b/src/qregisters.cpp
@@ -354,6 +354,34 @@ QRegisters::hook(Hook type)
* Command states
*/
+StateExpectQReg::StateExpectQReg() : State(), got_local(false)
+{
+ transitions['\0'] = this;
+}
+
+State *
+StateExpectQReg::custom(gchar chr) throw (Error)
+{
+ QRegister *reg;
+
+ if (chr == '.') {
+ undo.push_var(got_local) = true;
+ return this;
+ }
+ chr = g_ascii_toupper(chr);
+
+ if (got_local) {
+ undo.push_var(got_local) = false;
+ reg = (*QRegisters::locals)[chr];
+ } else {
+ reg = QRegisters::globals[chr];
+ }
+ if (!reg)
+ throw InvalidQRegError(chr, got_local);
+
+ return got_register(reg);
+}
+
State *
StatePushQReg::got_register(QRegister *reg) throw (Error)
{