[squeak-dev] The Trunk: Morphic-mt.1885.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 10 11:07:22 UTC 2022


Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1885.mcz

==================== Summary ====================

Name: Morphic-mt.1885
Author: mt
Time: 10 February 2022, 12:07:16.038307 pm
UUID: a9850d3a-002b-744d-84e3-5544a16e7a32
Ancestors: Morphic-mt.1884

Fixes an issue in text morphs regarding #plainTextOnly and TextAlignment attribute. For now, I think it is okay to at least allow alignment properties to persist in plain-text fields. For example, think of a simple field with centered contents. It's more layouting than formatting... :-)

=============== Diff against Morphic-mt.1884 ===============

Item was changed:
  ----- Method: TextEditor>>zapSelectionWith: (in category 'mvc compatibility') -----
  zapSelectionWith: replacement
  
  	| start stop rep |
  	morph readOnly ifTrue: [^ self].
  	start := self startIndex.
  	stop := self stopIndex.
  	(replacement isEmpty and: [stop > start]) ifTrue: [
  		"If deleting, then set emphasisHere from 1st character of the deletion"
  		emphasisHere := (self text attributesAt: start) select: [:att | att mayBeExtended]].
  	(start = stop and: [ replacement isEmpty ]) ifFalse: [
  		morph plainTextOnly
+ 			ifTrue: [
+ 				"We support TextAlignment but nothing else. Rely on emphasisHere."
+ 				rep := Text string: replacement asString attributes: emphasisHere ]
- 			ifTrue: [ rep := replacement asString ]
  			ifFalse: [ replacement isText
  				ifTrue: [ rep := replacement]
  				ifFalse: [ rep := Text string: replacement attributes: emphasisHere ] ].
  		
  		self text replaceFrom: start to: stop - 1 with: rep.
  		paragraph
  			recomposeFrom: start
  			to:  start + rep size - 1
  			delta: rep size - (stop-start).
  		self markIndex: start pointIndex: start + rep size.
  		otherInterval := self selectionInterval].
  
  	self userHasEdited  " -- note text now dirty"!

Item was changed:
  ----- Method: TextMorph>>newContents: (in category 'accessing') -----
  newContents: stringOrText 
  	"Accept new text contents."
  	| newText embeddedMorphs oldSelection |
  	newText := stringOrText isString 
  		ifTrue: [Text fromString: stringOrText copy ]
  		ifFalse: [ stringOrText copy asText.	"should be veryDeepCopy?" ].
+ 	self plainTextOnly ifTrue: [ newText removeAttributesThat: [:att | att isTextAlignment not] ].
- 	self plainTextOnly ifTrue: [ newText removeAllAttributes ].
  
  	(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]!



More information about the Squeak-dev mailing list