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

commits at source.squeak.org commits at source.squeak.org
Fri Sep 6 21:55:51 UTC 2013


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

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

Name: Multilingual-nice.169
Author: nice
Time: 6 September 2013, 11:54:49.119 pm
UUID: 85f6772d-9dff-48e7-a768-1d83c76e0cc5
Ancestors: Multilingual-nice.168

Apply Display/Character Scanner clean-ups from Cuis to MultiCharacter* counter part:
- remove unused paragraph ivar from DisplayScanner
- remove historical dead code from #crossedX
- ifNil: simplifies code a bit

This reduces the number of differences Between single and Multi Character Scanners

=============== Diff against Multilingual-nice.168 ===============

Item was changed:
  ----- Method: MultiCharacterBlockScanner>>characterBlockAtPoint:index:in: (in category 'scanning') -----
  characterBlockAtPoint: aPoint index: index in: textLine
  	"This method is the Morphic characterBlock finder.  It combines
  	MVC's characterBlockAtPoint:, -ForIndex:, and buildCharcterBlock:in:"
  	| runLength lineStop stopCondition |
  	line := textLine.
  	rightMargin := line rightMargin.
  	lastIndex := line first.
  	self setStopConditions.		"also sets font"
  	characterIndex := index.  " == nil means scanning for point"
  	characterPoint := aPoint.
  	(characterPoint isNil or: [characterPoint y > line bottom])
  		ifTrue: [characterPoint := line bottomRight].
  	(text isEmpty or: [(characterPoint y < line top or: [characterPoint x < line left])
  				or: [characterIndex notNil and: [characterIndex < line first]]])
  		ifTrue:	[^ (CharacterBlock new stringIndex: line first text: text
  					topLeft: line leftMargin at line top extent: 0 @ textStyle lineGrid)
  					textLine: line].
  	destX := leftMargin := line leftMarginForAlignment: alignment.
  	destY := line top.
  	runLength := text runLengthFor: line first.
+ 	lineStop := characterIndex	"scanning for index"
+ 		ifNil: [ line last ].			"scanning for point"
- 	characterIndex
- 		ifNotNil:	[lineStop := characterIndex  "scanning for index"]
- 		ifNil:	[lineStop := line last  "scanning for point"].
  	runStopIndex := lastIndex + (runLength - 1) min: lineStop.
  	lastCharacterExtent := 0 @ line lineHeight.
  	spaceCount := 0.
  
  	[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."
  	self lastCharacterExtentSetX: (specialWidth
  		ifNil: [font widthOf: (text at: lastIndex)]
  		ifNotNil: [specialWidth]).
  	self perform: stopCondition] whileFalse.
  	
  	characterIndex
  			ifNil: [
  				"Result for characterBlockAtPoint: "
  				(stopCondition ~~ #cr and: [ lastIndex == line last
  					and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]])
  						ifTrue: [ "Correct for right half of last character in line"
  							^ (CharacterBlock new stringIndex: lastIndex + 1
  									text: text
  									topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0)
  									extent:  0 @ lastCharacterExtent y)
  								textLine: line ].
  					^ (CharacterBlock new stringIndex: lastIndex
  						text: text topLeft: characterPoint + (font descentKern @ 0)
  						extent: lastCharacterExtent - (font baseKern @ 0))
  								textLine: line]
  			ifNotNil: ["Result for characterBlockForIndex: "
  					^ (CharacterBlock new stringIndex: characterIndex
  						text: text topLeft: characterPoint + ((font descentKern) - kern @ 0)
  						extent: lastCharacterExtent)
  								textLine: line]!

Item was changed:
  ----- Method: MultiCharacterBlockScanner>>crossedX (in category 'stop conditions') -----
  crossedX
  	"Text display has wrapping. The scanner just found a character past the x 
  	location of the cursor. We know that the cursor is pointing at a character 
  	or before one."
  
