integrated autocomplete

This commit is contained in:
Dominik Kundel 2014-06-18 17:57:42 +02:00
parent 9a3ba70ea2
commit f6355b034b
5 changed files with 22 additions and 3 deletions

View file

@ -382,6 +382,8 @@
editor_config_keybindings_label: "Key Bindings"
editor_config_keybindings_default: "Default (Ace)"
editor_config_keybindings_description: "Adds additional shortcuts known from the common editors."
editor_config_livecompletion_label: "Live Autocompletion"
editor_config_livecompletion_description: "Displays autocomplete suggestions while typing."
editor_config_invisibles_label: "Show Invisibles"
editor_config_invisibles_description: "Displays invisibles such as spaces or tabs."
editor_config_indentguides_label: "Show Indent Guides"

View file

@ -65,6 +65,7 @@ UserSchema = c.object {},
invisibles: {type: 'boolean', 'default': false}
indentGuides: {type: 'boolean', 'default': false}
behaviors: {type: 'boolean', 'default': false}
liveCompletion: {type: 'boolean', 'default': false}
simulatedBy: {type: 'integer', minimum: 0, default: 0}
simulatedFor: {type: 'integer', minimum: 0, default: 0}

View file

@ -27,6 +27,12 @@ block modal-body-content
option(value="emacs" selected=(keyBindings === "emacs")) Emacs
span.help-block(data-i18n="play_level.editor_config_keybindings_description") Adds additional shortcuts known from the common editors.
.form-group.checkbox
label(for="tome-live-completion")
input#tome-live-completion(name="liveCompletion", type="checkbox", checked=liveCompletion)
span(data-i18n="play_level.editor_config_livecompletion_label") Live Autocompletion
span.help-block(data-i18n="play_level.editor_config_livecompletion_description") Displays autocomplete suggestions while typing.
.form-group.checkbox
label(for="tome-invisibles")
input#tome-invisibles(name="invisibles", type="checkbox", checked=invisibles)

View file

@ -13,6 +13,7 @@ module.exports = class EditorConfigModal extends View
invisibles: false
indentGuides: false
behaviors: false
liveCompletion: false
events:
'change #tome-invisibles': 'updateInvisibles'
@ -20,6 +21,7 @@ module.exports = class EditorConfigModal extends View
'change #tome-key-bindings': 'updateKeyBindings'
'change #tome-indent-guides': 'updateIndentGuides'
'change #tome-behaviors': 'updateBehaviors'
'change #tome-live-completion': 'updateLiveCompletion'
constructor: (options) ->
super(options)
@ -43,6 +45,7 @@ module.exports = class EditorConfigModal extends View
c.invisibles = @aceConfig.invisibles
c.indentGuides = @aceConfig.indentGuides
c.behaviors = @aceConfig.behaviors
c.liveCompletion = @aceConfig.liveCompletion
c
updateSessionLanguage: ->
@ -63,6 +66,9 @@ module.exports = class EditorConfigModal extends View
updateBehaviors: ->
@aceConfig.behaviors = @$el.find('#tome-behaviors').prop('checked')
updateLiveCompletion: ->
@aceConfig.liveCompletion = @$el.find('#tome-live-completion').prop('checked')
afterRender: ->
super()
@ -75,6 +81,7 @@ module.exports = class EditorConfigModal extends View
@aceConfig.keyBindings = @$el.find('#tome-key-bindings').val()
@aceConfig.indentGuides = @$el.find('#tome-indent-guides').prop('checked')
@aceConfig.behaviors = @$el.find('#tome-behaviors').prop('checked')
@aceConfig.liveCompletion = @$el.find('#tome-live-completion').prop('checked')
me.set 'aceConfig', @aceConfig
Backbone.Mediator.publish 'tome:change-config'
Backbone.Mediator.publish 'tome:change-language', language: newLanguage unless newLanguage is oldLanguage

View file

@ -95,9 +95,10 @@ module.exports = class SpellView extends View
@toggleControls null, @writable
@aceSession.selection.on 'changeCursor', @onCursorActivity
$(@ace.container).find('.ace_gutter').on 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
@zatanna = new Zatanna @ace
# @addZatannaSnippets()
# window.aceEditor = @ace
@zatanna = new Zatanna @ace,
liveCompletion: aceConfig.liveCompletion ? false
completers:
keywords: false
createACEShortcuts: ->
@aceCommands = aceCommands = []
@ -643,10 +644,12 @@ module.exports = class SpellView extends View
@ace.setDisplayIndentGuides aceConfig.indentGuides # default false
@ace.setShowInvisibles aceConfig.invisibles # default false
@ace.setKeyboardHandler @keyBindings[aceConfig.keyBindings ? 'default']
@zatanna.set 'liveCompletion', (aceConfig.liveCompletion ? false)
onChangeLanguage: (e) ->
if @spell.canWrite()
@aceSession.setMode @editModes[e.language]
@zatanna.set 'language', @editModes[e.language].substr('ace/mode/')
dismiss: ->
@spell.hasChangedSignificantly @getSource(), null, (hasChanged) =>