笙默考试管理系统-MyExamTest----codemirror(25)
目录
一、 笙默考试管理系统-MyExamTest----codemirror
二、 笙默考试管理系统-MyExamTest----codemirror
三、 笙默考试管理系统-MyExamTest----codemirror
四、 笙默考试管理系统-MyExamTest----codemirror
五、 笙默考试管理系统-MyExamTest----codemirror
var from = 0, fromX = 0, to = text.length, toX;
// Guess a suitable upper bound for our search.
var estimated = Math.min(to, Math.ceil((x + innerOff * scroller.clientWidth * .9) / cw));
for (;;) {
var estX = getX(estimated);
if (estX <= x && estimated < to) estimated = Math.min(to, Math.ceil(estimated * 1.2));
else {toX = estX; to = estimated; break;}
}
if (x > toX) return {line: lineNo, ch: to};
// Try to guess a suitable lower bound as well.
estimated = Math.floor(to * 0.8); estX = getX(estimated);
if (estX < x) {from = estimated; fromX = estX;}
// Do a binary search between these bounds.
for (;;) {
if (to - from <= 1) return {line: lineNo, ch: (toX - x > x - fromX) ? from : to};
var middle = Math.ceil((from + to) / 2), middleX = getX(middle);
if (middleX > x) {to = middle; toX = middleX;}
else {from = middle; fromX = middleX;}
}
}
function pageCoords(pos) {
var local = localCoords(pos, true), off = eltOffset(lineSpace);
return {x: off.left + local.x, y: off.top + local.y, yBot: off.top + local.yBot};
}
var cachedHeight, cachedHeightFor, measureText;
function textHeight() {
if (measureText == null) {
measureText = "
";";
for (var i = 0; i < 49; ++i) measureText += "x
";
measureText += "x
var offsetHeight = lineDiv.clientHeight;
if (offsetHeight == cachedHeightFor) return cachedHeight;
cachedHeightFor = offsetHeight;
measure.innerHTML = measureText;
cachedHeight = measure.firstChild.offsetHeight / 50 || 1;
measure.innerHTML = "";
return cachedHeight;