The Trunk: EToys-ul.80.mcz

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

The Trunk: EToys-ul.80.mcz

commits-2
Levente Uzonyi uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-ul.80.mcz

==================== Summary ====================

Name: EToys-ul.80
Author: ul
Time: 29 January 2011, 1:21:24.328 am
UUID: 9b00814e-958d-d04c-a09e-bc5440d726d4
Ancestors: EToys-nice.79, EToys-fbs.78

- merged

=============== Diff against EToys-nice.79 ===============

Item was changed:
  ----- Method: SyntaxMorph>>replaceKeyWord:menuItem: (in category 'pop ups') -----
  replaceKeyWord: evt menuItem: stringMorph
  "Replace my entire message (which may be multi-part) with the one specified.  Preserve all argument tiles, either in the new message or in the world outside the scriptor.  I am a SelectorNode or KeyWordNode."
 
  | menu new news newSel mm newTree newRec newArgs top oldArgNodes share ctrY |
  (menu := stringMorph owner owner) class == RectangleMorph ifTrue: [
  menu delete].
  new := stringMorph contents.
  new first = $( ifTrue: [^ self]. "Cancel"
  new first = $  ifTrue: [^ self]. "nothing"
  news := String streamContents: [:strm | "remove fake args"
+ (new findBetweenSubStrs: {' 5'. Character space.}) do: [:part | strm nextPutAll: part]].
- (new findBetweenSubStrs: #(' 5' $ )) do: [:part | strm nextPutAll: part]].
  newSel := stringMorph valueOfProperty: #syntacticallyCorrectContents.
  newSel ifNil: [newSel := news].
  mm := MessageSend receiver: 5 selector: newSel
  arguments: ((Array new: newSel numArgs) atAllPut: 5).
  newTree := mm asTilesIn: Object globalNames: false.
  newRec := newTree receiverNode.
  newArgs := newTree argumentNodes.
  ctrY := self fullBoundsInWorld center y.
  top := self messageNode.
  newRec owner replaceSubmorph: newRec by: top receiverNode.
  oldArgNodes := top argumentNodes.
  share := newArgs size min: oldArgNodes size.
  (newArgs first: share) with: (oldArgNodes first: share) do: [:newNode :oldNode |
  newNode owner replaceSubmorph: newNode by: oldNode].
  "later get nodes for objects of the right type for new extra args"
 
  top owner replaceSubmorph: top by: newTree.
 
  "Deposit extra args in the World"
  (oldArgNodes copyFrom: share+1 to: oldArgNodes size) do: [:leftOver |
  (leftOver parseNode class == LiteralNode and: [leftOver decompile asString = '5'])
  ifFalse: [newTree pasteUpMorph addMorphFront: leftOver.
  leftOver position: newTree enclosingPane fullBoundsInWorld right - 20 @ ctrY.
  ctrY := ctrY + 26]
  ifTrue: [leftOver delete]].
  newTree acceptIfInScriptor.!

Item was changed:
  ----- Method: SyntaxMorph>>replaceSel:menuItem: (in category 'pop ups') -----
  replaceSel: evt menuItem: stringMorph
  "I rep a SelectorNode.  Replace my selector with new one that was just chosen from a menu"
 
  | menu new old newSel ms oa na case news |
  (menu := stringMorph owner owner) class == RectangleMorph ifTrue: [
  menu delete].
  new := stringMorph contents.
  new first = $( ifTrue: [^ self]. "Cancel"
  new first = $  ifTrue: [^ self]. "nothing"
  news := String streamContents: [:strm | "remove fake args"
+ (new findBetweenSubStrs: {' 5'. Character space.}) do: [:part | strm nextPutAll: part]].
- (new findBetweenSubStrs: #(' 5' $ )) do: [:part | strm nextPutAll: part]].
  newSel := stringMorph valueOfProperty: #syntacticallyCorrectContents.
  newSel ifNil: [newSel := news].
  old := (ms := self findA: StringMorph) valueOfProperty: #syntacticallyCorrectContents.
  old ifNil: [old := (self findA: StringMorph) contents].
  oa := old numArgs.  na := newSel numArgs.  case := 5.
  (oa = 1) & (na = 1) ifTrue: [case := 1].
  (oa = 0) & (na = 0) ifTrue: [case := 2].
  (oa = 1) & (na  = 0) ifTrue: [case := 3].
  (oa = 0) & (na  = 1) ifTrue: [case := 4].
  case <= 4 ifTrue: ["replace the selector"
  ms contents: news. "not multi-part"
  ms setProperty: #syntacticallyCorrectContents toValue: newSel].
  case = 3 ifTrue: [owner tossOutArg: 1].
  case = 4 ifTrue: [self addArg: 1].
  "more cases here.  Rebuild the entire MessageNode"
 
  self acceptIfInScriptor.!