'From etoys3.0 of 24 February 2008 [latest update: #1986] on 19 June 2008 at 1:24 pm'! MultiNewParagraph subclass: #PangoParagraph instanceVariableNames: 'paragraphs pangoAttrCache ' classVariableNames: '' poolDictionaries: '' category: 'Rome-Pango'! !PangoParagraph methodsFor: 'as yet unclassified' stamp: 'yo 6/19/2008 12:08'! asPangoAttributes pangoAttrCache ifNil: [pangoAttrCache := text pangoLanguageAttributes]. ^ pangoAttrCache, text asPangoAttributes. ! ! !PangoParagraph methodsFor: 'as yet unclassified' stamp: 'yo 6/18/2008 23:52'! characterBlockAtPoint: aPoint | r b rect index | r := RomePluginCanvas composingCanvas. r ifNil: [^ super characterBlockAtPoint: aPoint]. rect := self compositionRectangle. b := CharacterBlock new. index := r pangoIndexIn: text string attributeArray: self asPangoAttributes at: (aPoint - positionWhenComposed) width: rect width height: rect height into: b. ^ b textLine: (self textLineIncludes: index).! ! !PangoParagraph methodsFor: 'as yet unclassified' stamp: 'yo 6/18/2008 23:52'! characterBlockForIndex: index | r b rect | r := RomePluginCanvas composingCanvas. r ifNil: [^ super characterBlockForIndex: index]. rect := self compositionRectangle. b := CharacterBlock new. r pangoBlockIn: text string attributeArray: self asPangoAttributes at: index at: positionWhenComposed width: rect width height: rect height into: b. ^ b textLine: (self textLineIncludes: index). ! ! !PangoParagraph methodsFor: 'as yet unclassified' stamp: 'yo 6/18/2008 23:51'! composeAll | r rect myLines w | pangoAttrCache := nil. r := RomePluginCanvas composingCanvas. r ifNil: [^ super composeAll]. rect := self compositionRectangle. myLines := (1 to: 100) collect: [:i | TextLine new]. w := r pangoComposeString: text string attributeArray: self asPangoAttributes at: rect origin width: rect width height: rect height into: myLines withWrap: true. lines := self validLines: myLines. maxRightX := w. ! ! !PangoParagraph methodsFor: 'as yet unclassified' stamp: 'yo 6/18/2008 23:52'! pangoDrawOn: aCanvas in: bnds color: c | r start stop | (aCanvas isKindOf: FormCanvas) ifFalse: [^ self]. r := RomePluginCanvas drawingCanvasFor: aCanvas. r clipRectangle: ((bnds intersect: aCanvas clipRect) translateBy: aCanvas origin). start := selectionStart ifNil: [-1] ifNotNil: [selectionStart stringIndex]. stop := selectionStop ifNil: [-1] ifNotNil: [selectionStop stringIndex]. r pangoString: text string attributeArray: self asPangoAttributes at: (positionWhenComposed + aCanvas origin) width: bnds width height: bnds height selectionStart: start selectionEnd: stop selectionColorPixel: (self insertionPointColor pixelValueForDepth: 32). r finish. ! ! !RomePluginCanvas methodsFor: '*pango' stamp: 'yo 6/19/2008 12:27'! basicUtf8StringFor: aString andIndexFor: sqIndex into: anArray nullFlag: nullFlag | converter newIndex utf8String char | converter := UTF8TextConverter new. newIndex := -1. utf8String := String streamContents: [:stream | 1 to: aString size do: [:i | char := aString at: i. i = sqIndex ifTrue: [newIndex := stream position]. converter nextPut: char toStream: stream. ]. nullFlag ifTrue: [stream nextPut: (Character value: 0)] ]. anArray at: 1 put: utf8String. anArray at: 2 put: (newIndex = -1 ifTrue: [sqIndex = -1 ifTrue: [-1] ifFalse: [utf8String size]] ifFalse: [newIndex]). ^ anArray.! ! !RomePluginCanvas methodsFor: '*pango' stamp: 'yo 6/19/2008 12:27'! primUtf8StringFor: aString andIndexFor: sqIndex into: anArray nullFlag: nullFlag ^ self basicUtf8StringFor: aString andIndexFor: sqIndex into: anArray nullFlag: nullFlag. ! ! !RomePluginCanvas methodsFor: '*pango' stamp: 'yo 6/19/2008 12:27'! utf8StringFor: aString andIndexFor: sqIndex ^ self primUtf8StringFor: aString andIndexFor: sqIndex into: (Array new: 2) nullFlag: true. ! ! !Text methodsFor: '*rome-pango' stamp: 'yo 6/19/2008 12:08'! asPangoAttributes ^ runs asPangoAttributesFor: string. ! ! !Text methodsFor: '*rome-pango' stamp: 'yo 6/18/2008 23:15'! basicPangoLanguageAttributes | stream currentTag currentStart currentEnd leadingChar converter myStream utf8Stream | self size = 0 ifTrue: [^ Array new: 0]. (string isMemberOf: ByteString) ifTrue: [^ Array new: 0]. converter := UTF8TextConverter new. myStream := ReadStream on: self string. utf8Stream := WriteStream on: (String new: self size). stream := WriteStream on: (Array new: self size//20). currentTag := (string at: 1) leadingChar. currentStart := 0. converter nextPut: myStream next toStream: utf8Stream. currentEnd := utf8Stream position. 2 to: self size do: [:e | ((leadingChar := (string at: e) leadingChar) ~= currentTag) ifTrue: [ stream nextPut: (Array with: #L with: currentStart with: currentEnd with: currentTag). currentTag := leadingChar. currentStart := currentEnd. ]. converter nextPut: myStream next toStream: utf8Stream. currentEnd := utf8Stream position. ]. stream nextPut: (Array with: #L with: currentStart with: currentEnd with: currentTag). ^ stream contents. ! ! !Text methodsFor: '*rome-pango' stamp: 'yo 6/19/2008 12:10'! pangoLanguageAttributes " | ret array | ret := self primLanguageAttributes: string lOop: #L into: (array := Array new: self size//3+10). ret isInteger ifTrue: [^ array copyFrom: 1 to: ret]. ^ ret. " ^ self basicPangoLanguageAttributes. ! ! !Text methodsFor: '*rome-pango' stamp: 'yo 6/19/2008 12:05'! primLanguageAttributes: str lOop: l into: array "" ^ self basicPangoLanguageAttributes. ! ! MultiNewParagraph subclass: #PangoParagraph instanceVariableNames: 'pangoAttrCache' classVariableNames: '' poolDictionaries: '' category: 'Rome-Pango'!