+ 	| currentX |
- 	| leadingTab currentX |
  	characterIndex == nil ifFalse: [
  		"If the last character of the last line is a space,
  		and it crosses the right margin, then locating
  		the character block after it is impossible without this hack."
  		characterIndex > text size ifTrue: [
  			lastIndex := characterIndex.
  			characterPoint := (nextLeftMargin ifNil: [leftMargin]) @ (destY + line lineHeight).
  			^true]].
  	characterPoint x <= (destX + (lastCharacterExtent x // 2))
  		ifTrue:	[lastCharacter := (text at: lastIndex).
  				characterPoint := destX @ destY.
  				^true].
  	lastIndex >= line last 
  		ifTrue:	[lastCharacter := (text at: line last).
  				characterPoint := destX @ destY.
  				^true].
  
  	"Pointing past middle of a character, return the next character."
  	lastIndex := lastIndex + 1.
  	lastCharacter := text at: lastIndex.
  	currentX := destX + lastCharacterExtent x + kern.
  	self lastCharacterExtentSetX: (font widthOf: lastCharacter).
  	characterPoint := currentX @ destY.
  	lastCharacter = Space ifFalse: [^ true].
  
  	"Yukky if next character is space or tab."
  	alignment = Justified ifTrue:
  		[self lastCharacterExtentSetX:
+ 			(lastCharacterExtent x + 	(line justifiedPadFor: (spaceCount + 1) font: font))].
- 			(lastCharacterExtent x + 	(line justifiedPadFor: (spaceCount + 1) font: font)).
- 		^ true].
  
- 	true ifTrue: [^ true].
- 	"NOTE:  I find no value to the following code, and so have defeated it - DI"
- 
- 	"See tabForDisplay for illumination on the following awfulness."
- 	leadingTab := true.
- 	line first to: lastIndex - 1 do:
- 		[:index | (text at: index) ~= Tab ifTrue: [leadingTab := false]].
- 	(alignment ~= Justified or: [leadingTab])
- 		ifTrue:	[self lastCharacterExtentSetX: (textStyle nextTabXFrom: currentX
- 					leftMargin: leftMargin rightMargin: rightMargin) -
- 						currentX]
- 		ifFalse:	[self lastCharacterExtentSetX:  (((currentX + (textStyle tabWidth -
- 						(line justifiedTabDeltaFor: spaceCount))) -
- 							currentX) max: 0)].
  	^ true!

Item was changed:
  ----- Method: MultiCompositionScanner>>setActualFont: (in category 'scanning') -----
  setActualFont: aFont
  	"Keep track of max height and ascent for auto lineheight"
  	| descent |
  	super setActualFont: aFont.
- 	"'   ', lastIndex printString, '   ' displayAt: (lastIndex * 15)@0."
  	lineHeight == nil
  		ifTrue: [descent := font descent.
  				baseline := font ascent.
  				lineHeight := baseline + descent]
  		ifFalse: [descent := lineHeight - baseline max: font descent.
  				baseline := baseline max: font ascent.
  				lineHeight := lineHeight max: baseline + descent]!

Item was changed:
  MultiCharacterScanner subclass: #MultiDisplayScanner
+ 	instanceVariableNames: 'bitBlt lineY runX foregroundColor backgroundColor fillBlt lineHeight paragraphColor morphicOffset ignoreColorChanges'
- 	instanceVariableNames: 'bitBlt lineY runX foregroundColor backgroundColor fillBlt lineHeight paragraph paragraphColor morphicOffset ignoreColorChanges'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Multilingual-Scanning'!

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.
- 	paragraph := aParagraph.
  	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 |
  			leftMargin := aParagraph leftMarginForDisplayForLine: lineIndex alignment: (alignment ifNil:[textStyle alignment]).
  			destX := (runX := leftMargin).
  			line := aParagraph lines at: lineIndex.
  			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]]!



More information about the Squeak-dev mailing list