'From etoys3.0 of 24 February 2008 [latest update: #2088] on 26 August 2008 at 12:08:20 am'! "Change Set: MiniEditorFIxAug25-yo Date: 26 August 2008 Author: Yoshiki Ohshima Fix the behavior of MiniEditor. There could be a better fix to the compatibility of Pango, and not tweaking the client code like this one. But for now this should do it."! !ParagraphEditor methodsFor: 'typing support' stamp: 'yo 8/25/2008 22:22'! setEmphasisHere (paragraph textStyle fontArray size = 1 and: [paragraph text size = 0]) ifTrue: [ emphasisHere _ Array with: (TextFontReference toFont: paragraph textStyle fontArray first)] ifFalse: [ emphasisHere _ (paragraph text attributesAt: (self pointIndex - 1 max: 1) forStyle: paragraph textStyle) select: [:att | att mayBeExtended]].! ! !StringMorph methodsFor: 'editing' stamp: 'yo 8/25/2008 23:30'! launchMiniEditor: evt | textMorph | hasFocus _ true. "Really only means edit in progress for this morph" textMorph _ StringMorphEditor new contentsAsIs: contents. textMorph beAllFont: self fontToUse. textMorph usePango: self usePango. textMorph wrapFlag: true. textMorph bounds: (self bounds expandBy: 0@2). self addMorphFront: textMorph. evt hand newKeyboardFocus: textMorph. textMorph editor selectFrom: 1 to: textMorph paragraph text string size! ! !TextMorph methodsFor: 'accessing' stamp: 'nk 8/30/2004 05:43'! fontName: fontName pointSize: fontSize | newTextStyle | newTextStyle _ ((TextStyle named: fontName asSymbol) ifNil: [ TextStyle default ]) copy. newTextStyle ifNil: [self error: 'font ', fontName, ' not found.']. textStyle _ newTextStyle. text addAttribute: (TextFontChange fontNumber: (newTextStyle fontIndexOfPointSize: fontSize)). paragraph ifNotNil: [paragraph textStyle: newTextStyle]! ! !TextMorph methodsFor: 'accessing' stamp: 'nk 7/12/2003 08:39'! fontName: fontName size: fontSize | newTextStyle | newTextStyle _ ((TextStyle named: fontName asSymbol) ifNil: [ TextStyle default ]) copy. textStyle _ newTextStyle. text addAttribute: (TextFontChange fontNumber: (newTextStyle fontIndexOfSize: fontSize)). paragraph ifNotNil: [paragraph textStyle: newTextStyle]! ! !TextMorph methodsFor: 'accessing' stamp: 'nk 10/16/2003 16:42'! font: aFont | newTextStyle | newTextStyle _ aFont textStyle copy ifNil: [ TextStyle fontArray: { aFont } ]. textStyle _ newTextStyle. text addAttribute: (TextFontChange fontNumber: (newTextStyle fontIndexOf: aFont)). paragraph ifNotNil: [paragraph textStyle: newTextStyle]! ! !TextMorph methodsFor: 'initialization' stamp: 'yo 8/25/2008 23:25'! beAllFont: aFont textStyle _ TextStyle fontArray: (Array with: aFont). text addAttribute: (TextFontReference toFont: aFont). self releaseCachedState; changed! ! !StringMorphEditor methodsFor: 'event handling' stamp: 'yo 8/25/2008 23:32'! keyStroke: evt "This is hugely inefficient, but it seems to work, and it's unlikely it will ever need to be any more efficient -- it's only intended to edit single-line strings." | char newSel w | (((char _ evt keyCharacter) = Character enter) or: [(char = Character cr) or: [char = $s and: [evt commandKeyPressed]]]) ifTrue: [owner doneWithEdits; acceptContents. self flag: #arNote. "Probably unnecessary" evt hand releaseKeyboardFocus. ^ self delete]. (char = $l and: [evt commandKeyPressed]) ifTrue: "cancel" [owner cancelEdits. evt hand releaseKeyboardFocus. ^ self delete]. super keyStroke: evt. owner interimContents: self contents asString. newSel _ self editor selectionInterval. w := owner fullBounds width. self width: w + 1. self width: w. self textColor: self color. self editor selectFrom: newSel first to: newSel last. ! !