code formatting
authorClaus Gittinger <cg@exept.de>
Tue, 09 Dec 2008 19:49:08 +0100
changeset 3799 f6cbe8d860d5
parent 3798 5c318886e8da
child 3800 380b2ee3b02b
code formatting undo-labels learn: must also learn backspace
EditTextView.st
--- a/EditTextView.st	Tue Dec 09 19:48:03 2008 +0100
+++ b/EditTextView.st	Tue Dec 09 19:49:08 2008 +0100
@@ -2342,21 +2342,23 @@
 
     fn := aDropObject asFilename.
     (fn exists and:[fn isRegularFile]) ifTrue:[
-	answer := Dialog
-		    confirmWithCancel:(resources
-					string:'Drop the Filename (%1) or its Contents ?'
-					with:fn name allBold)
-		    labels:#( 'Cancel' 'Name' 'Contents').
-	answer isNil ifTrue:[ ^ self ].
-	answer ifTrue:[
-	    text := fn contentsOfEntireFile
-	] ifFalse:[
-	    text := fn pathName
-	].
+        answer := Dialog
+                    confirmWithCancel:(resources
+                                        string:'Drop the Filename (%1) or its Contents ?'
+                                        with:fn name allBold)
+                    labels:#( 'Cancel' 'Name' 'Contents').
+        answer isNil ifTrue:[ ^ self ].
+        answer ifTrue:[
+            text := fn contentsOfEntireFile
+        ] ifFalse:[
+            text := fn pathName
+        ].
     ] ifFalse:[
-	text := obj asString
-    ].
-    self undoablePaste:text info:'drop file'.
+        text := obj asString
+    ].
+    self 
+        undoablePaste:text 
+        info:'Drop File'.
 
     "Created: / 13-10-2006 / 17:38:31 / cg"
     "Modified: / 28-07-2007 / 13:27:09 / cg"
@@ -2369,17 +2371,19 @@
     |text|
 
     (aDropObject isFileObject) ifTrue:[
-	self dropFileObject:aDropObject
+        self dropFileObject:aDropObject
     ] ifFalse:[
-	aDropObject isTextObject ifTrue:[
-	    text := aDropObject theObject.
-	    text isStringCollection ifTrue:[
-		text := text asStringWithoutFinalCR
-	    ].
-	] ifFalse:[
-	    text := aDropObject theObject asString
-	].
-	self undoablePaste:text info:'drop'.
+        aDropObject isTextObject ifTrue:[
+            text := aDropObject theObject.
+            text isStringCollection ifTrue:[
+                text := text asStringWithoutFinalCR
+            ].
+        ] ifFalse:[
+            text := aDropObject theObject asString
+        ].
+        self 
+            undoablePaste:text 
+            info:'Drop'.
     ].
 
     "Created: / 13-10-2006 / 17:37:05 / cg"
@@ -2686,13 +2690,19 @@
 
     |wasOn beginCol beginLine endCol endLine|
 
+    self checkModificationsAllowed ifFalse:[ ^ self].
+
     wasOn := self hideCursor.
-    endCol := cursorCol-1.
-    endLine := cursorLine.
-    self cursorToPreviousWord.
-    beginCol := cursorCol.
-    beginLine := cursorLine.
-    self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
+    self 
+        undoableDo:[
+            endCol := cursorCol-1.
+            endLine := cursorLine.
+            self cursorToPreviousWord.
+            beginCol := cursorCol.
+            beginLine := cursorLine.
+            self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
+        ] 
+        info:'Delete Word'.
     wasOn ifTrue:[ self showCursor ].
 
     "Modified: / 22.2.2000 / 23:59:04 / cg"
@@ -4272,7 +4282,7 @@
                           #LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode
                           #'F*' #'f*')>
 
-    |fKeyMacros shiftPressed ctrlPressed i event cmdMacro|
+    |fKeyMacros shiftPressed ctrlPressed i event cmdMacro macroName|
 
     event := WindowGroup lastEventQuerySignal query.
     shiftPressed := event hasShift.
@@ -4286,12 +4296,16 @@
         self executeLearnedKeyboardMacro.
         ^ self.
     ].
