[squeak-dev] The Trunk: Multilingual-nice.183.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Sep 29 12:32:40 UTC 2013


Nicolas Cellier uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-nice.183.mcz

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

Name: Multilingual-nice.183
Author: nice
Time: 29 September 2013, 2:31:44.57 pm
UUID: 854e43ab-f424-410e-9c6e-212b8adcf05b
Ancestors: Multilingual-nice.182

Fix theFirstCharCrossedX is a bit more straight replacement of crooked itsNotTheFirstCharThatCrossedX..
And it should be taken into account in (multi) display scanner, otherwise, the display scanner does not honour the composition...
Apply the fix of Graphics branch to avoid displaying the cursor at window left in centerd alignment.

=============== Diff against Multilingual-nice.182 ===============

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].
+ 	destX := leftMargin := line leftMarginForAlignment: alignment.
+ 	destY := line top.
+ 	(text isEmpty or: [(characterPoint y < destY or: [characterPoint x <destX])
- 	(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: destX at destY extent: 0 @ textStyle lineGrid)
- 					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.
  	lineStop := characterIndex	"scanning for index"
  		ifNil: [ 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] whileFalse.
  	
  	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 added:
+ ----- Method: MultiCharacterBlockScanner>>theFirstCharCrossedX (in category 'private') -----
+ theFirstCharCrossedX
+ 	"Note: it is hard to explain why, but this is required to keep selection of leftmost char possible."
+ 	^false!

Item was removed:
- ----- Method: MultiCharacterScanner>>itsNotTheFirstCharThatCrossedX (in category 'private') -----
- itsNotTheFirstCharThatCrossedX
- 	^true!

Item was changed:
  ----- Method: MultiCharacterScanner>>scanJapaneseCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanner methods') -----
  scanJapaneseCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta
  
  	| ascii encoding nextDestX startEncoding |
  	lastIndex := startIndex.
  	lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun].
  	startEncoding := (sourceString at: startIndex) leadingChar.
  	[lastIndex <= stopIndex] whileTrue: [
  		encoding := (sourceString at: lastIndex) leadingChar.
  		encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun].
  		ascii := (sourceString at: lastIndex) charCode.
  		(encoding = 0 and: [ascii < 256 and:[(stops at: ascii + 1) notNil]]) 
  			ifTrue: [^ stops at: ascii + 1].
  		(self isBreakableAt: lastIndex in: sourceString in: (EncodedCharSet charsetAt: encoding)) ifTrue: [
  			self registerBreakableIndex.
  		].
  		nextDestX := destX + (font widthOf: (sourceString at: lastIndex)).
+ 		nextDestX > rightX ifTrue: [self theFirstCharCrossedX ifFalse: [^ stops crossedX]].
- 		nextDestX > rightX ifTrue: [self itsNotTheFirstCharThatCrossedX ifTrue: [^ stops crossedX]].
  		destX := nextDestX + kernDelta.
  		lastIndex := lastIndex + 1.
  	].
  	lastIndex := stopIndex.
  	^ stops endOfRun!

