Add TextEditor::observeMarkers, use it in presenter

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2015-05-29 17:21:23 -07:00
committed by Nathan Sobo
parent b59bec5f9d
commit 6f553f234c
5 changed files with 141 additions and 38 deletions

View File

@@ -10,6 +10,7 @@ Model = require './model'
Token = require './token'
Decoration = require './decoration'
Marker = require './marker'
MarkerObservationWindow = require './marker-observation-window'
class BufferToScreenConversionError extends Error
constructor: (@message, @metadata) ->
@@ -950,6 +951,9 @@ class DisplayBuffer extends Model
@emitter.emit 'did-remove-decoration', decoration
delete @decorationsByMarkerId[marker.id] if decorations.length is 0
decorationsForMarkerId: (markerId) ->
@decorationsByMarkerId[markerId]
# Retrieves a {Marker} based on its id.
#
# id - A {Number} representing a marker id
@@ -1045,6 +1049,9 @@ class DisplayBuffer extends Model
params = @translateToBufferMarkerParams(params)
@buffer.findMarkers(params).map (stringMarker) => @getMarker(stringMarker.id)
observeMarkers: (callback) ->
new MarkerObservationWindow(this, @buffer.observeMarkers(callback))
translateToBufferMarkerParams: (params) ->
bufferMarkerParams = {}
for key, value of params