undo - combine multiple-single keystrokes
authorClaus Gittinger <cg@exept.de>
Tue, 19 Apr 2005 12:01:01 +0200
changeset 1549 b35755379765
parent 1548 036dd8e862d0
child 1550 7710a4b44cc9
undo - combine multiple-single keystrokes
UndoSupport.st
--- a/UndoSupport.st	Tue Apr 12 17:15:39 2005 +0200
+++ b/UndoSupport.st	Tue Apr 19 12:01:01 2005 +0200
@@ -107,16 +107,27 @@
 !
 
 closeTransactionAndAddTo:aList
-    |actionToAdd|
+    |actionToAdd lastAction canCombine|
 
     transaction notEmptyOrNil ifTrue:[
+        canCombine := false.
         (transaction size == 1 and:[infoOfCurrentTransaction isNil]) ifTrue:[
-            actionToAdd := transaction first
+            actionToAdd := transaction first.
+
+            aList notEmpty ifTrue:[
+                lastAction := aList last.
+                canCombine := lastAction canCombineWithNext:actionToAdd.
+            ].
         ] ifFalse:[
             actionToAdd := (CompoundAction new actions:transaction).
             actionToAdd info:infoOfCurrentTransaction.
         ].
-        aList add:actionToAdd.
+
+        canCombine ifTrue:[
+            lastAction combineWithNext:actionToAdd.
+        ] ifFalse:[
+            aList add:actionToAdd.
+        ].
     ].
     infoOfCurrentTransaction := nil.
     transaction := nil
@@ -225,8 +236,14 @@
     actions reverseDo:[:each | each executeIn:editor ]
 ! !
 
+!UndoSupport::CompoundAction methodsFor:'queries'!
+
+canCombineWithNext:nextAction
+    ^ false.
+! !
+
 !UndoSupport class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/UndoSupport.st,v 1.5 2005-02-25 11:44:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/UndoSupport.st,v 1.6 2005-04-19 10:01:01 cg Exp $'
 ! !