笙默考试管理系统-MyExamTest----codemirror(22)
目录
一、 笙默考试管理系统-MyExamTest
二、 笙默考试管理系统-MyExamTest
三、 笙默考试管理系统-MyExamTest
四、 笙默考试管理系统-MyExamTest
五、 笙默考试管理系统-MyExamTest
return {line: line, ch: ch};
}
function moveH(dir, unit) {
var pos = dir < 0 ? sel.from : sel.to;
if (shiftSelecting || posEq(sel.from, sel.to)) pos = findPosH(dir, unit);
setCursor(pos.line, pos.ch, true);
}
function deleteH(dir, unit) {
if (!posEq(sel.from, sel.to)) replaceRange("", sel.from, sel.to);
else if (dir < 0) replaceRange("", findPosH(dir, unit), sel.to);
else replaceRange("", sel.from, findPosH(dir, unit));
userSelChange = true;
}
var goalColumn = null;
function moveV(dir, unit) {
var dist = 0, pos = localCoords(sel.inverted ? sel.from : sel.to, true);
if (goalColumn != null) pos.x = goalColumn;
if (unit == "page") dist = scroller.clientHeight;
else if (unit == "line") dist = textHeight();
var target = coordsChar(pos.x, pos.y + dist * dir + 2);
setCursor(target.line, target.ch, true);
goalColumn = pos.x;
}
function selectWordAt(pos) {
var line = getLine(pos.line).text;
var start = pos.ch, end = pos.ch;
while (start > 0 && isWordChar(line.charAt(start - 1))) --start;
while (end < line.length && isWordChar(line.charAt(end))) ++end;
setSelectionUser({line: pos.line, ch: start}, {line: pos.line, ch: end});
}
function selectLine(line) {
setSelectionUser({line: line, ch: 0}, {line: line, ch: getLine(line).text.length});
}
function indentSelected(mode) {
if (posEq(sel.from, sel.to)) return indentLine(sel.from.line, mode);
var e = sel.to.line - (sel.to.ch ? 0 : 1);
for (var i = sel.from.line; i <= e; ++i) indentLine(i, mode);
}
function indentLine(n, how) {
if (!how) how = "add";
if (how == "smart") {
if (!mode.indent) how = "prev";
else var state = getStateBefore(n);
}
var line = getLine(n), curSpace = line.indentation(options.tabSize),
curSpaceString = line.text.match(/^\s*/)[0], indentation;
if (how == "prev") {
if (n) indentation = getLine(n-1).indentation(options.tabSize);
else indentation = 0;