[squeak-dev] The Trunk: Multilingual-nice.182.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Sep 29 01:48:08 UTC 2013


Nicolas Cellier uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-nice.182.mcz

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

Name: Multilingual-nice.182
Author: nice
Time: 29 September 2013, 3:47:35.834 am
UUID: 646df1ad-f30e-455c-ac35-b17fe9933abf
Ancestors: Multilingual-nice.181

Reduce some differences with the CharacterScanner hierarchies:
This will fix a regression - centered Paragraph is not displayed corectly in MVC because inst. var. alignment was used before set in the scanner.
This was solved in 2003 in http://ftp.squeak.org/updates/6188CenteredTextFix-BG.cs
But the fix was applied on CharacterScanner branch only, while MultiCharacterScanner was already forked.
Then the MultiCharacterScanner displayLines:in:clippedBy: was connected in 2005 (from the timeStamp of the method, maybe not the inclusion in official images, you'll have to dig the updateStream).
Funnily, the selection did still use a CharacterBlockScanner, so was correctly centered (outside displayed text)

=============== Diff against Multilingual-nice.181 ===============

Item was changed:
  ----- Method: MultiCharacterBlockScanner>>buildCharacterBlockIn: (in category 'private') -----
  buildCharacterBlockIn: para
+ 	"This method is used by the MVC version only."
+ 	
+ 	| lineIndex runLength lineStop stopCondition |
- 	| lineIndex runLength lineStop done stopCondition |
  	"handle nullText"
  	(para numberOfLines = 0 or: [text size = 0])
  		ifTrue:	[^ CharacterBlock new stringIndex: 1  "like being off end of string"
  					text: para text
  					topLeft: (para leftMarginForDisplayForLine: 1 alignment: (alignment ifNil:[textStyle alignment]))
  								@ para compositionRectangle top
  					extent: 0 @ textStyle lineGrid].
  	"find the line"
  	lineIndex := para lineIndexOfTop: characterPoint y.
  	destY := para topAtLineIndex: lineIndex.
  	line := para lines at: lineIndex.
+ 	lastIndex := line first.
  	rightMargin := para rightMarginForDisplay.
+ 	self setStopConditions.  " also loads the font, alignment and all emphasis attributes "
  
  	(lineIndex = para numberOfLines and:
  		[(destY + line lineHeight) < characterPoint y])
  			ifTrue:	["if beyond lastLine, force search to last character"
  					self characterPointSetX: rightMargin]
  			ifFalse:	[characterPoint y < (para compositionRectangle) top
  						ifTrue: ["force search to first line"
  								characterPoint := (para compositionRectangle) topLeft].
  					characterPoint x > rightMargin
  						ifTrue:	[self characterPointSetX: rightMargin]].
+ 	destX := leftMargin := para leftMarginForDisplayForLine: lineIndex alignment: alignment.
+ 	nextLeftMargin:= para leftMarginForDisplayForLine: lineIndex+1 alignment: alignment.
+ 	runLength := text runLengthFor: line first.
+ 	lineStop := characterIndex	"scanning for index"
+ 		ifNil: [ line last ].			"scanning for point"
+ 	runStopIndex := lastIndex + (runLength - 1) min: lineStop.
- 	destX := (leftMargin := para leftMarginForDisplayForLine: lineIndex alignment: (alignment ifNil:[textStyle alignment])).
- 	nextLeftMargin:= para leftMarginForDisplayForLine: lineIndex+1 alignment: (alignment ifNil:[textStyle alignment]).
- 	lastIndex := line first.
- 
- 	self setStopConditions.		"also sets font"
- 	runLength := (text runLengthFor: line first).
- 	characterIndex == nil
- 		ifTrue:	[lineStop := line last  "characterBlockAtPoint"]
- 		ifFalse:	[lineStop := characterIndex  "characterBlockForIndex"].
- 	(runStopIndex := lastIndex + (runLength - 1)) > lineStop
- 		ifTrue:	[runStopIndex := lineStop].
  	lastCharacterExtent := 0 @ line lineHeight.
+ 	spaceCount := 0.
- 	spaceCount := 0. done  := false.
  	self handleIndentation.
  
- 	[done]
- 	whileFalse:
  	[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
  			in: text string rightX: characterPoint x
  			stopConditions: stopConditions kern: kern.
+ 	"see setStopConditions for stopping conditions for character block operations."
- 
- 	"see setStopConditions for stopping conditions for character block 	operations."
  	self lastCharacterExtentSetX: (font widthOf: (text at: lastIndex)).
+ 	self perform: stopCondition] whileFalse.
+ 
+ 	^characterIndex == nil
- 	(self perform: stopCondition) ifTrue:
- 		[characterIndex == nil
  			ifTrue: ["characterBlockAtPoint"
  					^ CharacterBlock new stringIndex: lastIndex text: text
  						topLeft: characterPoint + (font descentKern @ 0)
  						extent: lastCharacterExtent]
  			ifFalse: ["characterBlockForIndex"
  					^ CharacterBlock new stringIndex: lastIndex text: text
  						topLeft: characterPoint + ((font descentKern) - kern @ 0)
+ 						extent: lastCharacterExtent]!
- 						extent: lastCharacterExtent]]]!

