Dr.*_*eon 8 javascript cocoa autocomplete objective-c ace-editor
好的,所以这是交易:
现在,这里有一个问题:
任何帮助都不仅仅是值得赞赏的.
小智 19
可以在ace编辑器中实现AutoCompletion ..
代码:
var editor = ace.edit('editor');
editor.setTheme("ace/theme/eclipse");
editor.getSession().setMode("ace/mode/java");
editor.setShowInvisibles(true);
editor.setDisplayIndentGuides(true);
editor.getSession().setUseWrapMode(true);
var jsonUrl = "JSON/Components/proce.json";
//the url where the json file with the suggestions is present
var langTools = ace.require("ace/ext/language_tools");
editor.setOptions({enableBasicAutocompletion: true});
var rhymeCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
if (prefix.length === 0) { callback(null, []); return }
$.getJSON(jsonUrl, function(wordList) {
callback(null, wordList.map(function(ea) {
return {name: ea.word, value: ea.word, meta: "optional text"}
}));
})
}
}
langTools.addCompleter(rhymeCompleter);
Run Code Online (Sandbox Code Playgroud)
Json文件格式:
[ {"word":"hello"},
{"word":"good morning"},
{"word":"suggestions"},
{"word":"auto suggest"},
{"word":"try this"}]
Run Code Online (Sandbox Code Playgroud)
参考/演示:
http://plnkr.co/edit/6MVntVmXYUbjR0DI82Cr?p=preview
现在要在Ace中添加实时自动完成功能:在您的HTML中包括ace / ext-language_tools.js。的。调用尚无法正常运行,因此您可能必须为此输入ctrl-space或alt-space,但是现在将显示标准语法内容,例如写函数。然后:
var editor = ace.edit("editor");
ace.require("ace/ext/language_tools");
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8686 次 |
| 最近记录: |