@@ -183,12 +183,19 @@ class EditorTextView: UITextView, NSLayoutManagerDelegate {
183
183
184
184
185
185
func dimLineUnderLocation( location: CGPoint ) {
186
- let currentLine = lineNumberUnderPoint ( location)
186
+ //let currentLine = lineNumberUnderPoint(location)
187
+ let currentLine = Int ( ( location. y / ( font. lineHeight + lineSpacing) ) )
187
188
slightlyDimLineWhileDraggingOver ( lineNumber: currentLine)
188
189
}
189
190
190
191
func slightlyDimLineWhileDraggingOver( #lineNumber: Int) {
191
- let FirstLineNumberRect = getLineNumberRect ( lineNumber)
192
+ //let FirstLineNumberRect = getLineNumberRect(lineNumber)
193
+ let LineHeight = font. lineHeight + lineSpacing
194
+ let FirstLineNumberRect = CGRect (
195
+ x: 0 ,
196
+ y: LineHeight * CGFloat( lineNumber ) ,
197
+ width: frame. width,
198
+ height: LineHeight)
192
199
let HighlightingRect = CGRect (
193
200
x: FirstLineNumberRect . origin. x,
194
201
y: FirstLineNumberRect . origin. y,
@@ -478,16 +485,23 @@ class EditorTextView: UITextView, NSLayoutManagerDelegate {
478
485
stop. initialize ( true )
479
486
}
480
487
} else {
481
- numberOfExtraLines++
488
+ var characterRangeString = storage. string ( ) !. substringWithRange ( charRange) . stringByTrimmingCharactersInSet ( NSCharacterSet . newlineCharacterSet ( ) )
489
+ if countElements ( characterRangeString) > 0 {
490
+ numberOfExtraLines++
491
+ }
492
+
493
+
482
494
}
483
495
}
484
496
layoutManager. enumerateLineFragmentsForGlyphRange ( glyphsToShow,
485
497
usingBlock: lineFragmentClosure)
486
498
if boundingRect == nil {
499
+ println ( lineNumber)
500
+ println ( numberOfExtraLines)
487
501
let LineHeight = font. lineHeight + lineSpacing
488
502
let LineNumberRect = CGRect (
489
503
x: 0 ,
490
- y: LineHeight * CGFloat( lineNumber - numberOfExtraLines + 1 ) ,
504
+ y: LineHeight * CGFloat( lineNumber - numberOfExtraLines) ,
491
505
width: frame. width,
492
506
height: LineHeight)
493
507
boundingRect = LineNumberRect
0 commit comments