mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Cursor can be re-positioned with the mouse
This commit is contained in:
@@ -67,6 +67,12 @@ class Editor extends Template
|
||||
@hiddenInput.focus()
|
||||
false
|
||||
|
||||
@on 'click', (e) =>
|
||||
{ pageX, pageY } = e
|
||||
left = pageX - @lines.offset().left
|
||||
top = pageY - @lines.offset().top
|
||||
@setCursorPosition(@pointFromPixelPosition({left, top}))
|
||||
|
||||
@hiddenInput.on "textInput", (e) =>
|
||||
@insertText(e.originalEvent.data)
|
||||
|
||||
@@ -127,6 +133,9 @@ class Editor extends Template
|
||||
pixelPositionFromPoint: ({row, column}) ->
|
||||
{ top: row * @lineHeight, left: column * @charWidth }
|
||||
|
||||
pointFromPixelPosition: ({top, left}) ->
|
||||
{ row: Math.floor(top / @lineHeight), column: Math.floor(left / @charWidth) }
|
||||
|
||||
calculateDimensions: ->
|
||||
fragment = $('<pre style="position: absolute; visibility: hidden;">x</pre>')
|
||||
@lines.append(fragment)
|
||||
|
||||
Reference in New Issue
Block a user