The Trunk: Morphic-mt.895.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.895.mcz

commits-2
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)].
+
  (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]!