'From Squeak3.7alpha of 11 September 2003 [latest update: #5816] on 17 March 2004 at 7:57:02 pm'! "Change Set: q22easterEggs-sw Date: 10 March 2004, 18 March 2004 Author: Scott Wallace Adapted for Squeak 3.7a from Squeakland updates 0202easterEggs-sw and 0205varName-sw. There was one babel-related collision to be fixed up. Abolishes a few long-standing odd-ball wordings in the etoy user-interface. ¥ Makes the 'no help available' backstop message a little less whimsical. ¥ Makes the default names offered for launching new variables in a viewer be all of the form var1, var2, etc. ¥ Provides appropriate balloon help on symbol-list tiles."! !Player methodsFor: 'slots-user' stamp: 'sw 3/16/2004 14:27'! addInstanceVariable "Offer the user the opportunity to add an instance variable, and if he goes through with it, actually add it." | itsName initialValue typeChosen usedNames initialAnswer setterSelector originalString | usedNames _ self class instVarNames. initialAnswer _ Utilities keyLike: ('var', (usedNames size + 1) asString) satisfying: [:aKey | (usedNames includes: aKey) not]. originalString _ FillInTheBlank request: 'name for new variable: ' initialAnswer: initialAnswer. originalString isEmptyOrNil ifTrue: [^ self]. itsName _ ScriptingSystem acceptableSlotNameFrom: originalString forSlotCurrentlyNamed: nil asSlotNameIn: self world: self costume world. itsName size == 0 ifTrue: [^ self]. self assureUniClass. typeChosen _ self initialTypeForSlotNamed: itsName. self slotInfo at: itsName put: (SlotInformation new initialize type: typeChosen). initialValue _ self initialValueForSlotOfType: typeChosen. self addInstanceVarNamed: itsName withValue: initialValue. self class compileAccessorsFor: itsName. setterSelector _ Utilities setterSelectorFor: itsName. (self class allSubInstances copyWithout: self) do: [:anInstance | anInstance perform: setterSelector with: initialValue]. self updateAllViewersAndForceToShow: ScriptingSystem nameForInstanceVariablesCategory! ! !StandardScriptingSystem methodsFor: 'utilities' stamp: 'sw 3/10/2004 23:24'! helpStringForOperator: anOperator "Answer the help string associated with the given operator. If none found, return a standard no-help-available reply" ^ (self helpStringOrNilForOperator: anOperator) ifNil: ['Sorry, no help available here' translated] "This should never be seen, but is provided as a backstop"! ! !StandardScriptingSystem methodsFor: 'utilities' stamp: 'sw 3/18/2004 00:35'! helpStringOrNilForOperator: anOperator "Answer the help string associated with the given operator, nil if none found." | anIndex opsAndHelp | (anIndex _ (opsAndHelp _ self arithmeticalOperatorsAndHelpStrings) first indexOf: anOperator) > 0 ifTrue: [^ (opsAndHelp second at: anIndex) translated]. (anIndex _ (opsAndHelp _ self numericComparitorsAndHelpStrings) first indexOf: anOperator) > 0 ifTrue: [^ (opsAndHelp second at: anIndex) translated]. ^ nil! ! !SyntaxMorph methodsFor: 'pop ups' stamp: 'sw 3/18/2004 00:35'! setSelector: stringLike in: stringMorph "Store the new selector and accept method." | aSymbol myType str | aSymbol _ stringLike asSymbol. (ScriptingSystem helpStringOrNilFor: aSymbol) ifNotNilDo: [:aString | self setBalloonText: aString translated]. myType _ stringMorph valueOfProperty: #syntacticReformatting ifAbsent: [#none]. str _ aSymbol. (self isStandardSetterKeyword: str) ifTrue: [str _ self translateToWordySetter: str]. (self isStandardGetterSelector: str) ifTrue: [str _ self translateToWordyGetter: str]. (self shouldBeBrokenIntoWords: myType) ifTrue: [str _ self substituteKeywordFor: str]. stringMorph contents: str. "parseNode key: aSymbol code: nil." str = stringLike ifFalse: [stringMorph setProperty: #syntacticallyCorrectContents toValue: aSymbol]. self acceptSilently! ! !TileMorph methodsFor: 'arrows' stamp: 'sw 3/10/2004 23:27'! arrowAction: delta "Do what is appropriate when an arrow on the tile is pressed; delta will be +1 or -1" | index aList | owner ifNil: [^ self]. (type == #literal and: [literal isNumber]) ifTrue: [self literal: literal + delta. ^ self layoutChanged.]. (type == #literal and: [literal isKindOf: Boolean]) ifTrue: [self literal: literal not. ^ self layoutChanged]. operatorOrExpression ifNotNil: [aList _ #(+ - * / // \\ min: max:). index _ aList indexOf: operatorOrExpression. index > 0 ifTrue: [self setOperatorAndUseArrows: (aList atWrap: index + delta)] "NB sets balloon text too" ifFalse: [aList _ #(< <= = ~= > >= isDivisibleBy:). index _ aList indexOf: operatorOrExpression. index > 0 ifTrue: [owner firstSubmorph type = #Number ifTrue: [self setOperator: (aList atWrap: index + delta)] ifFalse: [self setOperator: (#(= ~=) atWrap: index - 2 + delta)]]. "Color does not understand <" (ScriptingSystem helpStringOrNilFor: operatorOrExpression) ifNotNilDo: [:aString | submorphs last setBalloonText: aString]]. ^ self acceptNewLiteral]! ! !SymbolListTile methodsFor: 'user interface' stamp: 'sw 3/10/2004 23:24'! adjustHelpMessage "Adjust the help message to reflect the new literal" (ScriptingSystem helpStringOrNilForOperator: literal) ifNotNilDo: [:aString | self labelMorph setBalloonText: aString]! !