Replace tokens with tagCodes in DisplayLayer.prototype.getScreenLines

This commit is contained in:
Nathan Sobo
2016-03-18 15:57:49 -06:00
parent 1a2f306db3
commit d62ef599cd
2 changed files with 24 additions and 14 deletions

View File

@@ -253,26 +253,26 @@ class LinesTileComponent
@currentLineTextNodes.push(textNode)
setLineInnerNodes: (id, lineNode) ->
{tokens} = @newTileState.lines[id]
{lineText, tagCodes} = @newTileState.lines[id]
lineLength = 0
startIndex = 0
openScopeNode = lineNode
for token in tokens when token.text.length > 0
{closeTags, openTags, text} = token
for scope in closeTags
for tagCode in tagCodes when tagCode isnt 0
if @presenter.isCloseTagCode(tagCode)
openScopeNode = openScopeNode.parentElement
for scope in openTags
else if @presenter.isOpenTagCode(tagCode)
scope = @presenter.tagForCode(tagCode)
newScopeNode = @domElementPool.buildElement("span", scope.replace(/\.+/g, ' '))
openScopeNode.appendChild(newScopeNode)
openScopeNode = newScopeNode
else
textNode = @domElementPool.buildText(lineText.substr(startIndex, tagCode).replace(/\s/g, NBSPCharacter))
startIndex += tagCode
openScopeNode.appendChild(textNode)
@currentLineTextNodes.push(textNode)
lineLength += text.length
textNode = @domElementPool.buildText(text.replace(/\s/g, NBSPCharacter))
openScopeNode.appendChild(textNode)
@currentLineTextNodes.push(textNode)
if lineLength is 0
if startIndex is 0
textNode = @domElementPool.buildText(NBSPCharacter)
lineNode.appendChild(textNode)
@currentLineTextNodes.push(textNode)

View File

@@ -436,7 +436,8 @@ class TextEditorPresenter
else
tileState.lines[line.id] =
screenRow: screenRow
tokens: line.tokens
lineText: line.lineText
tagCodes: line.tagCodes
decorationClasses: @lineDecorationClassesForRow(screenRow)
precedingBlockDecorations: precedingBlockDecorations
followingBlockDecorations: followingBlockDecorations
@@ -1548,3 +1549,12 @@ class TextEditorPresenter
isRowVisible: (row) ->
@startRow <= row < @endRow
isOpenTagCode: (tagCode) ->
@displayLayer.isOpenTagCode(tagCode)
isCloseTagCode: (tagCode) ->
@displayLayer.isCloseTagCode(tagCode)
tagForCode: (tagCode) ->
@displayLayer.tagForCode(tagCode)