From ec510eda5f080d39906c396a36cba89188031640 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 20 Nov 2012 00:43:18 +0100 Subject: local Q-Register tables; :M command * munged files use the same local Q-Registers as commandline * :M calls macro without new set of local registers (local register names refer to the parent macro level) * only .x names accepted at the moment. for string building characters, this will like stay that way (cannot refer to extended/long names) --- qbuffers.h | 59 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'qbuffers.h') diff --git a/qbuffers.h b/qbuffers.h index ce2645c..df05c08 100644 --- a/qbuffers.h +++ b/qbuffers.h @@ -83,7 +83,7 @@ public: virtual void edit(void); virtual void undo_edit(void); - void execute(void) throw (State::Error); + void execute(bool locals = true) throw (State::Error); bool load(const gchar *filename); inline void @@ -107,21 +107,23 @@ public: void edit(void); }; -extern class QRegisterTable : public RBTree { +class QRegisterTable : public RBTree { +public: + QRegisterTable() : RBTree() {} + inline void - initialize_register(const gchar *name) + initialize(const gchar *name) { QRegister *reg = new QRegister(name); insert(reg); /* make sure document is initialized */ reg->get_document(); } - -public: - QRegister *current; - - QRegisterTable() : RBTree(), current(NULL) {} - + inline void + initialize(gchar name) + { + initialize((gchar []){name, '\0'}); + } void initialize(void); inline QRegister * @@ -147,15 +149,7 @@ public: edit(reg); return reg; } - inline void - undo_edit(void) - { - current->dot = interface.ssm(SCI_GETCURRENTPOS); - - undo.push_var(current); - current->undo_edit(); - } -} qregisters; +}; class QRegisterStack { class Entry : public QRegisterData { @@ -459,12 +453,27 @@ namespace States { extern StateCopyToQReg copytoqreg; } -enum Hook { - HOOK_ADD = 1, - HOOK_EDIT, - HOOK_CLOSE, - HOOL_QUIT -}; -void execute_hook(Hook type); +namespace QRegisters { + extern QRegisterTable globals; + extern QRegisterTable *locals; + extern QRegister *current; + + inline void + undo_edit(void) + { + current->dot = interface.ssm(SCI_GETCURRENTPOS); + + undo.push_var(current); + current->undo_edit(); + } + + enum Hook { + HOOK_ADD = 1, + HOOK_EDIT, + HOOK_CLOSE, + HOOK_QUIT + }; + void hook(Hook type); +} #endif -- cgit v1.2.3