mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
All tests passing. Editor gets lines from LineWrapper.
Line wrapping still not fully functional. Need to fix many aspects of the LineWrapper integration.
This commit is contained in:
@@ -57,6 +57,7 @@ describe "Editor", ->
|
||||
editor.setSoftWrap(true)
|
||||
|
||||
it "wraps lines that are too long to fit within the editor's width, adjusting cursor positioning accordingly", ->
|
||||
expect(editor.lines.find('.line').length).toBe 16
|
||||
expect(editor.lines.find('pre:eq(3)').text()).toBe " var pivot = items.shift(), current, left = [], "
|
||||
expect(editor.lines.find('pre:eq(4)').text()).toBe "right = [];"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Highlighter = require 'highlighter'
|
||||
Range = require 'range'
|
||||
_ = require 'underscore'
|
||||
|
||||
fdescribe "LineWrapper", ->
|
||||
describe "LineWrapper", ->
|
||||
[wrapper, buffer] = []
|
||||
|
||||
beforeEach ->
|
||||
|
||||
@@ -114,22 +114,20 @@ class Editor extends View
|
||||
@on 'mousemove', moveHandler
|
||||
$(document).one 'mouseup', => @off 'mousemove', moveHandler
|
||||
|
||||
buildLineElement: (row) ->
|
||||
segments = @lineWrapper.segmentsForRow(row)
|
||||
buildLineElement: (screenRow) ->
|
||||
tokens = @lineWrapper.tokensForScreenRow(screenRow)
|
||||
$$ ->
|
||||
for segment in segments
|
||||
@pre class: 'line', =>
|
||||
if segment.length
|
||||
for token in segment
|
||||
@span { class: token.type.replace('.', ' ') }, token.value
|
||||
else
|
||||
@raw ' '
|
||||
@pre class: 'line', =>
|
||||
if tokens.length
|
||||
for token in tokens
|
||||
@span { class: token.type.replace('.', ' ') }, token.value
|
||||
else
|
||||
@raw ' '
|
||||
|
||||
renderLines: ->
|
||||
@lines.empty()
|
||||
for row in [0..@buffer.lastRow()]
|
||||
line = @buildLineElement(row)
|
||||
@lines.append line
|
||||
for screenRow in [0...@lineWrapper.screenLineCount()]
|
||||
@lines.append @buildLineElement(screenRow)
|
||||
|
||||
setBuffer: (@buffer) ->
|
||||
@highlighter = new Highlighter(@buffer)
|
||||
@@ -192,7 +190,7 @@ class Editor extends View
|
||||
new Point(row, column)
|
||||
|
||||
pixelPositionFromPoint: (position) ->
|
||||
{ row, column } = @lineWrapper.displayPositionFromBufferPosition(position)
|
||||
{ row, column } = @lineWrapper.screenPositionFromBufferPosition(position)
|
||||
{ top: row * @lineHeight, left: column * @charWidth }
|
||||
|
||||
pointFromPixelPosition: ({top, left}) ->
|
||||
|
||||
Reference in New Issue
Block a user