[squeak-dev] Re: The Trunk: Morphic-pre.1192.mcz

marcel.taeumel Marcel.Taeumel at hpi.de
Thu Jul 21 14:57:36 UTC 2016


commits-2 wrote
> Patrick Rein uploaded a new version of Morphic to project The Trunk:
> http://source.squeak.org/trunk/Morphic-pre.1192.mcz
> 
> ==================== Summary ====================
> 
> Name: Morphic-pre.1192
> Author: pre
> Time: 20 July 2016, 11:03:12.063382 pm
> UUID: bd2a03f6-120a-d543-af91-d4535051c547
> Ancestors: Morphic-mt.1191
> 
> Removing code from the TextMorph which copied text attributes from the old
> content to the new content in certain cases.
> 
> =============== Diff against Morphic-mt.1191 ===============
> 
> Item was changed:
>   ----- Method: TextMorph>>newContents: (in category 'accessing') -----
>   newContents: stringOrText 
>   	"Accept new text contents."
>   	| newText embeddedMorphs oldSelection |
>   	"If my text is all the same font, use the font for my new contents"
> + 	newText := stringOrText isString 
> + 		ifTrue: [Text fromString: stringOrText copy ]
> + 		ifFalse: [ stringOrText copy asText.	"should be veryDeepCopy?" ].
> - 	newText := stringOrText isString ifTrue: [ | textSize |
> - 		(text notNil
> - 		  and: [ (textSize := text size) > 0
> - 		    and: [ (text runLengthFor: 1) = textSize ]]) ifTrue: [ | attribs |
> - 			attribs := text attributesAt: 1 forStyle: textStyle.
> - 			Text string: stringOrText copy attributes: attribs.
> - 		]
> - 		ifFalse: [ Text fromString: stringOrText copy ]
> - 	]
> - 	ifFalse: [ stringOrText copy asText.	"should be veryDeepCopy?" ].
>   
>   	(text = newText and: [text runs = newText runs]) ifTrue: [^ self].	"No
> substantive change"
>   	text ifNotNil: [(embeddedMorphs := text embeddedMorphs)
>   			ifNotNil: 
>   				[self removeAllMorphsIn: embeddedMorphs.
>   				embeddedMorphs do: [:m | m delete]]].
>   
>   	oldSelection := editor ifNotNil: [:ed | ed selectionInterval].
>   	text := newText.
>   
>   	"add all morphs off the visible region; they'll be moved into the right 
>   	place when they become visible. (this can make the scrollable area too 
>   	large, though)"
>   	newText embeddedMorphs do: 
>   		[:m | 
>   		self addMorph: m.
>   		m position: -1000 @ 0].
>   	self releaseParagraph.
>   	"update the paragraph cache"
>   	self paragraph.
>   	oldSelection ifNotNil: [:sel | self selectFrom: sel first to: sel
> last].
>   	"re-instantiate to set bounds"
>   	self world ifNotNil: [self world startSteppingSubmorphsOf: self]!

Hi Patrick,

this does the same job:

...
newText := stringOrText copy asText.
...

Because Text >> #asText does not create a new instance of Text for a Text.

Best,
Marcel



--
View this message in context: http://forum.world.st/The-Trunk-Morphic-pre-1192-mcz-tp4907285p4907364.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.


More information about the Squeak-dev mailing list