--- a/Workspace.st Thu Mar 29 13:44:43 2018 +0200
+++ b/Workspace.st Thu Mar 29 13:47:34 2018 +0200
@@ -1400,85 +1400,85 @@
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock savedBackground|
- code notNil ifTrue:[
- code asString withoutSeparators isEmpty ifTrue:[ ^ self ].
-
- codeStartPosition := self characterPositionOfSelection.
-
- "
- remember selection for later - if there is an error,
- the notification method will highlight it.
- thus destroying the current selection
- "
- selLine := selectionStartLine.
- selCol := selectionStartCol.
- endLine := selectionEndLine.
- endCol := selectionEndCol.
- cCol := cursorCol.
- cLine := cursorLine.
-
- "
- cleanup: restore previous selection and cursor positions
- "
- cleanUp :=
- [
- self selectFromLine:selLine col:selCol toLine:endLine col:endCol.
- cLine notNil ifTrue:[
- self cursorLine:cLine col:cCol
- ].
- savedBackground notNil ifTrue:[
- self backgroundColor:savedBackground.
- self invalidate.
- ].
+ code isNil ifTrue:[^ self].
+ code asString withoutSeparators isEmpty ifTrue:[ ^ self ].
+ doItAction isNil ifTrue:[^ self].
+
+ codeStartPosition := self characterPositionOfSelection.
+
+ "
+ remember selection for later - if there is an error,
+ the notification method will highlight it.
+ thus destroying the current selection
+ "
+ selLine := selectionStartLine.
+ selCol := selectionStartCol.
+ endLine := selectionEndLine.
+ endCol := selectionEndCol.
+ cCol := cursorCol.
+ cLine := cursorLine.
+
+ "
+ cleanup: restore previous selection and cursor positions
+ "
+ cleanUp :=
+ [
+ self selectFromLine:selLine col:selCol toLine:endLine col:endCol.
+ cLine notNil ifTrue:[
+ self cursorLine:cLine col:cCol
].
-
- "
- perform the action.
- Be careful to release the reference to the value;
- otherwise, we could keep lots of garbage from being freed
- until the view gets closed
- "
- executeBlock :=
+ savedBackground notNil ifTrue:[
+ self backgroundColor:savedBackground.
+ self invalidate.
+ ].
+ ].
+
+ "
+ perform the action.
+ Be careful to release the reference to the value;
+ otherwise, we could keep lots of garbage from being freed
+ until the view gets closed
+ "
+ executeBlock :=
+ [
[
- [
- |busyColor|
-
- (busyColor := UserPreferences current busyBackgroundColorInDoits) notNil ifTrue:[
- savedBackground := self backgroundColor.
- self backgroundColor:busyColor.
- self invalidateRepairNow:true.
- ].
-
- AbortOperationRequest handle:[:ex |
- "/ aBlock value:'** Abortsignal caught **'.
- ex return
- ] do:[
- |value|
-
- doItAction notNil ifTrue:[
- value := doItAction value:(code asString).
- cleanUp value. cleanUp := nil.
- aBlock notNil ifTrue:[
- aBlock value:value.
- ].
- value := nil.
- self class rememberDoIt:code.
- ]
+ |busyColor|
+
+ (busyColor := UserPreferences current busyBackgroundColorInDoits) notNil ifTrue:[
+ savedBackground := self backgroundColor.
+ self backgroundColor:busyColor.
+ self invalidateRepairNow:true.
+ ].
+
+ AbortOperationRequest handle:[:ex |
+ "/ aBlock value:'** Abortsignal caught **'.
+ ex return
+ ] do:[
+ |value|
+
+ doItAction notNil ifTrue:[
+ value := doItAction value:(code asString).
+ cleanUp value. cleanUp := nil.
+ aBlock notNil ifTrue:[
+ aBlock value:value.
+ ].
+ value := nil.
+ self class rememberDoIt:code.
]
- ] ensure:[
- cleanUp notNil ifTrue:[
- cleanUp value. cleanUp := nil
- ].
]
- ].
- aBlock isNil ifTrue:[
- "no action is performed with the result - give the user a visible
- feedback, that something has been done"
- self topView withVisibleCursor:Cursor execute do:executeBlock.
- ] ifFalse:[
- self topView withCursor:Cursor execute do:executeBlock.
+ ] ensure:[
+ cleanUp notNil ifTrue:[
+ cleanUp value. cleanUp := nil
+ ].
+ ]
].
- ]
+ aBlock isNil ifTrue:[
+ "no action is performed with the result - give the user a visible
+ feedback, that something has been done"
+ self topView withVisibleCursor:Cursor execute do:executeBlock.
+ ] ifFalse:[
+ self topView withCursor:Cursor execute do:executeBlock.
+ ].
"Created: / 22-04-1998 / 21:57:05 / ca"
"Modified: / 01-11-2017 / 11:27:26 / cg"
@@ -1676,7 +1676,7 @@
|codeToEvaluate el idx
possibleSelectorString selector lineNr
- evaluatedValue classToBrowse gotResult browser|
+ evaluatedValue classToBrowse getClassToBrowseWithoutDoIt gotResult browser|
(self selection isEmptyOrNil
and:[ self supportsSyntaxElements
@@ -1721,57 +1721,66 @@
].
].
- (Parser parseErrorSignal , MessageNotUnderstood) handle:[:ex |
- |className words|
-
- (classToBrowse := Smalltalk classNamed:codeToEvaluate) isNil ifTrue:[
- "/ handle className selector (for example from messageTally list)
- codeToEvaluate includesSeparator ifTrue:[
- words := codeToEvaluate asCollectionOfWords.
- classToBrowse := Smalltalk classNamed:words first.
- classToBrowse notNil ifTrue:[
- selector := (words copyFrom:2) asStringWith:''.
- ((words size > 1) and:[words second = 'class']) ifTrue:[
- classToBrowse := classToBrowse theMetaclass.
- selector := (words copyFrom:3) asStringWith:''.
+ getClassToBrowseWithoutDoIt :=
+ [
+ |className words|
+
+ (classToBrowse := Smalltalk classNamed:codeToEvaluate) isNil ifTrue:[
+ "/ handle className selector (for example from messageTally list)
+ codeToEvaluate includesSeparator ifTrue:[
+ words := codeToEvaluate asCollectionOfWords.
+ classToBrowse := Smalltalk classNamed:words first.
+ classToBrowse notNil ifTrue:[
+ selector := (words copyFrom:2) asStringWith:''.
+ ((words size > 1) and:[words second = 'class']) ifTrue:[
+ classToBrowse := classToBrowse theMetaclass.
+ selector := (words copyFrom:3) asStringWith:''.
+ ].
+ browser := classToBrowse browserClass openInClass:classToBrowse selector:selector.
+ (selector notNil and:[lineNr notNil]) ifTrue:[
+ browser codeView makeLineVisible:lineNr; selectLine:lineNr.
+ ].
+ ^ self.
].
- browser := classToBrowse browserClass openInClass:classToBrowse selector:selector.
- (selector notNil and:[lineNr notNil]) ifTrue:[
- browser codeView makeLineVisible:lineNr; selectLine:lineNr.
- ].
- ^ self.
].
+
+ "/ fallback, if garbage is selected, look for matching classes.
+ className := SystemBrowser
+ askForClassNameMatching:codeToEvaluate
+ inEnvironment:nil
+ for:nil.
+
+ className isNil ifTrue:[^ self].
+ classToBrowse := Smalltalk classNamed:className.
].
-
- "/ fallback, if garbage is selected, look for matching classes.
- className := SystemBrowser
- askForClassNameMatching:codeToEvaluate
- inEnvironment:nil
- for:nil.
-
- className isNil ifTrue:[^ self].
- classToBrowse := Smalltalk classNamed:className.
- ]
- ] do:[
- gotResult := false.
-
- self
- do:codeToEvaluate
- withValueDo:[:result | evaluatedValue := result. gotResult := true.].
-
- gotResult ifFalse:[^ self].
-
- evaluatedValue isNil ifTrue:[
- codeToEvaluate asCollectionOfWords size == 1 ifTrue:[
- codeToEvaluate isUppercaseFirst ifTrue:[
- Dialog information:(codeToEvaluate allBold , ' is unbound or nil').
- ^ self.
+ ].
+
+ doItAction isNil ifTrue:[
+ getClassToBrowseWithoutDoIt value
+ ] ifFalse:[
+ (Parser parseErrorSignal , MessageNotUnderstood)
+ handle:getClassToBrowseWithoutDoIt
+ do:[
+ gotResult := false.
+
+ self
+ do:codeToEvaluate
+ withValueDo:[:result | evaluatedValue := result. gotResult := true.].
+
+ gotResult ifFalse:[^ self].
+
+ evaluatedValue isNil ifTrue:[
+ codeToEvaluate asCollectionOfWords size == 1 ifTrue:[
+ codeToEvaluate isUppercaseFirst ifTrue:[
+ Dialog information:(codeToEvaluate allBold , ' is unbound or nil').
+ ^ self.
+ ].
+ ]
].
- ]
- ].
- classToBrowse := evaluatedValue isBehavior
- ifTrue:[ evaluatedValue ]
- ifFalse:[ evaluatedValue class ].
+ classToBrowse := evaluatedValue isBehavior
+ ifTrue:[ evaluatedValue ]
+ ifFalse:[ evaluatedValue class ].
+ ].
].
browser := classToBrowse browserClass openInClass:classToBrowse selector:selector.
@@ -2069,7 +2078,7 @@
sub disable:#browseSharedPoolOfIt.
].
].
- self isReadOnly ifTrue:[
+ (self isReadOnly or:[commentStrings isEmptyOrNil]) ifTrue:[
sub disableAll:#(commentSelection uncommentSelection)
].
].
@@ -2102,6 +2111,9 @@
m disableAll:#(printIt doIt inspectIt browseIt)
].
].
+ doItAction isNil ifTrue:[
+ m disableAll:#(printIt doIt inspectIt timeIt spyOnIt)
+ ].
self isReadOnly ifTrue:[
m disable:#printIt
].