mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-01 15:50:11 -04:00
Trying out a Ctrl+Shift+B code beautifier option.
This commit is contained in:
parent
b3009ae909
commit
9eb8bb97f5
2 changed files with 15 additions and 1 deletions
app
|
@ -17,6 +17,8 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
|||
|
||||
destroy: ->
|
||||
Backbone.Mediator.unsubscribe(channel, @[func], @) for channel, func of @subscriptions
|
||||
@show = null
|
||||
@destroyed = true
|
||||
|
||||
build: ->
|
||||
@mouseEnabled = @mouseChildren = false
|
||||
|
@ -46,7 +48,7 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
|||
@uncache()
|
||||
|
||||
show: =>
|
||||
return unless @mouseInBounds and @lastPos
|
||||
return unless @mouseInBounds and @lastPos and not @destroyed
|
||||
@label.text = "(#{@lastPos.x}, #{@lastPos.y})"
|
||||
[width, height] = [@label.getMeasuredWidth(), @label.getMeasuredHeight()]
|
||||
@label.regX = width / 2
|
||||
|
|
|
@ -28,6 +28,7 @@ module.exports = class SpellView extends View
|
|||
'modal-closed': 'focus'
|
||||
'focus-editor': 'focus'
|
||||
'tome:spell-statement-index-updated': 'onStatementIndexUpdated'
|
||||
'spell-beautify': 'onSpellBeautify'
|
||||
|
||||
events:
|
||||
'mouseout': 'onMouseOut'
|
||||
|
@ -123,6 +124,10 @@ module.exports = class SpellView extends View
|
|||
name: 'spell-step-backward'
|
||||
bindKey: {win: 'Ctrl-Alt-[', mac: 'Command-Alt-[|Ctrl-Alt-]'}
|
||||
exec: -> Backbone.Mediator.publish 'spell-step-backward'
|
||||
addCommand
|
||||
name: 'spell-beautify'
|
||||
bindKey: {win: 'Ctrl-Shift-B', mac: 'Command-Shift-B|Ctrl-Shift-B'}
|
||||
exec: -> Backbone.Mediator.publish 'spell-beautify'
|
||||
|
||||
fillACE: ->
|
||||
@ace.setValue @spell.source
|
||||
|
@ -332,6 +337,7 @@ module.exports = class SpellView extends View
|
|||
# Could use the user-code-problem style... or we could leave that to other places.
|
||||
@ace[if @problems.length then 'setStyle' else 'unsetStyle'] 'user-code-problem'
|
||||
Backbone.Mediator.publish 'tome:problems-updated', spell: @spell, problems: @problems, isCast: isCast
|
||||
@ace.resize()
|
||||
|
||||
# Autocast:
|
||||
# Goes immediately if the code is a) changed and b) complete/valid and c) the cursor is at beginning or end of a line
|
||||
|
@ -513,6 +519,12 @@ module.exports = class SpellView extends View
|
|||
filters.revertImage background if @controlsEnabled
|
||||
filters.darkenImage background, 0.8 unless @controlsEnabled
|
||||
|
||||
onSpellBeautify: (e) ->
|
||||
return unless @ace.isFocused() and @spellThang
|
||||
ugly = @getSource()
|
||||
pretty = @spellThang.aether.beautify ugly
|
||||
@ace.setValue pretty
|
||||
|
||||
dismiss: ->
|
||||
@recompile() if @spell.hasChangedSignificantly @getSource()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue