diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-08 18:17:19 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-08 18:17:19 +0100 |
commit | 16614be0a5dea0613fedb6bbbb9f0dd8879905a2 (patch) | |
tree | a942507f90d669a3432f0177592e6e59345483f2 | |
parent | 779bb1654d20af6139f17bdaf9a38bcb75d20965 (diff) | |
download | sciteco-16614be0a5dea0613fedb6bbbb9f0dd8879905a2.tar.gz |
set UndoToken position only when it is required (undo enabled)
-rw-r--r-- | undo.cpp | 19 | ||||
-rw-r--r-- | undo.h | 15 |
2 files changed, 12 insertions, 22 deletions
@@ -10,8 +10,6 @@ UndoStack undo; -UndoToken::UndoToken() : pos(strlen(cmdline)) {} - void UndoTokenMessage::run(void) { @@ -19,20 +17,21 @@ UndoTokenMessage::run(void) } void -UndoStack::push_msg(unsigned int iMessage, uptr_t wParam, sptr_t lParam) +UndoStack::push(UndoToken *token) { - push(new UndoTokenMessage(iMessage, wParam, lParam)); + if (enabled) { + token->pos = strlen(cmdline); + SLIST_INSERT_HEAD(&head, token, tokens); + } else { + delete token; + } } -#if 0 -template <typename Type> void -UndoStack::push_var(Type &variable, Type value) +UndoStack::push_msg(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { - UndoToken *token = new UndoTokenVariable<Type>(variable, value); - SLIST_INSERT_HEAD(&head, token, tokens); + push(new UndoTokenMessage(iMessage, wParam, lParam)); } -#endif void UndoStack::pop(gint pos) @@ -14,8 +14,6 @@ public: gint pos; - UndoToken(); - virtual void run() = 0; }; @@ -75,25 +73,18 @@ public: }; extern class UndoStack { - SLIST_HEAD(undo_head, UndoToken) head; + SLIST_HEAD(Head, UndoToken) head; public: bool enabled; - UndoStack(bool _enabled = true) : enabled(_enabled) + UndoStack(bool _enabled = false) : enabled(_enabled) { SLIST_INIT(&head); } ~UndoStack(); - inline void - push(UndoToken *token) - { - if (enabled) - SLIST_INSERT_HEAD(&head, token, tokens); - else - delete token; - } + void push(UndoToken *token); void push_msg(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0); |