[Pkg] The Trunk: Multilingual-ul.152.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jun 18 08:54:31 UTC 2011
Levente Uzonyi uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-ul.152.mcz
==================== Summary ====================
Name: Multilingual-ul.152
Author: ul
Time: 17 June 2011, 4:40:16.576 pm
UUID: bb575e1e-fd17-4041-901a-9455f0d408cd
Ancestors: Multilingual-ul.151
- Use #repeat instead of [ true ] whileTrue and friends.
=============== Diff against Multilingual-ul.151 ===============
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.
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) ifTrue:
+ [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]]] repeat!
- [false] whileFalse:
- [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) ifTrue:
- [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: MultiCompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide: (in category 'scanning') -----
composeFrom: startIndex inRectangle: lineRectangle
firstLine: firstLine leftSide: leftSide rightSide: rightSide
"Answer an instance of TextLineInterval that represents the next line in the paragraph."
| runLength stopCondition |
"Set up margins"
leftMargin := lineRectangle left.
leftSide ifTrue: [leftMargin := leftMargin +
(firstLine ifTrue: [textStyle firstIndent]
ifFalse: [textStyle restIndent])].
destX := spaceX := leftMargin.
firstDestX := destX.
rightMargin := lineRectangle right.
rightSide ifTrue: [rightMargin := rightMargin - textStyle rightIndent].
lastIndex := startIndex. "scanning sets last index"
destY := lineRectangle top.
lineHeight := baseline := 0. "Will be increased by setFont"
self setStopConditions. "also sets font"
runLength := text runLengthFor: startIndex.
runStopIndex := (lastIndex := startIndex) + (runLength - 1).
line := (TextLine start: lastIndex stop: 0 internalSpaces: 0 paddingWidth: 0)
rectangle: lineRectangle.
presentationLine := (TextLine start: lastIndex stop: 0 internalSpaces: 0 paddingWidth: 0)
rectangle: lineRectangle.
numOfComposition := 0.
spaceCount := 0.
self handleIndentation.
leftMargin := destX.
line leftMargin: leftMargin.
presentationLine leftMargin: leftMargin.
presentation := TextStream on: (Text fromString: (WideString new: text size)).
+ [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)
+ ifTrue: [presentationLine lineHeight: lineHeight + textStyle leading
+ baseline: baseline + textStyle leading.
+ ^ line lineHeight: lineHeight + textStyle leading
+ baseline: baseline + textStyle leading]] repeat!
- [false]
- whileFalse:
- [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)
- ifTrue: [presentationLine lineHeight: lineHeight + textStyle leading
- baseline: baseline + textStyle leading.
- ^ line lineHeight: lineHeight + textStyle leading
- baseline: baseline + textStyle leading]]!
Item was changed:
----- Method: MultiCompositionScanner>>composeLine:fromCharacterIndex:inParagraph: (in category 'scanning') -----
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.
baselineY := destY + 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.
presentationLine := TextLineInterval
start: lastIndex
stop: 0
internalSpaces: 0
paddingWidth: 0.
numOfComposition := 0.
presentation := TextStream on: (Text fromString: (WideString new: text size)).
spaceCount := 0.
+
+ [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)
+ ifTrue: [presentationLine lineHeight: lineHeight + textStyle leading
+ baseline: baseline + textStyle leading.
+ ^line lineHeight: lineHeight + textStyle leading
+ baseline: baseline + textStyle leading]] repeat!
- [false]
- whileFalse:
- [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)
- ifTrue: [presentationLine lineHeight: lineHeight + textStyle leading
- baseline: baseline + textStyle leading.
- ^line lineHeight: lineHeight + textStyle leading
- baseline: baseline + textStyle leading]]!
More information about the Packages
mailing list