mirror of
https://github.com/atom/atom.git
synced 2026-02-09 22:24:59 -05:00
CompositeCursor.addCursor takes an optional screenPosition argument
This commit is contained in:
@@ -6,10 +6,14 @@ class Anchor
|
||||
bufferPosition: null
|
||||
screenPosition: null
|
||||
|
||||
constructor: (editor) ->
|
||||
constructor: (editor, screenPosition) ->
|
||||
@editor = editor
|
||||
@bufferPosition = new Point(0, 0)
|
||||
@screenPosition = new Point(0, 0)
|
||||
|
||||
if screenPosition
|
||||
@setScreenPosition(screenPosition)
|
||||
else
|
||||
@bufferPosition = new Point(0,0)
|
||||
@screenPosition = new Point(0,0)
|
||||
|
||||
handleBufferChange: (e) ->
|
||||
{ oldRange, newRange } = e
|
||||
|
||||
@@ -17,19 +17,18 @@ class CompositeCursor
|
||||
getCursors: ->
|
||||
@cursors
|
||||
|
||||
addCursor: ->
|
||||
cursor = new Cursor(@editor)
|
||||
addCursor: (screenPosition=null) ->
|
||||
cursor = new Cursor({@editor, screenPosition})
|
||||
@cursors.push(cursor)
|
||||
@editor.lines.append(cursor)
|
||||
cursor
|
||||
|
||||
addCursorAtScreenPosition: (screenPosition) ->
|
||||
cursor = @addCursor()
|
||||
cursor.setScreenPosition(screenPosition)
|
||||
cursor = @addCursor(screenPosition)
|
||||
|
||||
addCursorAtBufferPosition: (bufferPosition) ->
|
||||
cursor = @addCursor()
|
||||
cursor.setBufferPosition(bufferPosition)
|
||||
screenPosition = @editor.screenPositionForBufferPosition(bufferPosition)
|
||||
cursor = @addCursor(screenPosition)
|
||||
|
||||
removeCursor: (cursor) ->
|
||||
_.remove(@cursors, cursor)
|
||||
|
||||
@@ -12,8 +12,9 @@ class Cursor extends View
|
||||
editor: null
|
||||
wordRegex: /(\w+)|([^\w\s]+)/g
|
||||
|
||||
initialize: (@editor) ->
|
||||
@anchor = new Anchor(@editor)
|
||||
initialize: ({editor, screenPosition}) ->
|
||||
@editor = editor
|
||||
@anchor = new Anchor(@editor, screenPosition)
|
||||
@selection = @editor.compositeSelection.addSelectionForCursor(this)
|
||||
@one 'attach', => @updateAppearance()
|
||||
|
||||
|
||||
@@ -482,9 +482,9 @@ class Editor extends View
|
||||
@buffer.getMode()
|
||||
|
||||
scrollTo: (pixelPosition) ->
|
||||
_.defer =>
|
||||
@scrollVertically(pixelPosition)
|
||||
@scrollHorizontally(pixelPosition)
|
||||
_.defer => # Optimization
|
||||
@scrollVertically(pixelPosition)
|
||||
@scrollHorizontally(pixelPosition)
|
||||
|
||||
scrollVertically: (pixelPosition) ->
|
||||
linesInView = @scroller.height() / @lineHeight
|
||||
|
||||
Reference in New Issue
Block a user