UndoSupport.st
changeset 2136 2accac6ffb0f
parent 1932 7bafb4c076d3
child 3820 d4100babd7c8
--- a/UndoSupport.st	Sun May 03 17:33:39 2009 +0200
+++ b/UndoSupport.st	Mon May 04 16:42:09 2009 +0200
@@ -13,7 +13,7 @@
 
 Object subclass:#UndoSupport
 	instanceVariableNames:'actionPerformer transaction undoList redoList
-		infoOfCurrentTransaction'
+		infoOfCurrentTransaction undoLimit'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Text'
@@ -79,6 +79,14 @@
 
 actionInfo:aString
     infoOfCurrentTransaction := aString
+!
+
+undoLimit
+    ^ undoLimit
+!
+
+undoLimit:something
+    undoLimit := something.
 ! !
 
 !UndoSupport methodsFor:'initialization'!
@@ -89,6 +97,7 @@
 
 initialize
     self resetHistories.
+    "/ undoLimit := 1000.
 !
 
 resetHistories
@@ -126,6 +135,10 @@
             lastAction combineWithNext:actionToAdd.
         ] ifFalse:[
             aList add:actionToAdd.
+            (undoLimit notNil and:[aList size > undoLimit]) ifTrue:[
+                Transcript showCR:'forget old undo-action'.
+                aList removeFirst.
+            ].
         ].
     ].
     infoOfCurrentTransaction := nil.
@@ -250,5 +263,5 @@
 !UndoSupport class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/UndoSupport.st,v 1.9 2008-03-08 10:53:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/UndoSupport.st,v 1.10 2009-05-04 14:42:09 cg Exp $'
 ! !