mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
Support selecting editor lines from the gutter
Mouse events that occur in the gutter are forwarded to the rendered lines with the y-coordinate translated to be the leftmost pixel of the editor to simulate the event originating from column 0 of the current line row. Closes #287
This commit is contained in:
@@ -385,7 +385,7 @@ class Editor extends View
|
||||
@destroyFold($(e.currentTarget).attr('fold-id'))
|
||||
false
|
||||
|
||||
@renderedLines.on 'mousedown', (e) =>
|
||||
onMouseDown = (e) =>
|
||||
clickCount = e.originalEvent.detail
|
||||
|
||||
screenPosition = @screenPositionFromMouseEvent(e)
|
||||
@@ -403,6 +403,8 @@ class Editor extends View
|
||||
|
||||
@selectOnMousemoveUntilMouseup()
|
||||
|
||||
@renderedLines.on 'mousedown', onMouseDown
|
||||
|
||||
@on "textInput", (e) =>
|
||||
@insertText(e.originalEvent.data)
|
||||
false
|
||||
@@ -419,6 +421,10 @@ class Editor extends View
|
||||
@gutter.widthChanged = (newWidth) =>
|
||||
@scrollView.css('left', newWidth + 'px')
|
||||
|
||||
@gutter.on 'mousedown', (e) =>
|
||||
e.pageX = @renderedLines.offset().left
|
||||
onMouseDown(e)
|
||||
|
||||
@subscribe syntax, 'grammars-loaded', =>
|
||||
@reloadGrammar()
|
||||
for session in @editSessions
|
||||
|
||||
@@ -23,13 +23,6 @@ class Gutter extends View
|
||||
highlightLines = => @highlightLines()
|
||||
editor.on 'cursor:moved', highlightLines
|
||||
editor.on 'selection:changed', highlightLines
|
||||
@on 'click', '.line-number', (e) =>
|
||||
row = parseInt($(e.target).text()) - 1
|
||||
position = new Point(row, 0)
|
||||
if e.shiftKey
|
||||
@editor().selectToScreenPosition(position)
|
||||
else
|
||||
@editor().setCursorScreenPosition(position)
|
||||
|
||||
@calculateWidth()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user