Nicolas Cellier uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-nice.328.mcz ==================== Summary ==================== Name: Morphic-nice.328 Author: nice Time: 8 February 2010, 5:37:56.592 pm UUID: 53182147-82fd-3043-b27b-6b1ef256b8c5 Ancestors: Morphic-nice.327 deprecate #lineIndexForCharacter: in favour of #lineIndexOfCharacterIndex: The two selectors did already coexist. The later is preferred because both understood by st80 (Paragraph) and more descriptive. =============== Diff against Morphic-nice.327 =============== Item was changed: ----- Method: NewParagraph>>selectionRectsFrom:to: (in category 'selection') ----- selectionRectsFrom: characterBlock1 to: characterBlock2 "Return an array of rectangles representing the area between the two character blocks given as arguments." | line1 line2 rects cb1 cb2 w | characterBlock1 <= characterBlock2 ifTrue: [cb1 := characterBlock1. cb2 := characterBlock2] ifFalse: [cb2 := characterBlock1. cb1 := characterBlock2]. cb1 = cb2 ifTrue: [w := self caretWidth. ^ Array with: (cb1 topLeft - (w@0) corner: cb1 bottomLeft + ((w+1)@0))]. + line1 := self lineIndexOfCharacterIndex: cb1 stringIndex. + line2 := self lineIndexOfCharacterIndex: cb2 stringIndex. - line1 := self lineIndexForCharacter: cb1 stringIndex. - line2 := self lineIndexForCharacter: cb2 stringIndex. line1 = line2 ifTrue: [^ Array with: (cb1 topLeft corner: cb2 bottomRight)]. rects := OrderedCollection new. rects addLast: (cb1 topLeft corner: (lines at: line1) bottomRight). line1+1 to: line2-1 do: [ :i | | line | line := lines at: i. (line left = rects last left and: [ line right = rects last right ]) ifTrue: [ "new line has same margins as old one -- merge them, so that the caller gets as few rectangles as possible" | lastRect | lastRect := rects removeLast. rects add: (lastRect bottom: line bottom) ] ifFalse: [ "differing margins; cannot merge" rects add: line rectangle ] ]. rects addLast: ((lines at: line2) topLeft corner: cb2 bottomLeft). ^ rects! Item was changed: ----- Method: NewParagraph>>characterBlockForIndex: (in category 'selection') ----- characterBlockForIndex: index "Answer a CharacterBlock for the character in text at index." | line | + line := lines at: (self lineIndexOfCharacterIndex: index). - line := lines at: (self lineIndexForCharacter: index). ^ ((text string isWideString) ifTrue: [ MultiCharacterBlockScanner new text: text textStyle: textStyle ] ifFalse: [ CharacterBlockScanner new text: text textStyle: textStyle ]) characterBlockAtPoint: nil index: ((index max: line first) min: text size+1) in: line! Item was changed: ----- Method: NewParagraph>>lineIndexForCharacter: (in category 'private') ----- + lineIndexForCharacter: characterIndex + "Deprecated" + + ^self lineIndexOfCharacterIndex: characterIndex ! - lineIndexForCharacter: index - "Answer the index of the line in which to select the character at index." - ^ (self fastFindFirstLineSuchThat: [:line | line first > index]) - 1 max: 1! Item was changed: ----- Method: NewParagraph>>lineIndexOfCharacterIndex: (in category 'private') ----- + lineIndexOfCharacterIndex: index + "Answer the index of the line in which to select the character at index." + ^ (self fastFindFirstLineSuchThat: [:line | line first > index]) - 1 max: 1! - lineIndexOfCharacterIndex: characterIndex - "Answer the line index for a given characterIndex." - "apparently the selector changed with NewParagraph" - - ^self lineIndexForCharacter: characterIndex - ! Item was changed: ----- Method: NewParagraph>>recomposeFrom:to:delta: (in category 'composition') ----- recomposeFrom: start to: stop delta: delta "Recompose this paragraph. The altered portion is between start and stop. Recomposition may continue to the end of the text, due to a ripple effect. Delta is the amount by which the current text is longer than it was when its current lines were composed." | startLine newLines | "Have to recompose line above in case a word-break was affected." + startLine := (self lineIndexOfCharacterIndex: start) - 1 max: 1. - startLine := (self lineIndexForCharacter: start) - 1 max: 1. [startLine > 1 and: [(lines at: startLine-1) top = (lines at: startLine) top]] whileTrue: [startLine := startLine - 1]. "Find leftmost of line pieces" newLines := OrderedCollection new: lines size + 1. 1 to: startLine-1 do: [:i | newLines addLast: (lines at: i)]. text string isOctetString ifTrue: [ ^ self composeLinesFrom: (lines at: startLine) first to: stop delta: delta into: newLines priorLines: lines atY: (lines at: startLine) top. ]. self multiComposeLinesFrom: (lines at: startLine) first to: stop delta: delta into: newLines priorLines: lines atY: (lines at: startLine) top. ! |
Free forum by Nabble | Edit this page |