Allow markers to be created with just a position

When a marker is created with just a position, it only gets a head
position and has no tail position.
This commit is contained in:
Nathan Sobo
2013-01-30 21:37:57 -07:00
parent 0e67f35748
commit d8ffdcd6bd
3 changed files with 137 additions and 107 deletions

View File

@@ -271,17 +271,26 @@ class Buffer
getMarkers: ->
_.values(@validMarkers)
markRange: (range, options) ->
marker = new BufferMarker(_.extend({
markRange: (range, options={}) ->
marker = new BufferMarker(_.defaults({
id: @nextMarkerId++
buffer: this
range: range
range
}, options))
@validMarkers[marker.id] = marker
marker.id
markPosition: (position, options) ->
@markRange([position, position], _.defaults({noTail: true}, options))
getMarkerPosition: (id) ->
@validMarkers[id]?.getPosition()
@getMarkerHeadPosition(id)
getMarkerHeadPosition: (id) ->
@validMarkers[id]?.getHeadPosition()
getMarkerTailPosition: (id) ->
@validMarkers[id]?.getTailPosition()
getMarkerRange: (id) ->
@validMarkers[id]?.getRange()