From d8a316514c03d85b771a9dce4a8a51b875d955b3 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 4 Dec 2012 17:29:01 +0100 Subject: autoconf preparation: move everything into src/ subdir --- undo.h | 134 ----------------------------------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 undo.h (limited to 'undo.h') diff --git a/undo.h b/undo.h deleted file mode 100644 index 43692e9..0000000 --- a/undo.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef __UNDO_H -#define __UNDO_H - -#include - -#include -#include - -#include - -#ifdef DEBUG -#include "parser.h" -#endif - -class UndoToken { -public: - SLIST_ENTRY(UndoToken) tokens; - - gint pos; - - virtual ~UndoToken() {} - - virtual void run() = 0; -}; - -class UndoTokenMessage : public UndoToken { - unsigned int iMessage; - uptr_t wParam; - sptr_t lParam; - -public: - UndoTokenMessage(unsigned int _iMessage, - uptr_t _wParam = 0, sptr_t _lParam = 0) - : UndoToken(), iMessage(_iMessage), - wParam(_wParam), lParam(_lParam) {} - - void run(void); -}; - -template -class UndoTokenVariable : public UndoToken { - Type *ptr; - Type value; - -public: - UndoTokenVariable(Type &variable, Type _value) - : UndoToken(), ptr(&variable), value(_value) {} - - void - run(void) - { -#ifdef DEBUG - if ((State **)ptr == &States::current) - g_printf("undo state -> %p\n", (void *)value); -#endif - *ptr = value; - } -}; - -class UndoTokenString : public UndoToken { - gchar **ptr; - gchar *str; - -public: - UndoTokenString(gchar *&variable, gchar *_str) - : UndoToken(), ptr(&variable) - { - str = _str ? g_strdup(_str) : NULL; - } - - ~UndoTokenString() - { - g_free(str); - } - - void - run(void) - { - g_free(*ptr); - *ptr = str; - str = NULL; - } -}; - -extern class UndoStack { - SLIST_HEAD(Head, UndoToken) head; - -public: - bool enabled; - - UndoStack(bool _enabled = false) : enabled(_enabled) - { - SLIST_INIT(&head); - } - ~UndoStack(); - - void push(UndoToken *token); - - void push_msg(unsigned int iMessage, - uptr_t wParam = 0, sptr_t lParam = 0); - - template - inline Type & - push_var(Type &variable, Type value) - { - push(new UndoTokenVariable(variable, value)); - return variable; - } - - template - inline Type & - push_var(Type &variable) - { - return push_var(variable, variable); - } - - inline gchar *& - push_str(gchar *&variable, gchar *str) - { - push(new UndoTokenString(variable, str)); - return variable; - } - inline gchar *& - push_str(gchar *&variable) - { - return push_str(variable, variable); - } - - void pop(gint pos); - - void clear(void); -} undo; - -#endif \ No newline at end of file -- cgit v1.2.3