The Trunk: Multilingual-fbs.164.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Multilingual-fbs.164.mcz

commits-2
Frank Shearar uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-fbs.164.mcz

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

Name: Multilingual-fbs.164
Author: fbs
Time: 2 July 2013, 10:18:42.84 pm
UUID: 83457f26-4043-914a-b92d-8b34b4a2b37e
Ancestors: Multilingual-fbs.163

This nearly severs the Multilingual -> Morphic dependency.

=============== Diff against Multilingual-fbs.163 ===============

Item was removed:
- ----- 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!

Item was removed:
- ----- Method: MultiCompositionScanner>>setFont (in category 'stop conditions') -----
- setFont
- super setFont.
- breakAtSpace := false.
- wantsColumnBreaks == true ifTrue: [
- stopConditions := stopConditions copy.
- stopConditions at: TextComposer characterForColumnBreak asciiValue + 1 put: #columnBreak.
- ].
- !

Item was removed:
- NewParagraph subclass: #MultiNewParagraph
- instanceVariableNames: 'presentationText presentationLines'
- classVariableNames: ''
- poolDictionaries: 'TextConstants'
- category: 'Multilingual-Scanning'!

Item was removed:
- ----- Method: MultiNewParagraph>>displayOn:using:at: (in category 'fonts-display') -----
- displayOn: aCanvas using: displayScanner at: somePosition
- "Send all visible lines to the displayScanner for display"
-
- | visibleRectangle offset leftInRun line |
- visibleRectangle := aCanvas clipRect.
- offset := somePosition - positionWhenComposed.
- leftInRun := 0.
- (self lineIndexForPoint: visibleRectangle topLeft)
- to: (self lineIndexForPoint: visibleRectangle bottomRight)
- do: [:i | line := lines at: i.
- self displaySelectionInLine: line on: aCanvas.
- line first <= line last ifTrue:
- [leftInRun := displayScanner displayLine: line
- offset: offset leftInRun: leftInRun]].
- !

Item was removed:
- ----- Method: MultiNewParagraph>>displayOnTest:using:at: (in category 'fonts-display') -----
- displayOnTest: aCanvas using: displayScanner at: somePosition
- "Send all visible lines to the displayScanner for display"
-
- | visibleRectangle offset leftInRun line |
- (presentationText isNil or: [presentationLines isNil]) ifTrue: [
- ^ self displayOn: aCanvas using: displayScanner at: somePosition.
- ].
- visibleRectangle := aCanvas clipRect.
- offset := somePosition - positionWhenComposed.
- leftInRun := 0.
- (self lineIndexForPoint: visibleRectangle topLeft)
- to: (self lineIndexForPoint: visibleRectangle bottomRight)
- do: [:i | line := presentationLines at: i.
- self displaySelectionInLine: line on: aCanvas.
- line first <= line last ifTrue:
- [leftInRun := displayScanner displayLine: line
- offset: offset leftInRun: leftInRun]].
- !

Item was removed:
- ----- Method: MultiNewParagraph>>multiComposeLinesFrom:to:delta:into:priorLines:atY: (in category 'composition') -----
- multiComposeLinesFrom: start to: stop delta: delta into: lineColl priorLines: priorLines
- atY: startingY
- "While the section from start to stop has changed, composition may ripple all the way to the end of the text.  However in a rectangular container, if we ever find a line beginning with the same character as before (ie corresponding to delta in the old lines), then we can just copy the old lines from there to the end of the container, with adjusted indices and y-values"
-
- | newResult composer presentationInfo |
-
- composer := MultiTextComposer new.
- presentationLines := nil.
- presentationText := nil.
- newResult := composer
- multiComposeLinesFrom: start
- to: stop
- delta: delta
- into: lineColl
- priorLines: priorLines
- atY: startingY
- textStyle: textStyle
- text: text
- container: container
- wantsColumnBreaks: wantsColumnBreaks == true.
- lines := newResult first asArray.
- maxRightX := newResult second.
- presentationInfo := composer getPresentationInfo.
- presentationLines := presentationInfo first asArray.
- presentationText := presentationInfo second.
- "maxRightX printString displayAt: 0@0."
- ^maxRightX
- !

Item was removed:
- ----- Method: MultiNewParagraph>>presentationLines (in category 'accessing') -----
- presentationLines
-
- ^ presentationLines.
- !

Item was removed:
- ----- Method: MultiNewParagraph>>presentationText (in category 'accessing') -----
- presentationText
-
- ^ presentationText.
- !

Item was removed:
- TextComposer subclass: #MultiTextComposer
- instanceVariableNames: 'presentation presentationLines'
- classVariableNames: ''
- poolDictionaries: 'TextConstants'
- category: 'Multilingual-Scanning'!

