<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-04-17 15:58 GMT+02:00  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Marcel Taeumel uploaded a new version of Morphic to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Morphic-mt.895.mcz" target="_blank">http://source.squeak.org/trunk/Morphic-mt.895.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Morphic-mt.895<br>
Author: mt<br>
Time: 17 April 2015, 3:58:36.602 pm<br>
UUID: 955fb45c-fbb5-d545-8e18-2f22524bcd24<br>
Ancestors: Morphic-mt.894<br>
<br>
Added the missing hooks so that text models can not only handle printing but also debugging, exploring, inspecting, and even evaluation.<br>
<br>
This avoids having to subclass PluggableTextMorph, TextMorph, and TextEditor for achieving the same variation point.<br>
<br>
=============== Diff against Morphic-mt.894 ===============<br>
<br>
Item was changed:<br>
  ----- Method: TextEditor&gt;&gt;debugIt (in category &#39;do-its&#39;) -----<br>
  debugIt<br>
<br>
+       | receiver context |<br>
-       | method receiver context |<br>
-       (model respondsTo: #doItReceiver)<br>
-               ifTrue:<br>
-                       [receiver := model doItReceiver.<br>
-                       context := model doItContext]<br>
-               ifFalse:<br>
-                       [receiver := context := nil].<br>
        self lineSelectAndEmptyCheck: [^self].<br>
+<br>
+       (model respondsTo: #debugIt:)<br>
+               ifTrue: [^ model perform: #debugIt: with: self selection].<br>
+<br>
+       receiver := (model respondsTo: #doItReceiver)<br>
+               ifTrue: [model doItReceiver]<br>
+               ifFalse: [nil].<br>
+<br>
+       context := (model respondsTo: #doItContext)<br>
+               ifTrue: [model doItContext]<br>
+               ifFalse: [nil].<br>
+<br>
+       (self compileSelectionFor: receiver in: context) ifNotNil: [:method |<br>
+               self debug: method receiver: receiver in: context].!<br>
-       method := self compileSelectionFor: receiver in: context.<br>
-       method notNil ifTrue:<br>
-               [self debug: method receiver: receiver in: context].!<br>
<br>
Item was changed:<br>
  ----- Method: TextEditor&gt;&gt;evaluateSelectionAndDo: (in category &#39;do-its&#39;) -----<br>
  evaluateSelectionAndDo: aBlock<br>
        &quot;Treat the current selection as an expression; evaluate it and invoke aBlock with the result.&quot;<br>
        | result rcvr ctxt |<br>
        self lineSelectAndEmptyCheck: [^ nil].<br>
<br>
+       (model respondsTo: #evaluate:) ifTrue: [<br>
+               ^ aBlock value: (model perform: #evaluate: with: self selection)].<br>
+<br></blockquote><div><br></div><div>In one image with Tweak loaded (<a href="http://squeaksource.com/TweakCore">http://squeaksource.com/TweakCore</a>)<br></div><div>this change had the effect loosing the ability to do it/print it/inspect it<br><br></div><div>For example, typing one of most basic Smalltalk expression<br>  3+4 -&gt;  a Text for &#39;3+4&#39;<br><br></div><div>This is because the Scripting package installs Object&gt;&gt;evaluate: aBlock ^aBlock value<br><br></div><div>What are these hooks usefull for? They do not seem in usage currently in the image.<br><br></div><div>Nicolas<br></div><div><br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
        (model respondsTo: #doItReceiver)<br>
                ifTrue: [ rcvr := model doItReceiver.<br>
                                ctxt := model doItContext]<br>
                ifFalse: [rcvr := ctxt := nil].<br>
        result := [<br>
                rcvr class evaluatorClass new<br>
                        evaluate: self selectionAsStream<br>
                        in: ctxt<br>
                        to: rcvr<br>
                        notifying: self<br>
                        ifFail: [morph flash. ^ nil]<br>
                        logged: true.<br>
        ]<br>
                on: OutOfScopeNotification<br>
                do: [ :ex | ex resume: true].<br>
<br>
        (model respondsTo: #evaluated:result:) ifTrue: [<br>
                model perform: #evaluated:result: with: self selection with: result].<br>
<br>
        ^aBlock value: result!<br>
<br>
Item was changed:<br>
  ----- Method: TextEditor&gt;&gt;exploreIt (in category &#39;do-its&#39;) -----<br>
  exploreIt<br>
+<br>
+        self evaluateSelectionAndDo: [:result |<br>
+               (model respondsTo: #exploreIt:result:)<br>
+                       ifTrue: [model<br>
+                               perform: #exploreIt:result:<br>
+                               with: self selection<br>
+                               with: result]<br>
+                       ifFalse: [result explore]].!<br>
-       self evaluateSelectionAndDo: [:result | result explore]!<br>
<br>
Item was changed:<br>
  ----- Method: TextEditor&gt;&gt;inspectIt (in category &#39;do-its&#39;) -----<br>
  inspectIt<br>
+<br>
+        self evaluateSelectionAndDo: [:result |<br>
+               (model respondsTo: #inspectIt:result:)<br>
+                       ifTrue: [model<br>
+                               perform: #inspectIt:result:<br>
+                               with: self selection<br>
+                               with: result]<br>
+                       ifFalse: [result inspect]].!<br>
-        self evaluateSelectionAndDo: [:result | result inspect]!<br>
<br>
<br>
</blockquote></div><br></div></div>