added support for inserting snippets by shift+click

This commit is contained in:
Dominik Kundel 2014-08-04 23:02:54 +02:00
parent 86eea93e2f
commit 50517431db
2 changed files with 11 additions and 0 deletions

View file

@ -71,6 +71,9 @@ module.exports = class SpellPaletteEntryView extends CocoView
Backbone.Mediator.publish 'tome:palette-pin-toggled', entry: @, pinned: @popoverPinned
onClick: (e) =>
if key.shift
Backbone.Mediator.publish 'tome:insert-snippet', doc: @options.doc, language: @options.language
return
@togglePinned()
Backbone.Mediator.publish 'tome:palette-clicked', thang: @thang, prop: @doc.name, entry: @

View file

@ -47,6 +47,7 @@ module.exports = class SpellView extends CocoView
'tome:change-language': 'onChangeLanguage'
'tome:change-config': 'onChangeEditorConfig'
'tome:update-snippets': 'addZatannaSnippets'
'tome:insert-snippet': 'onInsertSnippet'
'spell-beautify': 'onSpellBeautify'
events:
@ -661,6 +662,13 @@ module.exports = class SpellView extends CocoView
@spell.setLanguage e.language
@reloadCode true if wasDefault
onInsertSnippet: (e) ->
console.log 'doc', e.doc
return unless e.doc.snippets?[e.language]?.code
snippetManager = ace.require('ace/snippets').snippetManager
snippetManager.insertSnippet @ace, e.doc.snippets[e.language].code
return
dismiss: ->
@spell.hasChangedSignificantly @getSource(), null, (hasChanged) =>
@recompile() if hasChanged