'From Squeak3.1alpha of 5 February 2001 [latest update: #3732] on 26 February 2001 at 4:25:30 pm'! !AssignmentNode methodsFor: 'tiles' stamp: 'RAA 2/26/2001 16:17'! asMorphicSyntaxIn: parent ^parent assignmentNode: self variable: variable value: value! ! !SyntaxMorph methodsFor: 'layout' stamp: 'RAA 2/26/2001 15:59'! addBlockArg: aMorph "Add a temporary to a block or the method. Return true if succeed" "(aMorph nodeClassIs: TempVariableNode) is known to be true." "***NOTE: This method should be combined with addTempVar:" | tempHolder tt var nn | owner isMethodNode ifTrue: [ ^ (self addTempVar: aMorph)]. "Node for them is not inside the block" "If exists, drop the temp in this block and let use extend it." tt _ self firstSubmorph. tempHolder _ tt firstSubmorph isSyntaxMorph ifTrue: [(tt nodeClassIs: BlockArgsNode) ifTrue: [tt] ifFalse: [nil]] ifFalse: [nil]. nn _ aMorph parseNode key. "name" tempHolder ifNil: ["make whole row" tempHolder _ self addRow: #blockarg1 on: (BlockArgsNode new). self addMorphFront: tempHolder. tempHolder addNoiseString: self noiseBeforeBlockArg. aMorph parseNode name: nn key: nn code: nil. var _ tempHolder addColumn: #tempVariable on: aMorph parseNode. var layoutInset: 1. var addMorphBack: (self addString: nn). self cleanupAfterItDroppedOnMe. ^ true]. tempHolder submorphsDo: [:m | "if present. caller adds the temp as a new line of code to be extended" m isSyntaxMorph and: [m parseNode key = nn ifTrue: [^ false]]]. "If this variable is not present, add it" tempHolder addNoiseString: self noiseBeforeBlockArg. aMorph parseNode name: nn key: nn code: nil. tempHolder addMorphBack: (tempHolder transparentSpacerOfSize: 4@4). var _ tempHolder addColumn: #tempVariable on: aMorph parseNode. var layoutInset: 1. var addMorphBack: (self aSimpleStringMorphWith: nn). var cleanupAfterItDroppedOnMe. ^ true ! ! !SyntaxMorph methodsFor: 'layout' stamp: 'RAA 2/26/2001 16:01'! addString: literalOrVarName | sMorph | "Create and return an UpdatingStringMorph containing the value. Use an UpdatingStringMorph, so it can inform its owner when it has been edited." sMorph _ self anUpdatingStringMorphWith: literalOrVarName. sMorph target: self; putSelector: #acceptIgnoring:; useStringFormat. "keep the getSelector being nil" ^ sMorph! ! !SyntaxMorph methodsFor: 'menus' stamp: 'RAA 2/26/2001 15:47'! addColumn: aColorOrSymbol on: aNode | col | self addMorphBack: (col _ self class column: aColorOrSymbol on: aNode). "col setProperty: #howCreated toValue: thisContext longStack." self specialBlockFormatting ifTrue: [ (aColorOrSymbol == #block and: [self isMethodNode not]) ifTrue: [ col setConditionalPartStyle. ]. ]. ^ col ! ! !SyntaxMorph methodsFor: 'node to morph' stamp: 'RAA 2/26/2001 16:11'! alanKeywordMessage: aNode isAConditional: template key: key args: args | nodeWithNilReceiver column keywords row onlyOne | "== Repeat for collection [ collect ( from foo. blah blah foo blah) ] Repeat for 1 to 50Ê [ doÊ ( from i. blah blab i blahÊ )Ê ] ==" nodeWithNilReceiver _ aNode copy receiver: nil. template = 1 ifTrue: [ self listDirection: #topToBottom. ]. column _ self addColumn: #keyword1 on: nodeWithNilReceiver. keywords _ key keywords. onlyOne _ args size = 1. keywords with: (args first: keywords size) do: [:kwd :arg | template = 1 ifTrue: [ column addMorphBack: (column transparentSpacerOfSize: 3@3). ]. (row _ column addRow: #keyword2 on: nodeWithNilReceiver) borderWidth: 1; parseNode: (nodeWithNilReceiver as: (onlyOne ifTrue: [MessageNode] ifFalse: [MessagePartNode])); borderColor: row stdBorderColor. template = 1 ifTrue: [row addMorphBack: (row transparentSpacerOfSize: 20@6)]. key == #if:do: ifTrue: [ kwd = 'do:' ifTrue: [ row addMorphBack: (row transparentSpacerOfSize: 26@6). ] ifFalse: [ row addMorphBack: (row transparentSpacerOfSize: 10@6). ]. row addTokenSpecialCase: kwd type: #keyword2 on: KeyWordNode new. ] ifFalse: [ row addToken: kwd type: #keyword2 on: (onlyOne ifTrue: [SelectorNode new key: kwd code: nil "fill this in?"] ifFalse: [KeyWordNode new]). template = 0 ifTrue: [ "row addMorphBack: self tokenVerticalSeparator" ]. ]. (arg asMorphicSyntaxIn: row) setConditionalPartStyle. ]. onlyOne ifTrue: [ self replaceSubmorph: column by: row. column _ row. ]. false "template = 2" ifTrue: [ self setSpecialOuterTestFormat. ] ifFalse: [ column setSpecialOuterTestFormat. ]. ! ! !SyntaxMorph methodsFor: 'node to morph' stamp: 'RAA 2/26/2001 16:13'! alansMessageNode: aNode receiver: receiver selector: selector keywords: key arguments: args | row receiverMorph testAndReceiver anotherSelf wordyMorph template | template _ self alansTemplateStyleFor: key. receiver ifNotNil: ["i.e. not a cascade" anotherSelf _ self constructSelfVariant: receiver and: key. anotherSelf ifNotNil: [ wordyMorph _ self addString: anotherSelf. wordyMorph setProperty: #wordyVariantOfSelf toValue: true. self addMorph: wordyMorph. self layoutInset: 1. ^self ]. testAndReceiver _ self. template = 1 ifTrue: [ testAndReceiver _ self addRow: #keyword1 on: nil. self setSpecialOuterTestFormat. testAndReceiver addNoiseString: 'Test' ]. false "template = 2" ifTrue: [ testAndReceiver _ self addRow: #keyword1 on: nil. "self setSpecialOuterTestFormat." testAndReceiver addNoiseString: 'Repeat for' ]. receiverMorph _ receiver asMorphicSyntaxIn: testAndReceiver. template = 1 ifTrue: [receiverMorph setConditionalPartStyle]. ]. "unary mssages" args size = 0 ifTrue: [ row _ (self addSingleKeywordRow: key style: #unary) layoutInset: 1. ^ row parseNode: selector ]. "binary messages" key last = $: ifFalse: [ ^self alanBinaryPostRcvr: aNode key: key args: args ]. "keyword messages" receiverMorph ifNotNil: [self setConditionalPartStyle]. self alanKeywordMessage: aNode isAConditional: template key: key args: args! ! !SyntaxMorph methodsFor: 'node to morph' stamp: 'RAA 2/26/2001 16:17'! assignmentNode: aNode variable: variable value: value | row valueMorph | row _ self addRow: #assignment on: aNode. variable asMorphicSyntaxIn: row. row addToken: ' _ ' type: #assignment on: aNode. valueMorph _ value asMorphicSyntaxIn: row. self alansTest1 ifTrue: [valueMorph setSpecialOuterTestFormat]. ^row ! ! !SyntaxMorph methodsFor: 'node to morph' stamp: 'RAA 2/26/2001 16:12'! returnNode: aNode expression: expr | row | row _ self addRow: #return on: aNode. row addToken: '^ ' type: #upArrow on: aNode. expr asMorphicSyntaxIn: row. expr addCommentToMorph: row. self alansTest1 ifTrue: [row setSpecialOuterTestFormat]. ^row ! ! !SyntaxMorph methodsFor: 'alans styles' stamp: 'RAA 2/26/2001 16:03'! aSimpleStringMorphWith: aString self alansTest1 ifTrue: [ ^StringMorph contents: aString font: self alansCurrentFontPreference ]. ^StringMorph contents: aString! ! !SyntaxMorph methodsFor: 'alans styles' stamp: 'RAA 2/26/2001 16:03'! alansCurrentFontPreference ^StrikeFont familyName: 'ComicBold' size: 16! ! !SyntaxMorph methodsFor: 'alans styles' stamp: 'RAA 2/26/2001 16:03'! anUpdatingStringMorphWith: aString self alansTest1 ifTrue: [ ^UpdatingStringMorph contents: aString font: self alansCurrentFontPreference ]. ^UpdatingStringMorph contents: aString! ! !SyntaxMorph methodsFor: 'alans styles' stamp: 'RAA 2/26/2001 15:57'! fontToUseForSpecialWord: aString ^(#('Yes' 'No' 'Test') includes: aString) ifTrue: [ (StrikeFont familyName: 'Helvetica' size: 14) ] ifFalse: [ (StrikeFont familyName: 'ComicBold' size: 16) ]! ! !SyntaxMorph methodsFor: 'alans styles' stamp: 'RAA 2/26/2001 16:00'! noiseStringMorph: aNoiseString | sMorph | self flag: #emphasis:. "who needs it. who doesn't" sMorph _ self aSimpleStringMorphWith: aNoiseString. sMorph font: (self fontToUseForSpecialWord: aNoiseString) "emphasis: 1"; color: (self colorForKeywords: aNoiseString and: aNoiseString); setProperty: #noiseWord toValue: true. ^sMorph ! ! !SyntaxMorph methodsFor: 'alans styles' stamp: 'RAA 2/26/2001 15:47'! setConditionalPartStyle | c | c _ self lightGreenishColor. self specialColor: c andBorder: c. "old border (Color r: 0.581 g: 0.774 b: 0.903)" self useRoundedCorners. self borderWidth: 1. ! ! SyntaxMorph removeSelector: #auUpdatingStringMorphWith:! SyntaxMorph removeSelector: #setConditionalPartStyle:!