mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Start adding marker methods to DisplayBuffer
Whereas marker methods on buffer take for granted that everything is in buffer coordinates, methods on the DisplayBuffer offer both screen and buffer coordinate versions of the marker API.
This commit is contained in:
@@ -580,10 +580,33 @@ describe "DisplayBuffer", ->
|
||||
it "returns the length of the longest screen line", ->
|
||||
expect(displayBuffer.maxLineLength()).toBe 65
|
||||
|
||||
describe "markers", ->
|
||||
it "allows markers to be worked with in terms of both screen and buffer coordinates", ->
|
||||
displayBuffer.foldBufferRow(4)
|
||||
marker1 = displayBuffer.markScreenRange([[5, 4], [5, 10]])
|
||||
marker2 = displayBuffer.markBufferRange([[8, 4], [8, 10]])
|
||||
expect(displayBuffer.getMarkerBufferRange(marker1)).toEqual [[8, 4], [8, 10]]
|
||||
expect(displayBuffer.getMarkerScreenRange(marker2)).toEqual [[5, 4], [5, 10]]
|
||||
fdescribe "markers", ->
|
||||
describe "creation and manipulation", ->
|
||||
beforeEach ->
|
||||
displayBuffer.foldBufferRow(4)
|
||||
|
||||
it "allows markers to be created in terms of both screen and buffer coordinates", ->
|
||||
marker1 = displayBuffer.markScreenRange([[5, 4], [5, 10]])
|
||||
marker2 = displayBuffer.markBufferRange([[8, 4], [8, 10]])
|
||||
expect(displayBuffer.getMarkerBufferRange(marker1)).toEqual [[8, 4], [8, 10]]
|
||||
expect(displayBuffer.getMarkerScreenRange(marker2)).toEqual [[5, 4], [5, 10]]
|
||||
|
||||
it "allows marker head and tail positions to be manipulated in both screen and buffer coordinates", ->
|
||||
marker = displayBuffer.markScreenRange([[5, 4], [5, 10]])
|
||||
displayBuffer.setMarkerHeadScreenPosition(marker, [5, 4])
|
||||
displayBuffer.setMarkerTailBufferPosition(marker, [5, 4])
|
||||
expect(displayBuffer.isMarkerReversed(marker)).toBeFalsy()
|
||||
expect(displayBuffer.getMarkerBufferRange(marker)).toEqual [[5, 4], [8, 4]]
|
||||
|
||||
displayBuffer.setMarkerHeadBufferPosition(marker, [5, 4])
|
||||
displayBuffer.setMarkerTailScreenPosition(marker, [5, 4])
|
||||
expect(displayBuffer.isMarkerReversed(marker)).toBeTruthy()
|
||||
expect(displayBuffer.getMarkerBufferRange(marker)).toEqual [[5, 4], [8, 4]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -296,12 +296,51 @@ class DisplayBuffer
|
||||
markBufferRange: (bufferRange) ->
|
||||
@buffer.markRange(bufferRange)
|
||||
|
||||
markScreenPosition: (screenPosition) ->
|
||||
@markBufferPosition(@bufferPositionForScreenPosition(screenPosition))
|
||||
|
||||
markBufferPosition: (bufferPosition) ->
|
||||
@buffer.markPosition(bufferPosition)
|
||||
|
||||
getMarkerScreenRange: (id) ->
|
||||
@screenRangeForBufferRange(@getMarkerBufferRange(id))
|
||||
|
||||
getMarkerBufferRange: (id) ->
|
||||
@buffer.getMarkerRange(id)
|
||||
|
||||
getMarkerScreenPosition: (id) ->
|
||||
@getMarkerHeadScreenPosition(id)
|
||||
|
||||
getMarkerBufferPosition: (id) ->
|
||||
@getMarkerHeadBufferPosition(id)
|
||||
|
||||
getMarkerHeadScreenPosition: (id) ->
|
||||
@screenPositionForBufferPosition(@getMarkerHeadBufferPosition(id))
|
||||
|
||||
setMarkerHeadScreenPosition: (id, screenPosition, options) ->
|
||||
@setMarkerHeadBufferPosition(id, @bufferPositionForScreenPosition(screenPosition, options))
|
||||
|
||||
getMarkerHeadBufferPosition: (id) ->
|
||||
@buffer.getMarkerHeadPosition(id)
|
||||
|
||||
setMarkerHeadBufferPosition: (id, bufferPosition) ->
|
||||
@buffer.setMarkerHeadPosition(id, bufferPosition)
|
||||
|
||||
getMarkerTailScreenPosition: (id) ->
|
||||
@screenPositionForBufferPosition(@getMarkerTailBufferPosition(id))
|
||||
|
||||
setMarkerTailScreenPosition: (id, screenPosition, options) ->
|
||||
@setMarkerTailBufferPosition(id, @bufferPositionForScreenPosition(screenPosition, options))
|
||||
|
||||
getMarkerTailBufferPosition: (id) ->
|
||||
@buffer.getMarkerTailPosition(id)
|
||||
|
||||
setMarkerTailBufferPosition: (id, bufferPosition) ->
|
||||
@buffer.setMarkerTailPosition(id, bufferPosition)
|
||||
|
||||
isMarkerReversed: (id) ->
|
||||
@buffer.isMarkerReversed(id)
|
||||
|
||||
destroy: ->
|
||||
@tokenizedBuffer.destroy()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user