💚 Fix specs

This commit is contained in:
Antonio Scandurra
2015-09-24 11:27:54 +02:00
parent 535a9da946
commit 19ca87f79f
3 changed files with 27 additions and 20 deletions

View File

@@ -406,20 +406,36 @@ class TextEditorComponent
getVisibleRowRange: ->
@presenter.getVisibleRowRange()
pixelPositionForBufferPosition: (bufferPosition) ->
@presenter.pixelPositionForBufferPosition(bufferPosition)
pixelPositionForScreenPosition: (screenPosition) ->
@presenter.pixelPositionForScreenPosition(screenPosition)
position = @presenter.pixelPositionForScreenPosition(screenPosition)
position.top += @presenter.getScrollTop()
position.left += @presenter.getScrollLeft()
position
screenPositionForPixelPosition: (pixelPosition) ->
@presenter.screenPositionForPixelPosition(pixelPosition)
pixelRectForScreenRange: (screenRange) ->
@presenter.pixelRectForScreenRange(screenRange)
if screenRange.end.row > screenRange.start.row
top = @pixelPositionForScreenPosition(screenRange.start).top
left = 0
height = (screenRange.end.row - screenRange.start.row + 1) * @lineHeight
width = @scrollWidth
else
{top, left} = @pixelPositionForScreenPosition(screenRange.start, false)
height = @lineHeight
width = @pixelPositionForScreenPosition(screenRange.end, false).left - left
pixelRangeForScreenRange: (screenRange, clip) ->
@presenter.pixelRangeForScreenRange(screenRange, clip)
{top, left, width, height}
pixelRangeForScreenRange: (screenRange, clip=true) ->
{start, end} = Range.fromObject(screenRange)
{start: @pixelPositionForScreenPosition(start, clip), end: @pixelPositionForScreenPosition(end, clip)}
pixelPositionForBufferPosition: (bufferPosition) ->
@pixelPositionForScreenPosition(
@editor.screenPositionForBufferPosition(bufferPosition)
)
onMouseDown: (event) =>
unless event.button is 0 or (event.button is 1 and process.platform is 'linux')

View File

@@ -181,7 +181,7 @@ class TextEditorElement extends HTMLElement
#
# Returns an {Object} with two values: `top` and `left`, representing the pixel position.
pixelPositionForBufferPosition: (bufferPosition) ->
@component.pixelPositionForBufferPosition(bufferPosition, true)
@component.pixelPositionForBufferPosition(bufferPosition)
# Extended: Converts a screen position to a pixel position.
#
@@ -190,7 +190,7 @@ class TextEditorElement extends HTMLElement
#
# Returns an {Object} with two values: `top` and `left`, representing the pixel positions.
pixelPositionForScreenPosition: (screenPosition) ->
@component.pixelPositionForScreenPosition(screenPosition, true)
@component.pixelPositionForScreenPosition(screenPosition)
# Extended: Retrieves the number of the row that is visible and currently at the
# top of the editor.
@@ -283,8 +283,8 @@ class TextEditorElement extends HTMLElement
pixelRectForScreenRange: (screenRange) ->
@component.pixelRectForScreenRange(screenRange)
pixelRangeForScreenRange: (screenRange, clip) ->
@component.pixelRangeForScreenRange(screenRange, clip)
pixelRangeForScreenRange: (screenRange) ->
@component.pixelRangeForScreenRange(screenRange)
stopEventPropagation = (commandListeners) ->
newCommandListeners = {}

View File

@@ -1603,11 +1603,6 @@ class TextEditorPresenter
getVisibleRowRange: ->
[@startRow, @endRow]
pixelPositionForBufferPosition: (bufferPosition) ->
@pixelPositionForScreenPosition(
@model.screenPositionForBufferPosition(bufferPosition)
)
screenPositionForPixelPosition: (pixelPosition) ->
targetTop = pixelPosition.top
targetLeft = pixelPosition.left
@@ -1642,7 +1637,3 @@ class TextEditorPresenter
column += charLength
new Point(row, column)
pixelRangeForScreenRange: (screenRange, clip=true) ->
{start, end} = Range.fromObject(screenRange)
{start: @pixelPositionForScreenPosition(start, clip), end: @pixelPositionForScreenPosition(end, clip)}