+    (key == #Undo) ifTrue:[self undo. ^self].
+    (key == #Redo) ifTrue:[self redo. ^self].
+
     self learnMode ifTrue:[
         learnedMacro add:event.
     ].
 
     cmdMacro := UserPreferences current functionKeySequences at:key ifAbsent:nil.
     cmdMacro notNil ifTrue:[
+self halt.
         self
             undoableDo:[ self executeKeyboardMacro:cmdMacro ]
             info: key.
@@ -4377,8 +4391,6 @@
     (key == #Cut) ifTrue:[self cut. ^self].
     (key == #Again) ifTrue:[self again. ^self].
     (key == #AgainForAll) ifTrue:[self multipleAgain. ^self].
-    (key == #Undo) ifTrue:[self undo. ^self].
-    (key == #Redo) ifTrue:[self redo. ^self].
 
     (key == #Join) ifTrue:[self joinLines. ^self].
     (key == #Replace) ifTrue:[self replace. ^self].
@@ -4502,14 +4514,15 @@
                 fKeyMacros := UserPreferences current functionKeySequences.
                 fKeyMacros notNil ifTrue:[
                     ((key == #Tab) and:[shiftPressed not]) ifTrue:[
-                        cmdMacro := fKeyMacros at:#IndentBy4 ifAbsent:nil.
+                        macroName := #IndentBy4.
                     ] ifFalse:[
-                        cmdMacro := fKeyMacros at:#UndentBy4 ifAbsent:nil.
+                        macroName := #UndentBy4.
                     ].
-                    cmdMacro notNil ifTrue:[
+                    macroName notNil ifTrue:[
+                        cmdMacro := fKeyMacros at:macroName ifAbsent:nil.
                         self
                             undoableDo:[ self executeKeyboardMacro:cmdMacro ]
-                            info:'IndentBy4'.
+                            info:macroName.
                         ^ self
                     ].
                 ].
@@ -5059,17 +5072,19 @@
     original size == 0 ifTrue:[^ self].
 
     self withWaitCursorDo:[
-	SOAP::SoapImplError handle:[:ex |
-	    Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs
-	] do:[
-	    translated := SOAP::BabelFishClient new translate:original mode:fromToModeString.
-	]
+        SOAP::SoapImplError handle:[:ex |
+            Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs
+        ] do:[
+            translated := SOAP::BabelFishClient new translate:original mode:fromToModeString.
+        ]
     ].
 
     "/ v pasteOrReplace:translated
     self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1).
     self unselect.
-    self undoablePaste:translated info:'translate'
+    self 
+        undoablePaste:translated 
+        info:'Translate'
 
     "Modified: / 28-07-2007 / 13:27:21 / cg"
 !
@@ -5416,21 +5431,23 @@
     |text suggestion|
 
     self withWaitCursorDo:[
-	text := self selection asString string withoutSeparators.
-	text size == 0 ifTrue:[^ self].
-
-	SOAP::SoapImplError handle:[:ex |
-	    Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs.
-	    ^ self.
-	] do:[
-	    suggestion := SOAP::GoogleClient new spellingSuggestionOf:text.
-	].
-	suggestion size == 0 ifTrue:[
-	    Transcript showCR:'No SpellingSuggestion from Google for: ' , text.
-	    ^ self.
-	].
-    ].
-    self undoablePaste:suggestion info:'spelling suggestion'.
+        text := self selection asString string withoutSeparators.
+        text size == 0 ifTrue:[^ self].
+
+        SOAP::SoapImplError handle:[:ex |
+            Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs.
+            ^ self.
+        ] do:[
+            suggestion := SOAP::GoogleClient new spellingSuggestionOf:text.
+        ].
+        suggestion size == 0 ifTrue:[
+            Transcript showCR:'No SpellingSuggestion from Google for: ' , text.
+            ^ self.
+        ].
+    ].
+    self 
+        undoablePaste:suggestion 
+        info:'Spelling Suggestion'.
 
     "Modified: / 28-07-2007 / 13:25:10 / cg"
 !
@@ -5441,7 +5458,7 @@
     typeOfSelection := nil.
     self
         undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)]
-        info:'Paste date and time'
+        info:'Paste Date and Time'
 !
 
 insertFile
@@ -5503,7 +5520,7 @@
     text := file contentsOfEntireFile.
     self
         undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ]
-        info:'Paste file'
+        info:'Paste File'
 
     "Modified: / 28-07-2007 / 13:23:32 / cg"
 !
@@ -5514,7 +5531,7 @@
     typeOfSelection := nil.
     self
         undoableDo:[ self pasteOrReplace:(UUID genUUID printString)]
-        info:'Paste new uuid'
+        info:'Paste New UUID'
 
     "Created: / 28-07-2007 / 13:01:16 / cg"
 !
@@ -7351,5 +7368,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.448 2008-12-07 10:57:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.449 2008-12-09 18:49:08 cg Exp $'
 ! !