[Pkg] The Trunk: Graphics-nice.262.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Oct 9 22:33:54 UTC 2013


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

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

Name: Graphics-nice.262
Author: nice
Time: 10 October 2013, 12:32:44.537 am
UUID: 841347d4-6f43-4213-a27b-1c7a2bba5826
Ancestors: Graphics-nice.261

Change the DisplayScanner loop:
- don't let endOfRun immediately change the font (setStopConditions) but just emit the stopConditionsMustBeReset request
- since the font is not reset, now perform: stopCondition before dispalying the string.
this enable using the lastDisplayableIndex rather than trying to double the job of stopCondition and grumbling against inhomogeneous lastIndex(ing).

=============== Diff against Graphics-nice.261 ===============

Item was changed:
  ----- Method: DisplayScanner>>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 lineHeight stop |
- 	| stopCondition nowLeftInRun startIndex string lastPos lineHeight |
  	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 := leftMargin.
  	fillBlt == nil ifFalse:
  		["Not right"
  		fillBlt destX: line left destY: lineY
  			width: line width left height: lineHeight; copyBits].
  	lastDisplayableIndex := lastIndex := line first.
  	leftInRun <= 0
  		ifTrue: [nowLeftInRun := text runLengthFor: lastIndex]
  		ifFalse: [nowLeftInRun := leftInRun].
  	destY := lineY + line baseline - 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.
  		
+ 		"reset the stopping conditions of this displaying loop, and also the font."
+ 		stopConditionsMustBeReset
+ 			ifTrue:[self setStopConditions].
+ 		
  		"find the end of this portion of the line"
  		stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
  						in: string rightX: rightMargin stopConditions: stopConditions
  						kern: kern.
+ 		"handle the stop condition - this will also set lastDisplayableIndex"
+ 		stop := self perform: stopCondition.
- 						
- 		"Dsiplay a character that crosses the right margin if first char of the line"
- 		stopCondition == #crossedX ifTrue: [self advanceIfFirstCharOfLine].
  		
  		"display that portion of the line"
+ 		lastDisplayableIndex >= startIndex ifTrue:[
- 		lastIndex >= startIndex ifTrue:[
  			font displayString: string on: bitBlt 
  				from: startIndex 
+ 				to: lastDisplayableIndex 
- 	"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].
+ 		
+ 		"if the stop condition were true, stop the loop"
+ 		stop
- 
- 		"handle the stop condition"
- 		"see setStopConditions for stopping conditions for displaying."
- 		self perform: stopCondition
  	] whileFalse.
  	^ runStopIndex - lastIndex   "Number of characters remaining in the current run"!

Item was changed:
  ----- Method: DisplayScanner>>endOfRun (in category 'stop conditions') -----
  endOfRun
  	"The end of a run in the display case either means that there is actually 
  	a change in the style (run code) to be associated with the string or the 
  	end of this line has been reached."
  	| runLength |
  	lastDisplayableIndex := lastIndex.
  	lastIndex = line last ifTrue: [^true].
  	runLength := text runLengthFor: (lastIndex := lastIndex + 1).
  	runStopIndex := lastIndex + (runLength - 1) min: line last.
+ 	"differ reset of stopConditions and font AFTER the dispaly of last scanned string"
  	stopConditionsMustBeReset := true.
- 	self setStopConditions.
  	^ false!



More information about the Packages mailing list