better info of replace action (compound-undo-action has info, too)
authorClaus Gittinger <cg@exept.de>
Fri, 25 Feb 2005 11:56:35 +0100
changeset 3127 29767bf8a215
parent 3126 2ba9a9c73f99
child 3128 a800566f5662
better info of replace action (compound-undo-action has info, too)
EditTextView.st
--- a/EditTextView.st	Wed Feb 23 17:39:32 2005 +0100
+++ b/EditTextView.st	Fri Feb 25 11:56:35 2005 +0100
@@ -2728,7 +2728,8 @@
         lastString := sel.
         self deleteSelection.
         replacing := true.
-        lastReplacement := ''
+        lastReplacement := ''.
+        undoSupport actionInfo:'replace'.
     ].
 
     (something isMemberOf:Character) ifTrue:[
@@ -5720,64 +5721,67 @@
         ^ false
     ].
 
-    s := lastString asString.
-
-    "remove final cr"
-    (s endsWith:Character cr) ifTrue:[s := s copyWithoutLast:1].
-"/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
-    savedSelectStyle := selectStyle.
-    selectStyle := nil.
-
-    sel := self selection.
-
-    "if we are already there (after a find), ommit search"
-
-    (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
-        l := selectionStartLine "cursorLine". 
-        c := selectionStartCol "cursorCol".
-        self deleteSelection.
-        lastReplacement notNil ifTrue:[
-            self insertLines:lastReplacement asStringCollection withCR:false.
-            self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
+    self undoableDo:[
+        s := lastString asString.
+
+        "remove final cr"
+        (s endsWith:Character cr) ifTrue:[s := s copyWithoutLast:1].
+    "/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
+        savedSelectStyle := selectStyle.
+        selectStyle := nil.
+
+        sel := self selection.
+
+        "if we are already there (after a find), ommit search"
+
+        (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
+            l := selectionStartLine "cursorLine". 
+            c := selectionStartCol "cursorCol".
+            self deleteSelection.
+            lastReplacement notNil ifTrue:[
+                self insertLines:lastReplacement asStringCollection withCR:false.
+                self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
+            ].
+            selectStyle := savedSelectStyle.
+            ^ true
+        ].
+        startColForSearch := cursorCol.
+        sel isNil ifTrue:[
+            startColForSearch := startColForSearch - 1
         ].
-        selectStyle := savedSelectStyle.
-        ^ true
-    ].
-    startColForSearch := cursorCol.
-    sel isNil ifTrue:[
-        startColForSearch := startColForSearch - 1
-    ].
-    self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch 
-        ifFound:
-            [
-                :line :col |
-
-                |repl|
-
-                self selectFromLine:line col:col
-                             toLine:line col:(col + s size - 1).
-                self makeLineVisible:line.
-
-                self deleteSelection.
-                lastReplacement notNil ifTrue:[
-                    lastReplacement isString ifFalse:[
-                        repl := lastReplacement asString "withoutSpaces"
-                    ] ifTrue:[
-                        repl := lastReplacement "withoutSpaces".
+        self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch 
+            ifFound:
+                [
+                    :line :col |
+
+                    |repl|
+
+                    self selectFromLine:line col:col
+                                 toLine:line col:(col + s size - 1).
+                    self makeLineVisible:line.
+
+                    self deleteSelection.
+                    lastReplacement notNil ifTrue:[
+                        lastReplacement isString ifFalse:[
+                            repl := lastReplacement asString "withoutSpaces"
+                        ] ifTrue:[
+                            repl := lastReplacement "withoutSpaces".
+                        ].
+                        self insertLines:repl asStringCollection withCR:false.
+                        self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
+                        undoSupport actionInfo:'replace'.
                     ].
-                    self insertLines:repl asStringCollection withCR:false.
-                    self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
+                    selectStyle := savedSelectStyle.
+                    ^ true
+                ] 
+           ifAbsent:
+                [
+                    self sensor compressKeyPressEventsWithKey:#Again.
+                    self showNotFound.
+                    selectStyle := savedSelectStyle.
+                    ^ false
                 ].
-                selectStyle := savedSelectStyle.
-                ^ true
-            ] 
-       ifAbsent:
-            [
-                self sensor compressKeyPressEventsWithKey:#Again.
-                self showNotFound.
-                selectStyle := savedSelectStyle.
-                ^ false
-            ].
+    ].
 
     ^ true.
 
@@ -5966,5 +5970,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.366 2004-11-30 11:55:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.367 2005-02-25 10:56:35 cg Exp $'
 ! !