aboutsummaryrefslogtreecommitdiffhomepage
path: root/undo.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-08 01:20:37 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-08 01:20:37 +0100
commit7dbb2831b81ff0174054d30b1fc105b2113c272d (patch)
treefde5c878e2c9a89e6f41c8535034e1b16927c154 /undo.h
parent1707fcabca80e2e664bef9c02ec5cc9d793ce37b (diff)
downloadsciteco-7dbb2831b81ff0174054d30b1fc105b2113c272d.tar.gz
added support for labels, including the goto label table
* uses BSD tree macros, might later be abstracted to a C++ table class
Diffstat (limited to 'undo.h')
-rw-r--r--undo.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/undo.h b/undo.h
index 17a8ba8..aeefb09 100644
--- a/undo.h
+++ b/undo.h
@@ -4,6 +4,7 @@
#include <bsd/sys/queue.h>
#include <glib.h>
+#include <glib/gprintf.h>
#include <Scintilla.h>
@@ -48,6 +49,31 @@ public:
}
};
+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(undo_head, UndoToken) head;
@@ -86,6 +112,17 @@ public:
push_var<Type>(variable, variable);
}
+ inline void
+ push_str(gchar *&variable, gchar *str)
+ {
+ push(new UndoTokenString(variable, str));
+ }
+ inline void
+ push_str(gchar *&variable)
+ {
+ push_str(variable, variable);
+ }
+
void pop(gint pos);
} undo;