EditSession informs cursor models of buffer changes (instead of Editor informing cursor views)

This commit is contained in:
Nathan Sobo
2012-06-07 15:41:35 -06:00
parent d5d5caf764
commit 624cf3cbd3
3 changed files with 7 additions and 5 deletions

View File

@@ -26,10 +26,6 @@ class CursorView extends View
@updateAppearance()
@editor.syncCursorAnimations()
handleBufferChange: (e) ->
@cursor.handleBufferChange(e)
@trigger 'cursor-move', bufferChange: true
remove: ->
@editor.compositeCursor.removeCursor(this)
@editor.compositeSelection.removeSelectionForCursor(this)

View File

@@ -7,6 +7,8 @@ _ = require 'underscore'
module.exports =
class EditSession
@idCounter: 1
@deserialize: (state, editor, rootView) ->
buffer = Buffer.deserialize(state.buffer, rootView.project)
session = new EditSession(editor, buffer)
@@ -21,12 +23,17 @@ class EditSession
cursors: null
constructor: (@editor, @buffer) ->
@id = @constructor.idCounter++
@renderer = new Renderer(@buffer, { softWrapColumn: @editor.calcSoftWrapColumn(), tabText: @editor.tabText })
@cursors = []
@addCursorAtScreenPosition([0, 0])
@buffer.on "change.edit-session-#{@id}", (e) =>
@moveCursors (cursor) -> cursor.handleBufferChange(e)
destroy: ->
@renderer.destroy()
@buffer.off ".edit-session-#{@id}"
serialize: ->
buffer: @buffer.serialize()

View File

@@ -452,7 +452,6 @@ class Editor extends View
Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1
handleBufferChange: (e) ->
@compositeCursor.handleBufferChange(e)
@compositeSelection.handleBufferChange(e)
handleRendererChange: (e) ->