Fix #25
This commit is contained in:
parent
fef4a30801
commit
0062f92da8
|
@ -64,15 +64,16 @@ var editors = {
|
||||||
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)))
|
while (end < curLine.length && word.test(curLine.charAt(end))) {
|
||||||
++end;
|
++end;
|
||||||
while (start && word.test(curLine.charAt(start - 1)))
|
}
|
||||||
|
while (start && word.test(curLine.charAt(start - 1))) {
|
||||||
--start;
|
--start;
|
||||||
|
}
|
||||||
var request = {
|
var request = {
|
||||||
code: editor.getValue(),
|
code: editor.getValue(),
|
||||||
cursorLine: editor.getCursor().line,
|
cursorLine: cur.line,
|
||||||
cursorCh: editor.getCursor().ch
|
cursorCh: cur.ch
|
||||||
};
|
};
|
||||||
|
|
||||||
var autocompleteHints = [];
|
var autocompleteHints = [];
|
||||||
|
@ -110,6 +111,36 @@ var editors = {
|
||||||
CodeMirror.commands.autocompleteAnyWord = function(cm) {
|
CodeMirror.commands.autocompleteAnyWord = function(cm) {
|
||||||
cm.showHint({hint: CodeMirror.hint.auto});
|
cm.showHint({hint: CodeMirror.hint.auto});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CodeMirror.commands.autocompleteRightPart = function(cm) {
|
||||||
|
setTimeout(function() {
|
||||||
|
var cur = cm.getCursor();
|
||||||
|
var curLine = cm.getLine(cur.line);
|
||||||
|
var curChar = curLine.charAt(cur.ch - 1);
|
||||||
|
|
||||||
|
replacement = '';
|
||||||
|
|
||||||
|
switch (curChar) {
|
||||||
|
case '(':
|
||||||
|
replacement = ')';
|
||||||
|
break;
|
||||||
|
case '[':
|
||||||
|
replacement = ']';
|
||||||
|
break;
|
||||||
|
case '{':
|
||||||
|
replacement = '}';
|
||||||
|
break;
|
||||||
|
default: // " or '
|
||||||
|
replacement = curChar;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.replaceRange(replacement, CodeMirror.Pos(cur.line, cur.ch));
|
||||||
|
cm.setCursor(CodeMirror.Pos(cur.line, cur.ch));
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
return CodeMirror.Pass;
|
||||||
|
};
|
||||||
},
|
},
|
||||||
newEditor: function(data) {
|
newEditor: function(data) {
|
||||||
$(".ico-fullscreen").show();
|
$(".ico-fullscreen").show();
|
||||||
|
@ -142,7 +173,12 @@ var editors = {
|
||||||
},
|
},
|
||||||
"F11": function(cm) {
|
"F11": function(cm) {
|
||||||
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
|
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
|
||||||
}
|
},
|
||||||
|
"'('": "autocompleteRightPart",
|
||||||
|
"'['": "autocompleteRightPart",
|
||||||
|
"'{'": "autocompleteRightPart",
|
||||||
|
"'\"'": "autocompleteRightPart",
|
||||||
|
"'''": "autocompleteRightPart",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
editor.setSize('100%', 430);
|
editor.setSize('100%', 430);
|
||||||
|
|
Loading…
Reference in New Issue