mirror of
https://github.com/atom/atom.git
synced 2026-02-10 06:35:00 -05:00
Add Editor.bounds() and Editor.screenPositionInBounds()
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user