Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.231.mcz ==================== Summary ==================== Name: Graphics-nice.231 Author: nice Time: 27 September 2013, 12:59:10.281 am UUID: 979ed33a-fbb0-424d-8752-728ddc71c5b8 Ancestors: Graphics-tpr.230 Let CharacterScanner properly handle #space stopCondition. Restore DefaultStopsCondition at Space to just #space as it should. Remove NilCondition and SpaceCondition. Add a ColumnBreakStopConditions, this avoids any reason to copy the stopConditions. Set stopConditions where it should be set (not in setFont, that's too weird). =============== Diff against Graphics-tpr.230 =============== Item was removed: - ----- Method: CharacterBlockScanner>>setStopConditions (in category 'stop conditions') ----- - setStopConditions - "Set the font and the stop conditions for the current run." - - self setFont. - self setConditionArray: (alignment = Justified ifTrue: [#paddedSpace]). - ! Item was added: + ----- Method: CharacterBlockScanner>>space (in category 'stop conditions') ----- + space + "Account for spaceWidth" + + spaceCount := spaceCount + 1. + lastSpaceOrTabExtent := lastCharacterExtent copy. + self lastSpaceOrTabExtentSetX: spaceWidth. + (destX + lastSpaceOrTabExtent x) >= characterPoint x + ifTrue: [lastCharacterExtent := lastSpaceOrTabExtent copy. + ^self crossedX]. + lastIndex := lastIndex + 1. + destX := destX + lastSpaceOrTabExtent x. + ^ false + ! Item was changed: Object subclass: #CharacterScanner instanceVariableNames: 'destX lastIndex destY stopConditions text textStyle alignment leftMargin rightMargin font line runStopIndex spaceCount spaceWidth emphasisCode kern indentationLevel wantsColumnBreaks pendingKernX' + classVariableNames: 'ColumnBreakStopConditions DefaultStopConditions PaddedSpaceCondition' - classVariableNames: 'DefaultStopConditions NilCondition PaddedSpaceCondition SpaceCondition' poolDictionaries: 'TextConstants' category: 'Graphics-Text'! !CharacterScanner commentStamp: '<historical>' prior: 0! My instances hold the state associated with scanning text. My subclasses scan characters for specified purposes, such as computing a CharacterBlock or placing characters into Forms.! Item was changed: ----- Method: CharacterScanner class>>initialize (in category 'class initialization') ----- initialize " CharacterScanner initialize " | a | a := TextStopConditions new. a at: 1 + 1 put: #embeddedObject. + a at: Space asciiValue + 1 put: #space. a at: Tab asciiValue + 1 put: #tab. a at: CR asciiValue + 1 put: #cr. a at: Character lf asciiValue + 1 put: #cr. - NilCondition := a copy. DefaultStopConditions := a copy. + ColumnBreakStopConditions := a copy. + ColumnBreakStopConditions at: TextComposer characterForColumnBreak asciiValue + 1 put: #columnBreak. + PaddedSpaceCondition := a copy. PaddedSpaceCondition at: Space asciiValue + 1 put: #paddedSpace. - - SpaceCondition := a copy. - SpaceCondition at: Space asciiValue + 1 put: #space. ! Item was changed: ----- Method: CharacterScanner>>historicalScanCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') ----- historicalScanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta "Primitive. This is the inner loop of text display--but see scanCharactersFrom: to:rightX: which would get the string, stopConditions and displaying from the instance. March through source String from startIndex to stopIndex. If any character is flagged with a non-nil entry in stops, then return the corresponding value. Determine width of each character from xTable, indexed by map. If dextX would exceed rightX, then return stops at: 258. Advance destX by the width of the character. If stopIndex has been reached, then return stops at: 257. Optional. See Object documentation whatIsAPrimitive. Historical note: this primitive has been unusable since about Squeak 2.8 when the shape of the CharracterScanner class changed. It is left here as a reminder that the actual primitive still needs supporting in the VM to keep old images such as Scratch1.4 alive - tpr" | ascii nextDestX char | <primitive: 103> lastIndex _ startIndex. [lastIndex <= stopIndex] whileTrue: + [char := (sourceString at: lastIndex). + ascii := char asciiValue + 1. - [char _ (sourceString at: lastIndex). - ascii _ char asciiValue + 1. (stops at: ascii) == nil ifFalse: [^stops at: ascii]. "Note: The following is querying the font about the width since the primitive may have failed due to a non-trivial mapping of characters to glyphs or a non-existing xTable." + nextDestX := destX + (font widthOf: char). - nextDestX _ destX + (font widthOf: char). nextDestX > rightX ifTrue: [^stops at: CrossedX]. + destX := nextDestX + kernDelta. + lastIndex := lastIndex + 1]. + lastIndex := stopIndex. - destX _ nextDestX + kernDelta. - lastIndex _ lastIndex + 1]. - lastIndex _ stopIndex. ^stops at: EndOfRun ! Item was changed: ----- Method: CharacterScanner>>setConditionArray: (in category 'private') ----- + setConditionArray: aStopConditionOrNil + "This method is to be removed" - setConditionArray: aSymbol + ^stopConditions := DefaultStopConditions! - aSymbol == #paddedSpace ifTrue: [^stopConditions := PaddedSpaceCondition copy]. - aSymbol == #space ifTrue: [^stopConditions := SpaceCondition copy]. - aSymbol == nil ifTrue: [^stopConditions := NilCondition copy]. - self error: 'undefined stopcondition for space character'. - ! Item was added: + ----- Method: CharacterScanner>>setStopConditions (in category 'private') ----- + setStopConditions + "Set the font and the stop conditions for the current run." + + self setFont. + self setStopConditionsOrNil: (alignment = Justified ifTrue: [PaddedSpaceCondition])! Item was added: + ----- Method: CharacterScanner>>setStopConditionsOrNil: (in category 'private') ----- + setStopConditionsOrNil: aStopConditionOrNil + + aStopConditionOrNil ifNotNil: [^stopConditions := aStopConditionOrNil]. + ^stopConditions := DefaultStopConditions! Item was removed: - ----- Method: CompositionScanner>>setFont (in category 'stop conditions') ----- - setFont - super setFont. - stopConditions == DefaultStopConditions - ifTrue:[stopConditions := stopConditions copy]. - stopConditions at: Space asciiValue + 1 put: #space. - wantsColumnBreaks == true ifTrue: [ - stopConditions at: TextComposer characterForColumnBreak asciiValue + 1 put: #columnBreak. - ]. - ! Item was changed: ----- Method: CompositionScanner>>setStopConditions (in category 'stop conditions') ----- setStopConditions "Set the font and the stop conditions for the current run." + self setFont. + self setStopConditionsOrNil: (wantsColumnBreaks == true ifTrue: [ColumnBreakStopConditions])! - self setFont! Item was removed: - ----- Method: DisplayScanner>>setStopConditions (in category 'stop conditions') ----- - setStopConditions - "Set the font and the stop conditions for the current run." - - self setFont. - self setConditionArray: (alignment = Justified ifTrue: [#paddedSpace]). - - " - alignment = Justified ifTrue: [ - stopConditions == DefaultStopConditions - ifTrue:[stopConditions := stopConditions copy]. - stopConditions at: Space asciiValue + 1 put: #paddedSpace] - "! Item was added: + ----- Method: DisplayScanner>>space (in category 'stop conditions') ----- + space + "Don't display the space, just skip the spaceWidth." + + spaceCount := spaceCount + 1. + destX := destX + spaceWidth. + lastIndex := lastIndex + 1. + pendingKernX := 0. + ^ false! Item was removed: - ----- Method: SegmentScanner>>setFont (in category 'private') ----- - setFont - super setFont. - "Make a local copy of stop conditions so we don't modify the default" - stopConditions == DefaultStopConditions - ifTrue:[stopConditions := stopConditions copy]. - stopConditions at: Space asciiValue + 1 put: nil.! Item was added: + ----- Method: SegmentScanner>>setStopConditionsOrNil: (in category 'private') ----- + setStopConditionsOrNil: aStopConditionOrNil + + aStopConditionOrNil ifNotNil: [^stopConditions := aStopConditionOrNil]. + stopConditions := DefaultStopConditions copy. + stopConditions at: Space asciiValue + 1 put: nil. + ^stopConditions! |
Free forum by Nabble | Edit this page |