Style color of folded line numbers

This commit is contained in:
Kevin Sawicki 2013-01-30 11:48:58 -08:00
parent 4db876aed1
commit 8dbcefa932
6 changed files with 36 additions and 5 deletions

View File

@ -1730,6 +1730,11 @@ describe "Editor", ->
fold.destroy()
expect(editor.gutter.find('.line-number').length).toBe 13
it "styles folded line numbers", ->
editor.createFold(3, 5)
expect(editor.gutter.find('.line-number.fold').length).toBe 1
expect(editor.gutter.find('.line-number.fold:eq(0)').text()).toBe '4'
describe "when the scrollView is scrolled to the right", ->
it "adds a drop shadow to the gutter", ->
editor.attachToDom()

View File

@ -307,6 +307,10 @@ class EditSession
fold.destroy()
@setCursorBufferPosition([fold.startRow, 0])
isFoldedAtBufferRow: (bufferRow) ->
screenRow = @screenPositionForBufferPosition([bufferRow]).row
@isFoldedAtScreenRow(screenRow)
isFoldedAtScreenRow: (screenRow) ->
@lineForScreenRow(screenRow)?.fold?

View File

@ -276,6 +276,7 @@ class Editor extends View
destroyFold: (foldId) -> @activeEditSession.destroyFold(foldId)
destroyFoldsContainingBufferRow: (bufferRow) -> @activeEditSession.destroyFoldsContainingBufferRow(bufferRow)
isFoldedAtScreenRow: (screenRow) -> @activeEditSession.isFoldedAtScreenRow(screenRow)
isFoldedAtBufferRow: (bufferRow) -> @activeEditSession.isFoldedAtBufferRow(bufferRow)
lineForScreenRow: (screenRow) -> @activeEditSession.lineForScreenRow(screenRow)
linesForScreenRows: (start, end) -> @activeEditSession.linesForScreenRows(start, end)

View File

@ -58,16 +58,19 @@ class Gutter extends View
@renderLineNumbers(renderFrom, renderTo) if performUpdate
renderLineNumbers: (startScreenRow, endScreenRow) ->
rows = @editor().bufferRowsForScreenRows(startScreenRow, endScreenRow)
editor = @editor()
rows = editor.bufferRowsForScreenRows(startScreenRow, endScreenRow)
cursorScreenRow = @editor().getCursorScreenPosition().row
cursorScreenRow = editor.getCursorScreenPosition().row
@lineNumbers[0].innerHTML = $$$ ->
for row in rows
if row == lastScreenRow
rowValue = ''
else
rowValue = row + 1
@div {class: 'line-number'}, rowValue
classes = ['line-number']
classes.push('fold') if editor.isFoldedAtBufferRow(row)
@div rowValue, class: classes.join(' ')
lastScreenRow = row
@calculateWidth()

View File

@ -43,10 +43,19 @@
-webkit-animation-iteration-count: 1;
}
.editor .fold {
.editor .line.fold {
background-color: #444;
}
.editor .gutter .line-number.fold {
color: #FBA0E3;
opacity: .75;
}
.editor .gutter .line-number.fold.cursor-line {
opacity: 1;
}
.editor .fold.selected {
background-color: #244;
}

View File

@ -46,10 +46,19 @@
-webkit-animation-iteration-count: 1;
}
.editor .fold {
.editor .line.fold {
background-color: #444;
}
.editor .gutter .line-number.fold {
color: #FBA0E3;
opacity: .75;
}
.editor .gutter .line-number.fold.cursor-line {
opacity: 1;
}
.editor .fold.selected {
background-color: #244;
}