mirror of
https://github.com/atom/atom.git
synced 2026-01-25 23:08:18 -05:00
Depend on DisplayLayer for more things
This commit is contained in:
@@ -261,7 +261,7 @@ class Cursor extends Model
|
||||
|
||||
while columnCount > column and row > 0
|
||||
columnCount -= column
|
||||
column = @editor.lineTextForScreenRow(--row).length
|
||||
column = @editor.lineLengthForScreenRow(--row)
|
||||
columnCount-- # subtract 1 for the row move
|
||||
|
||||
column = column - columnCount
|
||||
@@ -280,7 +280,7 @@ class Cursor extends Model
|
||||
else
|
||||
{row, column} = @getScreenPosition()
|
||||
maxLines = @editor.getScreenLineCount()
|
||||
rowLength = @editor.lineTextForScreenRow(row).length
|
||||
rowLength = @editor.lineLengthForScreenRow(row)
|
||||
columnsRemainingInLine = rowLength - column
|
||||
|
||||
while columnCount > columnsRemainingInLine and row < maxLines - 1
|
||||
@@ -288,7 +288,7 @@ class Cursor extends Model
|
||||
columnCount-- # subtract 1 for the row move
|
||||
|
||||
column = 0
|
||||
rowLength = @editor.lineTextForScreenRow(++row).length
|
||||
rowLength = @editor.lineLengthForScreenRow(++row)
|
||||
columnsRemainingInLine = rowLength
|
||||
|
||||
column = column + columnCount
|
||||
|
||||
@@ -366,7 +366,7 @@ class TextEditorPresenter
|
||||
visibleTiles[tileStartRow] = true
|
||||
zIndex++
|
||||
|
||||
if @mouseWheelScreenRow? and @model.tokenizedLineForScreenRow(@mouseWheelScreenRow)?
|
||||
if @mouseWheelScreenRow? and 0 <= @mouseWheelScreenRow < @model.getScreenLineCount()
|
||||
mouseWheelTile = @tileForRow(@mouseWheelScreenRow)
|
||||
|
||||
unless visibleTiles[mouseWheelTile]?
|
||||
@@ -581,12 +581,12 @@ class TextEditorPresenter
|
||||
softWrapped = false
|
||||
|
||||
screenRow = startRow + i
|
||||
line = @model.tokenizedLineForScreenRow(screenRow)
|
||||
lineId = @lineIdForScreenRow(screenRow)
|
||||
decorationClasses = @lineNumberDecorationClassesForRow(screenRow)
|
||||
foldable = @model.isFoldableAtScreenRow(screenRow)
|
||||
|
||||
tileState.lineNumbers[line.id] = {screenRow, bufferRow, softWrapped, decorationClasses, foldable}
|
||||
visibleLineNumberIds[line.id] = true
|
||||
tileState.lineNumbers[lineId] = {screenRow, bufferRow, softWrapped, decorationClasses, foldable}
|
||||
visibleLineNumberIds[lineId] = true
|
||||
|
||||
for id of tileState.lineNumbers
|
||||
delete tileState.lineNumbers[id] unless visibleLineNumberIds[id]
|
||||
@@ -647,9 +647,10 @@ class TextEditorPresenter
|
||||
updateHorizontalDimensions: ->
|
||||
if @baseCharacterWidth?
|
||||
oldContentWidth = @contentWidth
|
||||
rightmostPosition = Point(@model.getLongestScreenRow(), @model.getMaxScreenLineLength())
|
||||
if @model.tokenizedLineForScreenRow(rightmostPosition.row)?.isSoftWrapped()
|
||||
rightmostPosition = @model.clipScreenPosition(rightmostPosition)
|
||||
rightmostPosition = @model.getRightmostScreenPosition()
|
||||
# TODO: Add some version of this back once softwrap is reintroduced
|
||||
# if @model.tokenizedLineForScreenRow(rightmostPosition.row)?.isSoftWrapped()
|
||||
# rightmostPosition = @model.clipScreenPosition(rightmostPosition)
|
||||
@contentWidth = @pixelPositionForScreenPosition(rightmostPosition).left
|
||||
@contentWidth += @scrollLeft
|
||||
@contentWidth += 1 unless @model.isSoftWrapped() # account for cursor width
|
||||
@@ -1421,4 +1422,5 @@ class TextEditorPresenter
|
||||
@startRow <= row < @endRow
|
||||
|
||||
lineIdForScreenRow: (screenRow) ->
|
||||
@model.tokenizedLineForScreenRow(screenRow)?.id
|
||||
ids = @lineMarkerIndex.findStartingAt(Point(screenRow, 0))
|
||||
ids.values().next().value if ids.size > 0
|
||||
|
||||
@@ -738,7 +738,7 @@ class TextEditor extends Model
|
||||
|
||||
# Essential: Returns a {Number} representing the number of screen lines in the
|
||||
# editor. This accounts for folds.
|
||||
getScreenLineCount: -> @displayBuffer.getLineCount()
|
||||
getScreenLineCount: -> @displayLayer.getScreenLineCount()
|
||||
|
||||
# Essential: Returns a {Number} representing the last zero-indexed buffer row
|
||||
# number of the editor.
|
||||
@@ -746,7 +746,7 @@ class TextEditor extends Model
|
||||
|
||||
# Essential: Returns a {Number} representing the last zero-indexed screen row
|
||||
# number of the editor.
|
||||
getLastScreenRow: -> @displayBuffer.getLastRow()
|
||||
getLastScreenRow: -> @getScreenLineCount() - 1
|
||||
|
||||
# Essential: Returns a {String} representing the contents of the line at the
|
||||
# given buffer row.
|
||||
@@ -770,17 +770,21 @@ class TextEditor extends Model
|
||||
# {Delegates to: DisplayBuffer.tokenizedLinesForScreenRows}
|
||||
tokenizedLinesForScreenRows: (start, end) -> @displayBuffer.tokenizedLinesForScreenRows(start, end)
|
||||
|
||||
bufferRowForScreenRow: (row) -> @displayBuffer.bufferRowForScreenRow(row)
|
||||
bufferRowForScreenRow: (row) -> @displayLayer.translateScreenPosition(Point(row, 0)).row
|
||||
|
||||
# {Delegates to: DisplayBuffer.bufferRowsForScreenRows}
|
||||
bufferRowsForScreenRows: (startRow, endRow) -> @displayBuffer.bufferRowsForScreenRows(startRow, endRow)
|
||||
|
||||
screenRowForBufferRow: (row) -> @displayBuffer.screenRowForBufferRow(row)
|
||||
screenRowForBufferRow: (row) -> @displayLayer.translateBufferPosition(Point(row, 0)).row
|
||||
|
||||
getRightmostScreenPosition: -> @displayLayer.getRightmostScreenPosition()
|
||||
|
||||
# {Delegates to: DisplayBuffer.getMaxLineLength}
|
||||
getMaxScreenLineLength: -> @displayBuffer.getMaxLineLength()
|
||||
getMaxScreenLineLength: -> @getRightmostScreenPosition().column
|
||||
|
||||
getLongestScreenRow: -> @displayBuffer.getLongestScreenRow()
|
||||
getLongestScreenRow: -> @getRightmostScreenPosition().row
|
||||
|
||||
lineLengthForScreenRow: (screenRow) -> @displayLayer.lineLengthForScreenRow(screenRow)
|
||||
|
||||
# Returns the range for the given buffer row.
|
||||
#
|
||||
@@ -1337,22 +1341,14 @@ class TextEditor extends Model
|
||||
# * `bufferRange` {Range} in buffer coordinates to translate into screen coordinates.
|
||||
#
|
||||
# Returns a {Range}.
|
||||
screenRangeForBufferRange: (bufferRange) ->
|
||||
bufferRange = Range.fromObject(bufferRange)
|
||||
start = @displayLayer.translateBufferPosition(bufferRange.start)
|
||||
end = @displayLayer.translateBufferPosition(bufferRange.end)
|
||||
Range(start, end)
|
||||
screenRangeForBufferRange: (bufferRange) -> @displayLayer.translateBufferRange(bufferRange)
|
||||
|
||||
# Essential: Convert a range in screen-coordinates to buffer-coordinates.
|
||||
#
|
||||
# * `screenRange` {Range} in screen coordinates to translate into buffer coordinates.
|
||||
#
|
||||
# Returns a {Range}.
|
||||
bufferRangeForScreenRange: (screenRange) ->
|
||||
screenRange = Range.fromObject(screenRange)
|
||||
start = @displayLayer.translateScreenPosition(screenRange.start)
|
||||
end = @displayLayer.translateScreenPosition(screenRange.end)
|
||||
Range(start, end)
|
||||
bufferRangeForScreenRange: (screenRange) -> @displayLayer.translateScreenRange(screenRange)
|
||||
|
||||
# Extended: Clip the given {Point} to a valid position in the buffer.
|
||||
#
|
||||
@@ -2945,8 +2941,7 @@ class TextEditor extends Model
|
||||
#
|
||||
# Returns a {Boolean}.
|
||||
isFoldableAtScreenRow: (screenRow) ->
|
||||
bufferRow = @displayBuffer.bufferRowForScreenRow(screenRow)
|
||||
@isFoldableAtBufferRow(bufferRow)
|
||||
@isFoldableAtBufferRow(@bufferRowForScreenRow(screenRow))
|
||||
|
||||
# Extended: Fold the given buffer row if it isn't currently folded, and unfold
|
||||
# it otherwise.
|
||||
|
||||
Reference in New Issue
Block a user