mirror of
https://github.com/atom/atom.git
synced 2026-02-08 05:35:04 -05:00
wip: creating token spans
This commit is contained in:
committed by
Nathan Sobo
parent
f47b510d7c
commit
bebfaed69b
@@ -810,20 +810,32 @@ class Editor extends View
|
||||
lines = @activeEditSession.linesForScreenRows(startRow, endRow)
|
||||
activeEditSession = @activeEditSession
|
||||
|
||||
$$ ->
|
||||
for line in lines
|
||||
if fold = line.fold
|
||||
lineAttributes = { class: 'fold line', 'fold-id': fold.id }
|
||||
if activeEditSession.selectionIntersectsBufferRange(fold.getBufferRange())
|
||||
lineAttributes.class += ' selected'
|
||||
else
|
||||
lineAttributes = { class: 'line' }
|
||||
@pre lineAttributes, =>
|
||||
if line.text == ''
|
||||
@raw ' ' if line.text == ''
|
||||
else
|
||||
for token in line.tokens
|
||||
@span { class: token.getCssClassString() }, token.value
|
||||
buildLineHtml = @buildLineHtml
|
||||
$$ -> @raw(buildLineHtml(line)) for line in lines
|
||||
|
||||
buildLineHtml: (screenLine) ->
|
||||
scopesStack = []
|
||||
line = []
|
||||
|
||||
if fold = line.fold
|
||||
lineAttributes = { class: 'fold line', 'fold-id': fold.id }
|
||||
|
||||
if activeEditSession.selectionIntersectsBufferRange(fold.getBufferRange())
|
||||
lineAttributes.class += ' selected'
|
||||
else
|
||||
lineAttributes = { class: 'line' }
|
||||
|
||||
attributePairs = "#{attributeName}=\"#{value}\"" for attributeName, value of lineAttributes
|
||||
line.push("<pre #{attributePairs.join(' ')}>")
|
||||
if line.text == ''
|
||||
lines.push(' ')
|
||||
else
|
||||
for token in line.tokens
|
||||
for scopesStack, i in token.scopes
|
||||
line.push("<span class=#{classString}>")
|
||||
line.push("</span>")
|
||||
|
||||
line.push("</pre>)
|
||||
|
||||
insertLineElements: (row, lineElements) ->
|
||||
@spliceLineElements(row, 0, lineElements)
|
||||
|
||||
Reference in New Issue
Block a user