Pass old and new screen position with Anchor/Cursor move events

This commit is contained in:
Nathan Sobo
2012-11-29 12:17:01 -07:00
parent 91e899456a
commit 833ccb30ab
3 changed files with 10 additions and 6 deletions

View File

@@ -54,7 +54,7 @@ class Anchor
@screenPosition.row
setScreenPosition: (position, options={}) ->
previousScreenPosition = @screenPosition
oldScreenPosition = @screenPosition
@screenPosition = Point.fromObject(position)
clip = options.clip ? true
assignBufferPosition = options.assignBufferPosition ? true
@@ -65,8 +65,12 @@ class Anchor
Object.freeze @screenPosition
Object.freeze @bufferPosition
unless @screenPosition.isEqual(previousScreenPosition)
@trigger 'moved', @screenPosition, bufferChange: options.bufferChange, autoscroll: options.autoscroll
unless @screenPosition.isEqual(oldScreenPosition)
@trigger 'moved',
oldScreenPosition: oldScreenPosition
newScreenPosition: @screenPosition
bufferChange: options.bufferChange
autoscroll: options.autoscroll
refreshScreenPosition: (options={}) ->
return unless @editSession

View File

@@ -19,7 +19,7 @@ class CursorView extends View
shouldPauseBlinking: false
initialize: (@cursor, @editor) ->
@cursor.on 'moved.cursor-view', (screenPosition, { autoscroll }) =>
@cursor.on 'moved.cursor-view', ({ autoscroll }) =>
@needsUpdate = true
@shouldPauseBlinking = true
@needsAutoscroll = (autoscroll ? true) and @cursor?.isLastCursor()

View File

@@ -12,8 +12,8 @@ class Selection
constructor: ({@cursor, @editSession}) ->
@cursor.selection = this
@cursor.on 'moved.selection', (e) =>
@screenRangeChanged() unless e.bufferChange
@cursor.on 'moved.selection', ({bufferChange}) =>
@screenRangeChanged() unless bufferChange
@cursor.on 'destroy.selection', =>
@cursor = null