The Trunk: Morphic-nice.1314.mcz

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

The Trunk: Morphic-nice.1314.mcz

commits-2
Nicolas Cellier uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-nice.1314.mcz

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

Name: Morphic-nice.1314
Author: nice
Time: 27 October 2016, 4:18:33.359635 am
UUID: bb709001-2190-4eb8-87cf-089aa0b2b1d9
Ancestors: Morphic-nice.1313

Fix text selection over long word flowing on next line again.

Err, I discarded the following change thinking that it was not necessary.
But selectionChanged will call it and is triggered by handleInteraction:fromEvent:

=============== Diff against Morphic-nice.1313 ===============

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.
+ cb1 top = (lines at: line1) top
+ ifFalse:
+ ["a word did not fit on prev line - start selection on prev line"
+ line1 := line1 - 1].
  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!