refactor
This commit is contained in:
parent
ec477b5e7a
commit
1c84934a1e
|
@ -5,15 +5,16 @@ var editors = {
|
||||||
editors._initTabs();
|
editors._initTabs();
|
||||||
},
|
},
|
||||||
_initAutocomplete: function() {
|
_initAutocomplete: function() {
|
||||||
CodeMirror.registerHelper("hint", "go", function(editor, options) {
|
CodeMirror.registerHelper("hint", "go", function(editor) {
|
||||||
var word = /[\w$]+/
|
var word = /[\w$]+/;
|
||||||
|
|
||||||
var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
|
var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
|
||||||
|
|
||||||
var start = cur.ch, end = start;
|
var start = cur.ch, end = start;
|
||||||
while (end < curLine.length && word.test(curLine.charAt(end))) ++end;
|
while (end < curLine.length && word.test(curLine.charAt(end)))
|
||||||
while (start && word.test(curLine.charAt(start - 1))) --start;
|
++end;
|
||||||
var curWord = start != end && curLine.slice(start, end);
|
while (start && word.test(curLine.charAt(start - 1)))
|
||||||
|
--start;
|
||||||
|
|
||||||
var request = {
|
var request = {
|
||||||
code: editor.getValue(),
|
code: editor.getValue(),
|
||||||
|
@ -47,23 +48,18 @@ var editors = {
|
||||||
});
|
});
|
||||||
|
|
||||||
CodeMirror.commands.autocompleteAfterDot = function(cm) {
|
CodeMirror.commands.autocompleteAfterDot = function(cm) {
|
||||||
var cur = cm.getCursor();
|
|
||||||
// console.log(cm.getRange(CodeMirror.Pos(cur.line, cur.ch - 1), cur));
|
|
||||||
|
|
||||||
// var token = cm.getTokenAt(cm.getCursor());
|
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (!cm.state.completionActive) {
|
if (!cm.state.completionActive) {
|
||||||
cm.showHint({hint: CodeMirror.hint.go, completeSingle: false});
|
cm.showHint({hint: CodeMirror.hint.go, completeSingle: false});
|
||||||
}
|
}
|
||||||
}, 50)
|
}, 50);
|
||||||
|
|
||||||
return CodeMirror.Pass;
|
return CodeMirror.Pass;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodeMirror.commands.autocompleteAnyWord = function(cm) {
|
CodeMirror.commands.autocompleteAnyWord = function(cm) {
|
||||||
cm.showHint({hint: CodeMirror.hint.auto});
|
cm.showHint({hint: CodeMirror.hint.auto});
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
_initTabs: function() {
|
_initTabs: function() {
|
||||||
var $tabsPanel = $(".edit-panel .tabs-panel"),
|
var $tabsPanel = $(".edit-panel .tabs-panel"),
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
var tabs = function () {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
$.extend(tabs.prototype, {
|
||||||
|
add: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
remove: function () {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue