'From Squeak3.1alpha of 5 February 2001 [latest update: #3875] on 25 March 2001 at 6:21:11 pm'! "Change Set: editingSelectors Date: 25 March 2001 Author: Bob Arning Improve editing of selectors and such in universal tiles so that things that got munged going one way get unmunged coming back. Also, remove some experimental options that are no longer needed"! !SyntaxMorph methodsFor: 'initialization' stamp: 'RAA 3/25/2001 16:11'! returnNode: aNode expression: expr | row expMorph sMorph aNoiseString | row _ self addRow: #return on: aNode. self alansTest1 ifTrue: [ row setSpecialOuterTestFormat. aNoiseString _ ' Reply '. sMorph _ self aSimpleStringMorphWith: aNoiseString. sMorph emphasis: 1; setProperty: #syntacticallyCorrectContents toValue: '^'. row addMorphBack: sMorph. ] ifFalse: [ row addToken: '^ ' type: #upArrow on: aNode. ]. expMorph _ expr asMorphicSyntaxIn: row. self alansTest1 ifTrue: [ (expMorph hasProperty: #deselectedColor) ifFalse: [expMorph setConditionalPartStyle]. ]. expr addCommentToMorph: row. ^row ! ! !SyntaxMorph methodsFor: 'accessing' stamp: 'RAA 3/25/2001 17:17'! cleanUpString: stringSubMorph | style rawData | ^ stringSubMorph valueOfProperty: #syntacticallyCorrectContents ifAbsent: [ style _ stringSubMorph valueOfProperty: #syntacticReformatting. rawData _ stringSubMorph contents. (#(unary tempVariableDeclaration blockarg2 methodHeader1 tempVariable variable) includes: style) ifTrue: [ rawData _ self unSpaceAndUpShift: rawData appending: nil. ]. style == #keywordGetz ifTrue: [ rawData _ self unSpaceAndUpShift: rawData appending: 'Getz:'. ]. (#(keyword2 methodHeader2) includes: style) ifTrue: [ rawData _ self unSpaceAndUpShift: rawData appending: ':'. ]. rawData ] ! ! !SyntaxMorph methodsFor: 'accessing' stamp: 'RAA 3/25/2001 17:16'! unSpaceAndUpShift: aString appending: extraChars | answer upShiftNext | answer _ WriteStream on: String new. upShiftNext _ false. aString do: [ :ch | ch == Character space ifTrue: [ upShiftNext _ true ] ifFalse: [ answer nextPut: (upShiftNext ifTrue: [ch asUppercase] ifFalse: [ch]). upShiftNext _ false. ]. ]. answer _ answer contents. extraChars isEmptyOrNil ifTrue: [^answer]. (answer endsWith: extraChars) ifFalse: [answer _ answer,extraChars]. ^answer ! ! !SyntaxMorph methodsFor: 'drawing' stamp: 'RAA 3/25/2001 16:16'! drawOn: aCanvas super drawOn: aCanvas. self isBlockNode ifFalse: [^self]. self alansTest1 ifTrue: [^self]. self immediatelyBelowTheMethodNode ifTrue: [ aCanvas fillRectangle: (self topLeft + (0@-1) extent: self width@1) color: Color gray ] ifFalse: [ aCanvas fillRectangle: (self topLeft + (1@1) extent: 2@(self height-2)) color: Color gray. aCanvas fillRectangle: (self topLeft + (1@1) extent: 4@1) color: Color gray. aCanvas fillRectangle: (self bottomLeft + (1@-1) extent: 4@1) color: Color gray ]. ! ! !SyntaxMorph methodsFor: 'layout' stamp: 'RAA 3/25/2001 16:17'! addNoiseString: aNoiseString self alansTest1 ifFalse: [^self]. ^(self addColumn: #keyword1 on: nil) layoutInset: 1; addMorphBack: (self noiseStringMorph: aNoiseString) ! ! !SyntaxMorph methodsFor: 'layout' stamp: 'RAA 3/25/2001 16:17'! addNoiseString: aNoiseString emphasis: anInteger self alansTest1 ifFalse: [^self]. ^(self addColumn: #keyword1 on: nil) layoutInset: 1; addMorphBack: ((self noiseStringMorph: aNoiseString) emphasis: anInteger) ! ! !SyntaxMorph methodsFor: 'layout' stamp: 'RAA 3/25/2001 16:23'! addSingleKeywordRow: aStringLikeItem | row sMorph modifiedString | (row _ self class row: #text on: nil) borderWidth: 1. modifiedString _ self substituteKeywordFor: aStringLikeItem. sMorph _ self addString: modifiedString special: true. sMorph font: (self fontToUseForSpecialWord: modifiedString); setProperty: #syntacticallyCorrectContents toValue: aStringLikeItem. row addMorph: sMorph. self addMorphBack: row. ^row! ! !SyntaxMorph methodsFor: 'layout' stamp: 'RAA 3/25/2001 16:31'! addUnaryRow: aStringLikeItem style: aSymbol | row sMorph modifiedString fontToUse | (row _ self class row: #text on: nil) borderWidth: 1. modifiedString _ self substituteKeywordFor: aStringLikeItem. sMorph _ self addString: modifiedString special: true. fontToUse _ self fontToUseForSpecialWord: modifiedString. sMorph font: fontToUse emphasis: 1; setProperty: #syntacticReformatting toValue: #unary; setProperty: #syntacticallyCorrectContents toValue: aStringLikeItem. row addMorph: sMorph. self addMorphBack: row. ^row! ! !SyntaxMorph methodsFor: 'menus' stamp: 'RAA 3/25/2001 16:15'! addColumn: aColorOrSymbol on: aNode | col | self addMorphBack: (col _ self class column: aColorOrSymbol on: aNode). "col setProperty: #howCreated toValue: thisContext longStack." self alansTest1 ifTrue: [ (aColorOrSymbol == #block and: [self isMethodNode not]) ifTrue: [ col setConditionalPartStyle. ]. ]. ^ col ! ! !SyntaxMorph methodsFor: 'menus' stamp: 'RAA 3/25/2001 17:21'! addToken: aString type: aColorOrSymbol on: aNode | sMorph modifiedString noiseWord col | col _ (self addRow: aColorOrSymbol on: aNode) layoutInset: 1. self alansTest1 ifFalse: [ sMorph _ self addString: aString special: false. col addMorphBack: sMorph. ^col ]. noiseWord _ [ :w | w ifNotNil: [ col addMorphBack: (self noiseStringMorph: w); addMorphBack: (self tokenVerticalSeparator) ]. ]. (self shouldBeBrokenIntoWords: aColorOrSymbol) ifTrue: [ modifiedString _ self substituteKeywordFor: aString. sMorph _ self addString: modifiedString special: (aColorOrSymbol == #unary). sMorph setProperty: #syntacticReformatting toValue: aColorOrSymbol; setProperty: #syntacticallyCorrectContents toValue: aString; contents: modifiedString. ] ifFalse: [ sMorph _ self addString: (modifiedString _ aString) special: false. ]. (#(keyword2 upArrow) includes: aColorOrSymbol) ifTrue: [ sMorph font: (self fontToUseForSpecialWord: modifiedString). ]. (#(keyword2 unary assignmentArrow methodHeader1 methodHeader2) includes: aColorOrSymbol) ifTrue: [ sMorph emphasis: 1. ]. aColorOrSymbol == #blockarg1 ifTrue: [ ]. (aColorOrSymbol == #variable or: [aColorOrSymbol == #tempVariable]) ifTrue: [ aString = 'self' ifTrue: [ sMorph setProperty: #wordyVariantOfSelf toValue: true. ]. noiseWord value: (self noiseWordBeforeVariableNode: aNode string: aString). ]. col addMorphBack: sMorph. ^col! ! !SyntaxMorph methodsFor: 'menus' stamp: 'RAA 3/25/2001 17:22'! addTokenSpecialCase: aString type: aColorOrSymbol on: aNode | sMorph modifiedString noiseWord col | noiseWord _ nil. sMorph _ self addString: aString special: false. (aColorOrSymbol == #keyword2) ifTrue: [ modifiedString _ aString = 'if:' ifTrue: ['Test'] ifFalse: ['Yes']. sMorph font: (self fontToUseForSpecialWord: modifiedString); setProperty: #syntacticallyCorrectContents toValue: aString; contents: modifiedString. ]. col _ (self addRow: aColorOrSymbol on: aNode) layoutInset: 1. noiseWord ifNotNil: [ col addMorphBack: (self noiseStringMorph: noiseWord); addMorphBack: (self transparentSpacerOfSize: 3@1) ]. col addMorphBack: sMorph. ^col! ! !SyntaxMorph methodsFor: 'menus' stamp: 'RAA 3/25/2001 17:27'! finalAppearanceTweaks | deletes | SizeScaleFactor ifNil: [SizeScaleFactor _ 1.0]. self usingClassicTiles ifTrue: [ self allMorphsDo: [:each | (each isKindOf: SyntaxMorph) ifTrue: [each lookClassic] ]. ^self ]. deletes _ OrderedCollection new. self allMorphsDo: [ :each | (each respondsTo: #setDeselectedColor) ifTrue: [each setDeselectedColor]. (each hasProperty: #variableInsetSize) ifTrue: [ each layoutInset: ((each valueOfProperty: #variableInsetSize) * SizeScaleFactor) rounded. ]. ]. deletes do: [ :each | each delete]. ! ! !SyntaxMorph methodsFor: 'node to morph' stamp: 'RAA 3/25/2001 16:31'! alanKwdCollect: aNode isAConditional: template key: key args: args | nodeWithNilReceiver row kwdHolder | nodeWithNilReceiver _ aNode copy receiver: nil. (row _ self addRow: #keyword2 on: nodeWithNilReceiver) borderWidth: 1; parseNode: (nodeWithNilReceiver as: MessageNode); borderColor: row stdBorderColor. kwdHolder _ row addToken: key type: #keyword2 on: (SelectorNode new key: key code: nil "fill this in?"). kwdHolder firstSubmorph setProperty: #syntacticallyCorrectContents toValue: key asString; contents: ''. args first asMorphicCollectSyntaxIn: row. ! ! !SyntaxMorph methodsFor: 'node to morph' stamp: 'RAA 3/25/2001 17:12'! alanKwdSetter: aNode isAConditional: template key: key args: args | nodeWithNilReceiver row kwdHolder | nodeWithNilReceiver _ aNode copy receiver: nil. (row _ self addRow: #keyword2 on: nodeWithNilReceiver) borderWidth: 1; parseNode: (nodeWithNilReceiver as: MessageNode); borderColor: row stdBorderColor. row addNoiseString: '''s' emphasis: 1. kwdHolder _ row addToken: key type: #keywordGetz on: (SelectorNode new key: key code: nil "fill this in?"). kwdHolder firstSubmorph setProperty: #syntacticReformatting toValue: #keywordGetz; setProperty: #syntacticallyCorrectContents toValue: key asString; contents: (key asString allButLast: 5); emphasis: 1. row addNoiseString: '_' emphasis: 1. (args first asMorphicSyntaxIn: row) setConditionalPartStyle ! ! !SyntaxMorph methodsFor: 'node to morph' stamp: 'RAA 3/25/2001 16:30'! 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 special: false. 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 messages" args size = 0 ifTrue: [ row _ (self addUnaryRow: key style: #unary) layoutInset: 1. ^ row parseNode: selector ]. "binary messages" key last = $: ifFalse: [ ^self alanBinaryPostRcvr: aNode key: key args: args ]. "keyword messages" receiverMorph ifNotNil: [receiverMorph setConditionalPartStyle]. self setSpecialOuterTestFormat. self alanKeywordMessage: aNode isAConditional: template key: key args: args! ! !SyntaxMorph methodsFor: 'alans styles' stamp: 'RAA 3/25/2001 17:16'! noiseStringMorph: aNoiseString | sMorph | sMorph _ self aSimpleStringMorphWith: aNoiseString. sMorph font: (self fontToUseForSpecialWord: aNoiseString); setProperty: #noiseWord toValue: true. ^sMorph ! ! SyntaxMorph removeSelector: #colorForBinaries! SyntaxMorph removeSelector: #colorForKeywords:and:! SyntaxMorph removeSelector: #colorForUnaries! SyntaxMorph removeSelector: #noiseWordsAdded! SyntaxMorph removeSelector: #specialBlockFormatting! SyntaxMorph removeSelector: #tokenVerticalSeparatorBlueBar! SyntaxMorph removeSelector: #tokenVerticalSeparatorGray! SyntaxMorph removeSelector: #unSpaceAndUpShift:!