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

commits at source.squeak.org commits at source.squeak.org
Fri Sep 27 20:50:40 UTC 2013


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

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

Name: Multilingual-nice.179
Author: nice
Time: 27 September 2013, 10:50:01.56 pm
UUID: db50e584-fe6f-4a0c-b200-72b2e6074e5c
Ancestors: Multilingual-nice.178

Remove usage of baselineY inst. var. (I did not removed the inst var yet).
The inst var. where always computed where used, so it can become temp.
This makes one difference less with CharacterScanner hierarchy.

=============== Diff against Multilingual-nice.178 ===============

Item was changed:
  ----- Method: MultiCanvasCharacterScanner>>setFont (in category 'private') -----
  setFont
+ 	| baselineY |
  	foregroundColor ifNil: [foregroundColor := Color black].
  	super setFont.
  	baselineY := lineY + line baseline.
  	destY := baselineY - font ascent.!

Item was changed:
  ----- Method: MultiCharacterBlockScanner>>cr (in category 'stop conditions') -----
  cr 
  	"Answer a CharacterBlock that specifies the current location of the mouse 
  	relative to a carriage return stop condition that has just been 
  	encountered. The ParagraphEditor convention is to denote selections by 
  	CharacterBlocks, sometimes including the carriage return (cursor is at 
  	the end) and sometimes not (cursor is in the middle of the text)."
  
  	((characterIndex ~= nil
  		and: [characterIndex > text size])
  			or: [(line last = text size)
  				and: [(destY + line lineHeight) < characterPoint y]])
  		ifTrue:	["When off end of string, give data for next character"
  				destY := destY +  line lineHeight.
- 				baselineY := line lineHeight.
  				lastCharacter := nil.
  				characterPoint := (nextLeftMargin ifNil: [leftMargin]) @ destY.
  				(lastIndex < text size and: [(text at: lastIndex) = CR and: [(text at: lastIndex+1) = Character lf]])
  					ifTrue: [lastIndex := lastIndex + 2]
  					ifFalse: [lastIndex := lastIndex + 1].
  				self lastCharacterExtentSetX: 0.
  				^ true].
  		lastCharacter := CR.
  		characterPoint := destX @ destY.
  		self lastCharacterExtentSetX: rightMargin - destX.
  		^true!

Item was changed:
  ----- Method: MultiCharacterScanner>>measureString:inFont:from:to: (in category 'scanning') -----
  measureString: aString inFont: aFont from: startIndex to: stopIndex
  	"WARNING: In order to use this method the receiver has to be set up using #initializeStringMeasurer"
  	destX := destY := lastIndex := 0.
- 	baselineY := aFont ascent.
  	font := aFont.
  	pendingKernX := 0.
  	kern := 0 - font baseKern.
  	spaceWidth := font widthOf: Space.
  	
  	self scanCharactersFrom: startIndex to: stopIndex in: aString rightX: 999999 stopConditions: stopConditions kern: kern.
  	^destX!

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 |
- 	| stopCondition nowLeftInRun startIndex string lastPos |
  	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.
  	[
  		startIndex := lastIndex.
  		lastPos := destX at destY.
  		stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
  						in: string rightX: rightMargin stopConditions: stopConditions
  						kern: kern.
  		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.
  		].
  		"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 |
- 			| 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]]!

Item was changed:
  ----- Method: MultiDisplayScanner>>placeEmbeddedObject: (in category 'scanning') -----
  placeEmbeddedObject: anchoredMorph
  	anchoredMorph relativeTextAnchorPosition ifNotNil:[
  		anchoredMorph position: 
  			anchoredMorph relativeTextAnchorPosition +
  			(anchoredMorph owner textBounds origin x @ 0)
  			- (0 at morphicOffset y) + (0 at lineY).
  		^true
  	].
  	(super placeEmbeddedObject: anchoredMorph) ifFalse: [^ false].
  	(anchoredMorph isMorph or: [anchoredMorph isPrimitiveCostume]) ifTrue: [
  		anchoredMorph position: ((destX - anchoredMorph width)@lineY) - morphicOffset
+ 	] ifFalse: [| baselineY |
- 	] ifFalse: [
  		destY := lineY.
  		baselineY := lineY + anchoredMorph height..
  		runX := destX.
  		anchoredMorph 
  			displayOn: bitBlt destForm 
  			at: destX - anchoredMorph width @ destY
  			clippingBox: bitBlt clipRect
  			rule: Form blend
  			fillColor: Color white 
  	].
  	^ true!

Item was changed:
  ----- Method: MultiDisplayScanner>>setFont (in category 'private') -----
  setFont 
  	foregroundColor := paragraphColor.
  	super setFont.  "Sets font and emphasis bits, and maybe foregroundColor"
  	font installOn: bitBlt foregroundColor: foregroundColor backgroundColor: Color transparent.
+ 	text ifNotNil:[| baselineY |
- 	text ifNotNil:[
  		baselineY := lineY + line baseline.
  		destY := baselineY - font ascent].
  !



More information about the Squeak-dev mailing list