Item was removed:
- ----- Method: MultiTextComposer>>composeEachRectangleIn: (in category 'as yet unclassified') -----
- composeEachRectangleIn: rectangles
-
- | myLine lastChar |
-
- 1 to: rectangles size do: [:i |
- currCharIndex <= theText size ifFalse: [^false].
- myLine := scanner
- composeFrom: currCharIndex
- inRectangle: (rectangles at: i)
- firstLine: isFirstLine
- leftSide: i=1
- rightSide: i=rectangles size.
- lines addLast: myLine.
- presentationLines addLast: scanner getPresentationLine.
- presentation ifNil: [presentation := scanner getPresentation]
- ifNotNil: [presentation := presentation, scanner getPresentation].
- actualHeight := actualHeight max: myLine lineHeight.  "includes font changes"
- currCharIndex := myLine last + 1.
- lastChar := theText at: myLine last.
- (CharacterSet crlf includes: lastChar) ifTrue: [^#cr].
- wantsColumnBreaks ifTrue: [
- lastChar = TextComposer characterForColumnBreak ifTrue: [^#columnBreak].
- ].
- ].
- ^false!

Item was removed:
- ----- Method: MultiTextComposer>>getPresentationInfo (in category 'as yet unclassified') -----
- getPresentationInfo
-
- ^ Array with: presentationLines with: presentation.
- !

Item was removed:
- ----- Method: MultiTextComposer>>multiComposeLinesFrom:to:delta:into:priorLines:atY:textStyle:text:container:wantsColumnBreaks: (in category 'as yet unclassified') -----
- multiComposeLinesFrom: argStart to: argStop delta: argDelta into: argLinesCollection priorLines: argPriorLines atY: argStartY textStyle: argTextStyle text: argText container: argContainer wantsColumnBreaks: argWantsColumnBreaks
-
- wantsColumnBreaks := argWantsColumnBreaks.
- lines := argLinesCollection.
- presentationLines := argLinesCollection copy.
- theTextStyle := argTextStyle.
- theText := argText.
- theContainer := argContainer.
- deltaCharIndex := argDelta.
- currCharIndex := startCharIndex := argStart.
- stopCharIndex := argStop.
- prevLines := argPriorLines.
- currentY := argStartY.
- defaultLineHeight := theTextStyle lineGrid.
- maxRightX := theContainer left.
- possibleSlide := stopCharIndex < theText size and: [theContainer isMemberOf: Rectangle].
- nowSliding := false.
- prevIndex := 1.
- scanner := MultiCompositionScanner new text: theText textStyle: theTextStyle.
- scanner wantsColumnBreaks: wantsColumnBreaks.
- isFirstLine := true.
- self composeAllLines.
- isFirstLine ifTrue: ["No space in container or empty text"
- self
- addNullLineWithIndex: startCharIndex
- andRectangle: (theContainer topLeft extent: 0@defaultLineHeight)
- ] ifFalse: [
- self fixupLastLineIfCR
- ].
- ^{lines asArray. maxRightX}
-
- !

Item was removed:
- ----- Method: TTGlyph>>asFormWithScale:ascender:descender:fgColor:bgColor:depth:replaceColor:lineGlyph:lingGlyphWidth:emphasis: (in category '*Multilingual-Display-converting') -----
- asFormWithScale: scale ascender: ascender descender: descender fgColor: fgColor bgColor: bgColor depth: depth replaceColor: replaceColorFlag lineGlyph: lineGlyph lingGlyphWidth: lWidth emphasis: code
-
- | form canvas newScale |
- form := Form extent: (advanceWidth @ (ascender - descender) * scale) rounded depth: depth.
- form fillColor: bgColor.
- canvas := BalloonCanvas on: form.
- canvas aaLevel: 4.
- canvas transformBy: (MatrixTransform2x3 withScale: scale asPoint * (1 @ -1)).
- canvas transformBy: (MatrixTransform2x3 withOffset: 0 @ ascender negated).
- canvas
- drawGeneralBezierShape: self contours
- color: fgColor
- borderWidth: 0
- borderColor: fgColor.
- ((code bitAnd: 4) ~= 0 or: [(code bitAnd: 16) ~= 0]) ifTrue: [
- newScale := (form width + 1) asFloat / lineGlyph calculateWidth asFloat.
- canvas transformBy: (MatrixTransform2x3 withScale: (newScale / scale)@1.0).
-
- (code bitAnd: 4) ~= 0 ifTrue: [
- canvas
- drawGeneralBezierShape: lineGlyph contours
- color: fgColor
- borderWidth: 0
- borderColor: fgColor.
- ].
-
- (code bitAnd: 16) ~= 0 ifTrue: [
- canvas transformBy: (MatrixTransform2x3 withOffset: 0@(ascender // 2)).
- canvas
- drawGeneralBezierShape: lineGlyph contours
- color: fgColor
- borderWidth: 0
- borderColor: fgColor.
- ].
- ].
-
- replaceColorFlag ifTrue: [
- form replaceColor: bgColor withColor: Color transparent.
- ].
- ^ form!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Multilingual-fbs.164.mcz

Frank Shearar-3
On 2 July 2013 22:18,  <[hidden email]> wrote:

> Frank Shearar uploaded a new version of Multilingual to project The Trunk:
> http://source.squeak.org/trunk/Multilingual-fbs.164.mcz
>
> ==================== Summary ====================
>
> Name: Multilingual-fbs.164
> Author: fbs
> Time: 2 July 2013, 10:18:42.84 pm
> UUID: 83457f26-4043-914a-b92d-8b34b4a2b37e
> Ancestors: Multilingual-fbs.163
>
> This nearly severs the Multilingual -> Morphic dependency.
>
> =============== Diff against Multilingual-fbs.163 ===============

The last remaining dependency is:

LanguageEnvironment class >> startUp
    self clearDefault.
    Clipboard startUp.
    HandMorph startUp.

I am stumped as to how to preserve this behaviour and sever the
dependency. Smalltalk at: #HandMorph is _not_ a solution. It makes
things worse because you hide the dependency, but it's still there,
ready to bite you at a random moment.

Inlining the above into Language class >> #startUp's call sites
seems... undesirable.

Perhaps a startup registry, and HandMorph's and Clipboard's
#initialize would say something like LanguageEnvironment
registerForStartup: self ?

Thoughts?

frank

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Multilingual-fbs.164.mcz

Chris Muller-3
> The last remaining dependency is:
>
> LanguageEnvironment class >> startUp
>     self clearDefault.
>     Clipboard startUp.
>     HandMorph startUp.
>
> I am stumped as to how to preserve this behaviour and sever the
> dependency. Smalltalk at: #HandMorph is _not_ a solution. It makes
> things worse because you hide the dependency, but it's still there,
> ready to bite you at a random moment.

Not sure why it "hides it" since references to HandMorph would still
find it.  Would it still bite even with a guard?

  (Smalltalk classNamed: #HandMorph) ifNotNil: [ : cls | cls startUp ]

I suppose if someone loaded Multilingual _first_ one could get bitten
by not starting the Clipboard?  Not sure about that..

>
> Inlining the above into Language class >> #startUp's call sites
> seems... undesirable.
>
> Perhaps a startup registry, and HandMorph's and Clipboard's
> #initialize would say something like LanguageEnvironment
> registerForStartup: self ?

What about Smalltalk addToStartupList:after:?

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Multilingual-fbs.164.mcz

Frank Shearar-3
On 3 July 2013 02:46, Chris Muller <[hidden email]> wrote:

>> The last remaining dependency is:
>>
>> LanguageEnvironment class >> startUp
>>     self clearDefault.
>>     Clipboard startUp.
>>     HandMorph startUp.
>>
>> I am stumped as to how to preserve this behaviour and sever the
>> dependency. Smalltalk at: #HandMorph is _not_ a solution. It makes
>> things worse because you hide the dependency, but it's still there,
>> ready to bite you at a random moment.
>
> Not sure why it "hides it" since references to HandMorph would still
> find it.

You couldn't use "class references" (alt-shift-n) to find the
dependencies and the Dependency Browser wouldn't be able to find it.

>  Would it still bite even with a guard?
>
>   (Smalltalk classNamed: #HandMorph) ifNotNil: [ : cls | cls startUp ]
>
> I suppose if someone loaded Multilingual _first_ one could get bitten
> by not starting the Clipboard?  Not sure about that..

Yes. But also it's the wrong thing; the dependency is inverted. In
order to support some new shiny feature that needs state reset when
the LanguageEnvironment changes, I'd need to affect the base
infrastructure. I guess what I'm looking for is a callback or
announcement mechanism. "Hey guys, the LanguageEnvironment has
changed", and then Clipboard and HandMorph can say "oh right, I must
<insert state change>".

>> Inlining the above into Language class >> #startUp's call sites
>> seems... undesirable.
>>
>> Perhaps a startup registry, and HandMorph's and Clipboard's
>> #initialize would say something like LanguageEnvironment
>> registerForStartup: self ?
>
> What about Smalltalk addToStartupList:after:?

It's not an image startUp thing, but rather LanguageEnvironment class
>> #startUp is called when the Locale changes, and a few other places.

frank