笙默考试管理系统-MyExamTest----codemirror(13)
目录
一、 笙默考试管理系统-MyExamTest----codemirror
二、 笙默考试管理系统-MyExamTest----codemirror
三、 笙默考试管理系统-MyExamTest----codemirror
四、 笙默考试管理系统-MyExamTest----codemirror
五、 笙默考试管理系统-MyExamTest----codemirror
function replaceSelection(code, collapse) {
replaceRange1(splitLines(code), sel.from, sel.to, function(end) {
if (collapse == "end") return {from: end, to: end};
else if (collapse == "start") return {from: sel.from, to: sel.from};
else return {from: sel.from, to: end};
});
}
function replaceRange1(code, from, to, computeSel) {
var endch = code.length == 1 ? code[0].length + from.ch : code[code.length-1].length;
var newSel = computeSel({line: from.line + code.length - 1, ch: endch});
updateLines(from, to, code, newSel.from, newSel.to);
}
function getRange(from, to) {
var l1 = from.line, l2 = to.line;
if (l1 == l2) return getLine(l1).text.slice(from.ch, to.ch);
var code = [getLine(l1).text.slice(from.ch)];
doc.iter(l1 + 1, l2, function(line) { code.push(line.text); });
code.push(getLine(l2).text.slice(0, to.ch));
return code.join("\n");
}
function getSelection() {
return getRange(sel.from, sel.to);
}
var pollingFast = false; // Ensures slowPoll doesn't cancel fastPoll
function slowPoll() {
if (pollingFast) return;
poll.set(options.pollInterval, function() {
startOperation();
readInput();
if (focused) slowPoll();
endOperation();
});
}