Item was changed:
  ----- Method: MultiDisplayScanner>>displayLine:offset:leftInRun: (in category 'scanning') -----
  displayLine: textLine offset: offset leftInRun: leftInRun
  	"The call on the primitive (scanCharactersFrom:to:in:rightX:) will be interrupted according to an array of stop conditions passed to the scanner at which time the code to handle the stop condition is run and the call on the primitive continued until a stop condition returns true (which means the line has terminated).  leftInRun is the # of characters left to scan in the current run; when 0, it is time to call setStopConditions."
  	| stopCondition nowLeftInRun startIndex string lastPos baselineY |
  	line := textLine.
  	morphicOffset := offset.
  	lineY := line top + offset y.
  	lineHeight := line lineHeight.
  	rightMargin := line rightMargin + offset x.
  	lastIndex := line first.
  	leftInRun <= 0 ifTrue: [self setStopConditions].
  	leftMargin := (line leftMarginForAlignment: alignment) + offset x.
  	destX := runX := leftMargin.
  	fillBlt == nil ifFalse:
  		["Not right"
  		fillBlt destX: line left destY: lineY
  			width: line width left height: lineHeight; copyBits].
  	lastIndex := line first.
  	leftInRun <= 0
  		ifTrue: [nowLeftInRun := text runLengthFor: lastIndex]
  		ifFalse: [nowLeftInRun := leftInRun].
  	baselineY := lineY + line baseline.
  	destY := baselineY - font ascent.
  	runStopIndex := lastIndex + (nowLeftInRun - 1) min: line last.
  	spaceCount := 0.
  	string := text string.
  	[
+ 		"remember where this portion of the line starts"
  		startIndex := lastIndex.
  		lastPos := destX at destY.
+ 		
+ 		"find the end of this portion of the line"
  		stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
  						in: string rightX: rightMargin stopConditions: stopConditions
  						kern: kern.
+ 
+ 		"display that portion of the line"
  		lastIndex >= startIndex ifTrue:[
  			bitBlt displayString: string 
  				from: startIndex 
  	"XXXX: The following is an interesting bug. All stopConditions exept #endOfRun
  		have lastIndex past the last character displayed. #endOfRun sets it *on* the character.
  		If we display up until lastIndex then we will also display invisible characters like
  		CR and tab. This problem should be fixed in the scanner (i.e., position lastIndex
  		consistently) but I don't want to deal with the fallout right now so we keep the
  		fix minimally invasive."
  				to: (stopCondition == #endOfRun ifTrue:[lastIndex] ifFalse:[lastIndex-1])
  				at: lastPos kern: kern baselineY: baselineY font: font].
  		(emphasisCode allMask: 4) ifTrue:[
  			font displayUnderlineOn: bitBlt from: lastPos x at baselineY to: destX at baselineY.
  		].
  		(emphasisCode allMask: 16) ifTrue:[
  			font displayStrikeoutOn: bitBlt from: lastPos x at baselineY to: destX at baselineY.
  		].
+ 	
+ 		"handle the stop condition"
  		"see setStopConditions for stopping conditions for displaying."
  		self perform: stopCondition.
- 		"or: [lastIndex > runStopIndex]."
  	] whileFalse.
  	^ runStopIndex - lastIndex   "Number of characters remaining in the current run"!

Item was changed:
  ----- Method: MultiDisplayScanner>>displayLines:in:clippedBy: (in category 'MVC-compatibility') -----
  displayLines: linesInterval in: aParagraph clippedBy: visibleRectangle
  	"The central display routine. The call on the primitive 
  	(scanCharactersFrom:to:in:rightX:) will be interrupted according to an 
  	array of stop conditions passed to the scanner at which time the code to 
  	handle the stop condition is run and the call on the primitive continued 
  	until a stop condition returns true (which means the line has 
  	terminated)."
  	| leftInRun |
  	"leftInRun is the # of characters left to scan in the current run;
  		when 0, it is time to call 'self setStopConditions'"
  	morphicOffset := 0 at 0.
  	leftInRun := 0.
  	self initializeFromParagraph: aParagraph clippedBy: visibleRectangle.
  	ignoreColorChanges := false.
  	foregroundColor := paragraphColor := aParagraph foregroundColor.
  	backgroundColor := aParagraph backgroundColor.
  	aParagraph backgroundColor isTransparent
  		ifTrue: [fillBlt := nil]
  		ifFalse: [fillBlt := bitBlt copy.  "Blt to fill spaces, tabs, margins"
  				fillBlt sourceForm: nil; sourceOrigin: 0 at 0.
  				fillBlt fillColor: aParagraph backgroundColor].
  	rightMargin := aParagraph rightMarginForDisplay.
  	lineY := aParagraph topAtLineIndex: linesInterval first.
  	bitBlt destForm deferUpdatesIn: visibleRectangle while: [
  		linesInterval do: 
  			[:lineIndex | 
  			| runLength stopCondition startIndex string lastPos baselineY |
- 			leftMargin := aParagraph leftMarginForDisplayForLine: lineIndex alignment: (alignment ifNil:[textStyle alignment]).
- 			destX := (runX := leftMargin).
  			line := aParagraph lines at: lineIndex.
+ 			lastIndex := line first.
+ 			leftInRun <= 0
+ 				ifTrue: [self setStopConditions.  "also sets the font, alignment and emphasisCode"
+ 						leftInRun := text runLengthFor: line first].
+ 			leftMargin := aParagraph leftMarginForDisplayForLine: lineIndex alignment: alignment.
+ 			destX := (runX := leftMargin).
  			lineHeight := line lineHeight.
  			fillBlt == nil ifFalse:
  				[fillBlt destX: visibleRectangle left destY: lineY
  					width: visibleRectangle width height: lineHeight; copyBits].
- 			lastIndex := line first.
- 			leftInRun <= 0
- 				ifTrue: [self setStopConditions.  "also sets the font"
- 						leftInRun := text runLengthFor: line first].
  			baselineY := lineY + line baseline.
  			destY := baselineY - font ascent.  "Should have happened in setFont"
  			runLength := leftInRun.
  			runStopIndex := lastIndex + (runLength - 1) min: line last.
  			leftInRun := leftInRun - (runStopIndex - lastIndex + 1).
  			spaceCount := 0.
  			string := text string.
  			self handleIndentation.
  			[
  				startIndex := lastIndex.
  				lastPos := destX at destY.
  				stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
  							in: string rightX: rightMargin stopConditions: stopConditions
  							kern: kern.
  				lastIndex >= startIndex ifTrue:[
  					font displayString: string on: bitBlt 
  						from: startIndex to: lastIndex at: lastPos kern: kern baselineY: baselineY].
  				"see setStopConditions for stopping conditions for displaying."
  				self perform: stopCondition
  			] whileFalse.
  			fillBlt == nil ifFalse:
  				[fillBlt destX: destX destY: lineY width: visibleRectangle right-destX height: lineHeight; copyBits].
  			lineY := lineY + lineHeight]]!

Item was changed:
  ----- Method: MultiDisplayScanner>>initializeFromParagraph:clippedBy: (in category 'MVC-compatibility') -----
  initializeFromParagraph: aParagraph clippedBy: clippingRectangle
  
  	super initializeFromParagraph: aParagraph clippedBy: clippingRectangle.
  	bitBlt := BitBlt asGrafPort toForm: aParagraph destinationForm.
  	bitBlt sourceX: 0; width: 0.	"Init BitBlt so that the first call to a primitive will not fail"
+ 	bitBlt combinationRule:
+ 		((Display depth = 1)
+ 			ifTrue:
+ 				[aParagraph rule]
+ 			ifFalse:
+ 				[Form paint]).
- 	bitBlt combinationRule: Form paint.
  	bitBlt colorMap:
  		(Bitmap with: 0      "Assumes 1-bit deep fonts"
  				with: (bitBlt destForm pixelValueFor: aParagraph foregroundColor)).
  	bitBlt clipRect: clippingRectangle.
  !



More information about the Squeak-dev mailing list