WIP: Start on LineWrapper.displayPositionFromBufferPosition

It takes a row, column from the buffer and converts it to coordinates
that account for line wrapping.
This commit is contained in:
Nathan Sobo
2012-02-07 18:40:59 -07:00
parent b21595f037
commit a16bc99249
3 changed files with 30 additions and 3 deletions

View File

@@ -35,6 +35,7 @@ class LineWrapper
currentSegment = []
currentSegment.lastIndex = 0
currentSegment.textLength = 0
segments = [currentSegment]
nextBreak = breakIndices.shift()
for token in @highlighter.tokensForRow(row)
@@ -50,3 +51,17 @@ class LineWrapper
currentSegment.textLength += token.value.length
segments
displayPositionFromBufferPosition: (bufferPosition) ->
row = 0
for segments in @lines[0...bufferPosition.row]
row += segments.length
column = bufferPosition.column
for segment in @lines[bufferPosition.row]
break if segment.lastIndex > bufferPosition.column
column -= segment.textLength
row++
{ row, column }