diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2946bd866..b9974c362 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -36,6 +36,7 @@ class Editor extends View charWidth: null charHeight: null cursorViews: null + cursorRow: -1 selectionViews: null lineCache: null isFocused: false @@ -343,6 +344,8 @@ class Editor extends View else @gutter.addClass('drop-shadow') + @on 'cursor-move', => @highlightCursorLine() + selectOnMousemoveUntilMouseup: -> moveHandler = (e) => @selectToScreenPosition(@screenPositionFromMouseEvent(e)) @on 'mousemove', moveHandler @@ -746,6 +749,7 @@ class Editor extends View if renderedLines @gutter.renderLineNumbers(renderFrom, renderTo) + @highlightCursorLine() @updatePaddingOfRenderedLines() updatePaddingOfRenderedLines: -> @@ -809,6 +813,7 @@ class Editor extends View charHeight = @charHeight lines = @activeEditSession.linesForScreenRows(startRow, endRow) activeEditSession = @activeEditSession + cursorRow = @cursorRow buildLineHtml = (line) => @buildLineHtml(line) $$ -> @raw(buildLineHtml(line)) for line in lines @@ -932,3 +937,19 @@ class Editor extends View @screenPositionFromPixelPosition top: pageY - @scrollView.offset().top + @scrollTop() left: pageX - @scrollView.offset().left + @scrollView.scrollLeft() + + highlightCursorLine: -> + return if @mini + + newCursorRow = @getCursorBufferPosition().row + emptySelection = @getSelection().isEmpty() + if emptySelection + if @cursorRow isnt newCursorRow + @cursorRow = newCursorRow + screenRow = newCursorRow - @firstRenderedScreenRow + @find('.line.cursor-line').removeClass('cursor-line') + @find(".line:eq(#{screenRow})").addClass('cursor-line') + else if @cursorRow isnt -1 + @find('.line.cursor-line').removeClass('cursor-line') + + @cursorRow = -1 if !emptySelection diff --git a/static/editor.css b/static/editor.css index 63df5ef61..a4bc13bbb 100644 --- a/static/editor.css +++ b/static/editor.css @@ -30,6 +30,10 @@ color: rgba(255, 255, 255, .6); } +.line.cursor-line, .line-number.cursor-line-number { + background-color: rgba(255, 255, 255, .12); +} + .editor.mini .gutter { display: none; }