Clean up visual idents, limit to players under level 20 or with indentGuides turned on.

This commit is contained in:
Rob 2015-11-30 13:54:50 -05:00
parent e6afb51085
commit 1b43c3e54f

View file

@ -92,7 +92,7 @@ module.exports = class SpellView extends CocoView
@aceSession.setNewLineMode 'unix'
@aceSession.setUseSoftTabs true
@ace.setTheme 'ace/theme/textmate'
@ace.setDisplayIndentGuides aceConfig.indentGuides
@ace.setDisplayIndentGuides false
@ace.setShowPrintMargin false
@ace.setShowInvisibles aceConfig.invisibles
@ace.setBehavioursEnabled aceConfig.behaviors
@ -253,6 +253,7 @@ module.exports = class SpellView extends CocoView
hookACECustomBehavior: ->
aceConfig = me.get('aceConfig') ? {}
@ace.commands.on 'exec', (e) =>
# When pressing enter with an active selection, just make a new line under it.
if e.command.name is 'enter-skip-delimiters'
@ -261,6 +262,7 @@ module.exports = class SpellView extends CocoView
e.editor.execCommand 'gotolineend'
return true
if me.level() < 20 or aceConfig.indentGuides
@aceSession.addDynamicMarker
update: (html, markerLayer, session, config) =>
Range = ace.require('ace/range').Range
@ -284,17 +286,11 @@ module.exports = class SpellView extends CocoView
xstart = startOfRow(range.start.row)
level = Math.floor(xstart / 4)
data =
b: xstart
i: startOfRow(range.start.row + 1)
s: range.start.row, e: range.end.row, c: colors[level % colors.length]
color = data.c
t = markerLayer.$getTop(data.s + 1, config)
h = config.lineHeight * (data.e - data.s)
l = markerLayer.$padding + data.b * config.characterWidth
indent = startOfRow(range.start.row + 1)
color = colors[level % colors.length]
t = markerLayer.$getTop(range.start.row + 1, config)
h = config.lineHeight * (range.end.row - range.start.row)
l = markerLayer.$padding + xstart * config.characterWidth
# w = (data.i - data.b) * config.characterWidth
w = 4 * config.characterWidth
@ -304,7 +300,7 @@ module.exports = class SpellView extends CocoView
"border-right: 3px solid rgba(#{color},0.4);",
'"></div>' ].join ''
markerLayer.drawTextMarker html, new Range(data.s,data.b, data.s, 1000), 'rob', config, "border: 3px solid rgba(#{color}, 0.4); position: absolute"
markerLayer.drawTextMarker html, new Range(range.start.row,xstart, range.start.row, 1000), 'rob', config, "border: 3px solid rgba(#{color}, 0.4); position: absolute"
fillACE: ->
@ace.setValue @spell.source