mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Start on TextEditorPresenter with lines state
This commit is contained in:
20
src/text-editor-presenter.coffee
Normal file
20
src/text-editor-presenter.coffee
Normal file
@@ -0,0 +1,20 @@
|
||||
module.exports =
|
||||
class TextEditorPresenter
|
||||
constructor: ({@model, @clientHeight, @scrollTop, @lineHeight, @lineOverdrawMargin}) ->
|
||||
@state = {}
|
||||
@buildLinesState()
|
||||
|
||||
buildLinesState: ->
|
||||
@state.lines = {}
|
||||
startRow = Math.floor(@scrollTop / @lineHeight) - @lineOverdrawMargin
|
||||
startRow = Math.max(0, startRow)
|
||||
endRow = startRow + Math.ceil(@clientHeight / @lineHeight) + @lineOverdrawMargin
|
||||
endRow = Math.min(@model.getScreenLineCount(), endRow)
|
||||
|
||||
for line, i in @model.tokenizedLinesForScreenRows(startRow, endRow)
|
||||
row = startRow + i
|
||||
@state.lines[line.id] = {
|
||||
screenRow: row
|
||||
tokens: line.tokens
|
||||
top: row * @lineHeight
|
||||
}
|
||||
Reference in New Issue
Block a user