[squeak-dev] The Trunk: Morphic-mt.895.mcz
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Thu Apr 30 22:10:12 UTC 2015
2015-04-17 15:58 GMT+02:00 <commits at source.squeak.org>:
> Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
> http://source.squeak.org/trunk/Morphic-mt.895.mcz
>
> ==================== Summary ====================
>
> Name: Morphic-mt.895
> Author: mt
> Time: 17 April 2015, 3:58:36.602 pm
> UUID: 955fb45c-fbb5-d545-8e18-2f22524bcd24
> Ancestors: Morphic-mt.894
>
> Added the missing hooks so that text models can not only handle printing
> but also debugging, exploring, inspecting, and even evaluation.
>
> This avoids having to subclass PluggableTextMorph, TextMorph, and
> TextEditor for achieving the same variation point.
>
> =============== Diff against Morphic-mt.894 ===============
>
> Item was changed:
> ----- Method: TextEditor>>debugIt (in category 'do-its') -----
> debugIt
>
> + | receiver context |
> - | method receiver context |
> - (model respondsTo: #doItReceiver)
> - ifTrue:
> - [receiver := model doItReceiver.
> - context := model doItContext]
> - ifFalse:
> - [receiver := context := nil].
> self lineSelectAndEmptyCheck: [^self].
> +
> + (model respondsTo: #debugIt:)
> + ifTrue: [^ model perform: #debugIt: with: self selection].
> +
> + receiver := (model respondsTo: #doItReceiver)
> + ifTrue: [model doItReceiver]
> + ifFalse: [nil].
> +
> + context := (model respondsTo: #doItContext)
> + ifTrue: [model doItContext]
> + ifFalse: [nil].
> +
> + (self compileSelectionFor: receiver in: context) ifNotNil:
> [:method |
> + self debug: method receiver: receiver in: context].!
> - method := self compileSelectionFor: receiver in: context.
> - method notNil ifTrue:
> - [self debug: method receiver: receiver in: context].!
>
> Item was changed:
> ----- Method: TextEditor>>evaluateSelectionAndDo: (in category 'do-its')
> -----
> evaluateSelectionAndDo: aBlock
> "Treat the current selection as an expression; evaluate it and
> invoke aBlock with the result."
> | result rcvr ctxt |
> self lineSelectAndEmptyCheck: [^ nil].
>
> + (model respondsTo: #evaluate:) ifTrue: [
> + ^ aBlock value: (model perform: #evaluate: with: self
> selection)].
> +
>
In one image with Tweak loaded (http://squeaksource.com/TweakCore)
this change had the effect loosing the ability to do it/print it/inspect it
For example, typing one of most basic Smalltalk expression
3+4 -> a Text for '3+4'
This is because the Scripting package installs Object>>evaluate: aBlock
^aBlock value
What are these hooks usefull for? They do not seem in usage currently in
the image.
Nicolas
> (model respondsTo: #doItReceiver)
> ifTrue: [ rcvr := model doItReceiver.
> ctxt := model doItContext]
> ifFalse: [rcvr := ctxt := nil].
> result := [
> rcvr class evaluatorClass new
> evaluate: self selectionAsStream
> in: ctxt
> to: rcvr
> notifying: self
> ifFail: [morph flash. ^ nil]
> logged: true.
> ]
> on: OutOfScopeNotification
> do: [ :ex | ex resume: true].
>
> (model respondsTo: #evaluated:result:) ifTrue: [
> model perform: #evaluated:result: with: self selection
> with: result].
>
> ^aBlock value: result!
>
> Item was changed:
> ----- Method: TextEditor>>exploreIt (in category 'do-its') -----
> exploreIt
> +
> + self evaluateSelectionAndDo: [:result |
> + (model respondsTo: #exploreIt:result:)
> + ifTrue: [model
> + perform: #exploreIt:result:
> + with: self selection
> + with: result]
> + ifFalse: [result explore]].!
> - self evaluateSelectionAndDo: [:result | result explore]!
>
> Item was changed:
> ----- Method: TextEditor>>inspectIt (in category 'do-its') -----
> inspectIt
> +
> + self evaluateSelectionAndDo: [:result |
> + (model respondsTo: #inspectIt:result:)
> + ifTrue: [model
> + perform: #inspectIt:result:
> + with: self selection
> + with: result]
> + ifFalse: [result inspect]].!
> - self evaluateSelectionAndDo: [:result | result inspect]!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150501/9eb976a1/attachment.htm
More information about the Squeak-dev
mailing list
|