Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.153.mcz ==================== Summary ==================== Name: ST80-nice.153 Author: nice Time: 2 October 2013, 10:33:05.329 pm UUID: 209184da-cf25-40e7-9a80-cb27e22aa125 Ancestors: ST80-nice.152 Move more MVC specific protocol of CharacterScanner from Graphics to ST80. =============== Diff against ST80-nice.152 =============== Item was added: + ----- Method: CharacterBlockScannerForMVC>>characterPointSetX: (in category 'private') ----- + characterPointSetX: xVal + characterPoint := xVal @ characterPoint y! Item was added: + ----- Method: CharacterScanner>>initializeFromParagraph:clippedBy: (in category '*ST80-Support') ----- + initializeFromParagraph: aParagraph clippedBy: clippingRectangle + + text := aParagraph text. + textStyle := aParagraph textStyle. + ! Item was added: + ----- Method: CompositionScanner>>composeLine:fromCharacterIndex:inParagraph: (in category '*ST80-Support') ----- + composeLine: lineIndex fromCharacterIndex: startIndex inParagraph: aParagraph + "Answer an instance of TextLineInterval that represents the next line in the paragraph." + | runLength stopCondition | + destX := spaceX := leftMargin := aParagraph leftMarginForCompositionForLine: lineIndex. + destY := 0. + rightMargin := aParagraph rightMarginForComposition. + leftMargin >= rightMargin ifTrue: [self error: 'No room between margins to compose']. + lastIndex := startIndex. "scanning sets last index" + lineHeight := textStyle lineGrid. "may be increased by setFont:..." + baseline := textStyle baseline. + self setStopConditions. "also sets font" + self handleIndentation. + runLength := text runLengthFor: startIndex. + runStopIndex := (lastIndex := startIndex) + (runLength - 1). + line := TextLineInterval + start: lastIndex + stop: 0 + internalSpaces: 0 + paddingWidth: 0. + nextIndexAfterLineBreak := spaceCount := 0. + lastBreakIsNotASpace := false. + + [stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex + in: text string rightX: rightMargin stopConditions: stopConditions + kern: kern. + "See setStopConditions for stopping conditions for composing." + self perform: stopCondition] whileFalse. + + ^line + lineHeight: lineHeight + textStyle leading + baseline: baseline + textStyle leading! Item was added: + ----- Method: CompositionScanner>>forParagraph: (in category '*ST80-Support') ----- + forParagraph: aParagraph + "Initialize the receiver for scanning the given paragraph." + + self + initializeFromParagraph: aParagraph + clippedBy: aParagraph clippingRectangle. + ! Item was added: + ----- Method: DisplayScanner>>displayLines:in:clippedBy: (in category '*ST80-Support') ----- + 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@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@0. + fillBlt fillColor: aParagraph backgroundColor]. + rightMargin := aParagraph rightMarginForDisplay. + lineY := aParagraph topAtLineIndex: linesInterval first. + bitBlt destForm deferUpdatesIn: visibleRectangle while: [ + linesInterval do: + [:lineIndex | + | string startIndex lastPos runLength stopCondition baselineY | + 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]. + 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@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]. + "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 added: + ----- Method: DisplayScanner>>initializeFromParagraph:clippedBy: (in category '*ST80-Support') ----- + 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 colorMap: + (Bitmap with: 0 "Assumes 1-bit deep fonts" + with: (bitBlt destForm pixelValueFor: aParagraph foregroundColor)). + bitBlt clipRect: clippingRectangle! |
Free forum by Nabble | Edit this page |