Nicolas Cellier uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-nice.273.mcz==================== Summary ====================
Name: Morphic-nice.273
Author: nice
Time: 25 December 2009, 4:04:57 am
UUID: 552efe8b-03cc-4a8c-8547-428de87dc93c
Ancestors: Morphic-ar.272
Simplify #lines and handle eventual crlf pairs correctly
(Old code did assume there was a single separator using index := index + 1)
=============== Diff against Morphic-ar.272 ===============
Item was changed:
----- Method: Editor>>lines (in category 'private') -----
lines
"Compute lines based on logical line breaks, not optical (which may change due to line wrapping of the editor).
+ Subclasses using kinds of Paragraphs can instead use the service provided by it."
+ | lines string lineIndex |
- Subclasses using kinds of Paragraphs can instead use the service provided by it.
- "
- | lines string index lineIndex stringSize |
string := self string.
"Empty strings have no lines at all. Think of something."
string isEmpty ifTrue:[^{#(1 0 0)}].
- stringSize := string size.
lines := OrderedCollection new: (string size // 15).
- index := 0.
lineIndex := 0.
+ string lineIndicesDo: [:start :endWithoutDelimiters :end |
+ lines addLast: {start. (lineIndex := lineIndex + 1). end}].
- string linesDo:[:line |
- lines addLast: (Array
- with: (index := index + 1)
- with: (lineIndex := lineIndex + 1)
- with: (index := index + line size min: stringSize))].
"Special workaround for last line empty."
(string last == Character cr or: [string last == Character lf])
+ ifTrue: [lines addLast: {string size + 1. lineIndex + 1. string size}].
- "lines last last < stringSize" ifTrue:[lines addLast:{stringSize +1. lineIndex+1. stringSize}].
^lines!