Highlight locked default code

This commit is contained in:
Matt Lott 2014-12-04 16:33:56 -08:00
parent 5aefd5ffa2
commit bd797e8cfd
2 changed files with 10 additions and 1 deletions

View file

@ -107,6 +107,9 @@
.executed
background-color: rgba(110, 110, 110, 0.12)
.locked-code
border: 1px dashed rgba(53, 45, 34, 0.5)
+keyframes(pulseRedBackground)
from
background-color: rgba(255, 45, 27, 0.4)

View file

@ -293,10 +293,16 @@ module.exports = class SpellView extends CocoView
wrapper => orig.apply obj, args
obj[method]
if @lockedCodeMarkerID?
@aceSession.removeMarker @lockedCodeMarkerID
@lockedCodeMarkerID = null
@readOnlyRanges = []
lines = @aceDoc.getAllLines()
lastRow = row for line, row in lines when not /^\s*$/.test(line)
@readOnlyRanges.push new Range 0, 0, lastRow, lines[lastRow].length - 1 if lastRow?
if lastRow?
@readOnlyRanges.push new Range 0, 0, lastRow, lines[lastRow].length - 1
@lockedCodeMarkerID = @aceSession.addMarker @readOnlyRanges[0], 'locked-code', 'fullLine'
# Override write operations that intersect with default code
interceptCommand @ace, 'onPaste', preventReadonly