mirror of
https://github.com/atom/atom.git
synced 2026-02-08 21:55:05 -05:00
Use LineWrapper to calculate pixelPositionFromPoint
This commit is contained in:
@@ -191,18 +191,9 @@ class Editor extends View
|
||||
|
||||
new Point(row, column)
|
||||
|
||||
pixelPositionFromPoint: ({row, column}) ->
|
||||
segmentsAbove = 0
|
||||
segmentsAbove += @lineWrapper.segmentsForRow(i).length for i in [0...row]
|
||||
|
||||
for segment in @lineWrapper.segmentsForRow(row)
|
||||
if column > segment.lastIndex
|
||||
segmentsAbove++
|
||||
column -= segment.textLength
|
||||
else
|
||||
break
|
||||
|
||||
{ top: segmentsAbove * @lineHeight, left: column * @charWidth }
|
||||
pixelPositionFromPoint: (position) ->
|
||||
{ row, column } = @lineWrapper.displayPositionFromBufferPosition(position)
|
||||
{ top: row * @lineHeight, left: column * @charWidth }
|
||||
|
||||
pointFromPixelPosition: ({top, left}) ->
|
||||
{ row: Math.floor(top / @lineHeight), column: Math.floor(left / @charWidth) }
|
||||
|
||||
Reference in New Issue
Block a user