Item was changed:
  ----- Method: MultiCharacterScanner>>scanMultiCharactersCombiningFrom:to:in:rightX:stopConditions:kern: (in category 'scanner methods') -----
  scanMultiCharactersCombiningFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta
  
  "appears to be unused"
  	| charCode encoding startEncoding combining combined combiningIndex c |
  	lastIndex := startIndex.
  	lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun].
  	startEncoding := (sourceString at: startIndex) leadingChar.
  	combining := nil.
  	[lastIndex <= stopIndex] whileTrue: [
  		charCode := (sourceString at: lastIndex) charCode.
  		c := (sourceString at: lastIndex).
  		combining ifNil: [
  			combining := CombinedChar new.
  			combining add: c.
  			combiningIndex := lastIndex.
  			lastIndex := lastIndex + 1.
  		] ifNotNil: [
  			(combining add: c) ifFalse: [
  				self addCharToPresentation: (combined := combining combined).
  				combining := CombinedChar new.
  				combining add: c.
  				charCode := combined charCode.
  				encoding := combined leadingChar.
  				encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1.
  					(encoding = 0 and: [charCode < 256 and:[(stops at: charCode + 1) notNil]]) ifTrue: [
  						^ stops at: charCode + 1
  					] ifFalse: [
  						 ^ stops endOfRun
  					].
  				].
  				(encoding = 0 and: [charCode < 256 and:[(stops at: charCode + 1) notNil]]) ifTrue: [
  					combining ifNotNil: [
  						self addCharToPresentation: (combining combined).
  					].
  					^ stops at: charCode + 1
  				].
  				destX > rightX ifTrue: [
+ 					self theFirstCharCrossedX ifFalse: [
- 					self itsNotTheFirstCharThatCrossedX ifTrue: [
  						lastIndex := combiningIndex.
  						self removeLastCharFromPresentation.
  						^ stops crossedX]].
  				combiningIndex := lastIndex.
  				lastIndex := lastIndex + 1.
  			] ifTrue: [
  				lastIndex := lastIndex + 1.
  			].
  		].
  	].
  	lastIndex := stopIndex.
  	combining ifNotNil: [
  		combined := combining combined.
  		self addCharToPresentation: combined.
  	].
  	^ stops endOfRun!

Item was changed:
  ----- Method: MultiCharacterScanner>>scanMultiCharactersFrom:to:in:rightX:stopConditions:kern: (in category 'scanning') -----
  scanMultiCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta
  
  	| ascii encoding nextDestX startEncoding floatDestX widthAndKernedWidth nextChar atEndOfRun |
  	lastIndex := startIndex.
  	lastIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun].
  	startEncoding := (sourceString at: startIndex) leadingChar.
  	floatDestX := destX.
  	widthAndKernedWidth := Array new: 2.
  	atEndOfRun := false.
  	[lastIndex <= stopIndex] whileTrue: [
  		encoding := (sourceString at: lastIndex) leadingChar.
  		encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun].
  		ascii := (sourceString at: lastIndex) charCode.
  		(ascii < 256 and: [(stops at: ascii + 1) ~~ nil]) ifTrue: [^ stops at: ascii + 1].
  		nextChar := (lastIndex + 1 <= stopIndex) 
  			ifTrue:[sourceString at: lastIndex + 1]
  			ifFalse:[
  				atEndOfRun := true.
  				"if there is a next char in sourceString, then get the kern 
  				and store it in pendingKernX"
  				lastIndex + 1 <= sourceString size
  					ifTrue:[sourceString at: lastIndex + 1]
  					ifFalse:[	nil]].
  		font 
  			widthAndKernedWidthOfLeft: (sourceString at: lastIndex) 
  			right: nextChar
  			into: widthAndKernedWidth.
  		nextDestX := floatDestX + (widthAndKernedWidth at: 1).
+ 		nextDestX > rightX ifTrue: [self theFirstCharCrossedX ifFalse: [^stops crossedX]].
- 		nextDestX > rightX ifTrue: [self itsNotTheFirstCharThatCrossedX ifTrue: [^stops crossedX]].
  		floatDestX := floatDestX + kernDelta + (widthAndKernedWidth at: 2).
  		atEndOfRun 
  			ifTrue:[
  				pendingKernX := (widthAndKernedWidth at: 2) - (widthAndKernedWidth at: 1).
  				floatDestX := floatDestX - pendingKernX].
  		destX := floatDestX .
  		lastIndex := lastIndex + 1.
  	].
  	lastIndex := stopIndex.
  	^ stops endOfRun!

Item was added:
+ ----- Method: MultiCharacterScanner>>theFirstCharCrossedX (in category 'private') -----
+ theFirstCharCrossedX
+ 	"Tell whether the left most char crossed the right margin boundary"
+ 	^destX = leftMargin!

Item was removed:
- ----- Method: MultiCompositionScanner>>itsNotTheFirstCharThatCrossedX (in category 'private') -----
- itsNotTheFirstCharThatCrossedX
- 	"When composing, this is used to avoid wrapping the line if the first char does not fit in composition rectangle"
- 	^destX ~= leftMargin!



More information about the Squeak-dev mailing list