Add Editor.bounds() and Editor.screenPositionInBounds()

This commit is contained in:
Corey Johnson
2012-04-03 14:39:09 -07:00
parent 846846abe8
commit a372a2b411
3 changed files with 44 additions and 1 deletions

View File

@@ -162,6 +162,23 @@ class Editor extends View
rootView: ->
@parents('#root-view').view()
bounds: ->
rows = @height() / @lineHeight
columns = @horizontalScroller.width() / @charWidth
start = new Point(@scrollTop() / @lineHeight, @horizontalScroller.scrollLeft() / @charWidth)
end = new Point(start.row + rows, start.column + columns)
new Range(start, end)
screenPositionInBounds: (screenPosition) ->
screenPosition = Point.fromObject(screenPosition)
bounds = @bounds()
bounds.start.row <= screenPosition.row and
bounds.start.column <= screenPosition.column and
bounds.end.row >= screenPosition.row and
bounds.end.column >= screenPosition.column
selectOnMousemoveUntilMouseup: ->
moveHandler = (e) => @selectToScreenPosition(@screenPositionFromMouseEvent(e))
@on 'mousemove', moveHandler