mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-12 22:50:54 +03:00
Add initial support for line highlighting
This commit is contained in:
parent
6d151809c3
commit
be8120e8c6
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user