The Trunk: ST80-nice.77.mcz

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

The Trunk: ST80-nice.77.mcz

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

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

Name: ST80-nice.77
Author: nice
Time: 25 December 2009, 4:13:18 am
UUID: 5cfb47c6-c45e-42cc-8443-f957af69b18a
Ancestors: ST80-ar.76

Simplify #lines and handle eventual crlf pairs correctly
(Old code did assume there was a single separator using index := index + 1)

So many duplicated code... More code = more maintenance + more errors. If I had to pay a programmer, I would index a good proportion of wages on code removal rate, especially in Squeak ;)

=============== Diff against ST80-ar.76 ===============

Item was changed:
  ----- Method: ParagraphEditor>>lines (in category 'private') -----
  lines
  "Other than my member paragraph i compute lines based on logical
  line breaks, not optical (which may change due to line wrapping of the editor)"
+ | lines string lineIndex |
- | lines string index lineIndex stringSize |
  string := paragraph text 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!