笙默考试管理系统-MyExamTest----codemirror(23)

笙默考试管理系统-MyExamTest----codemirror(23)

目录

笙默考试管理系统-MyExamTest----codemirror(23)

一、 笙默考试管理系统-MyExamTest----codemirror

二、 笙默考试管理系统-MyExamTest----codemirror

三、 笙默考试管理系统-MyExamTest----codemirror

四、 笙默考试管理系统-MyExamTest----codemirror

五、 笙默考试管理系统-MyExamTest----codemirror

  • 笙默考试管理系统-MyExamTest----codemirror

  if (x > toX) return 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 (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;}

            }

        }

  • 笙默考试管理系统-MyExamTest----codemirror

        var tempId = Math.floor(Math.random() * 0xffffff).toString(16);

        function measureLine(line, ch) {

            var extra = "";

            // Include extra text at the end to make sure the measured line is wrapped in the right way.

            if (options.lineWrapping) {

                var end = line.text.indexOf(" ", ch + 2);

                extra = htmlEscape(line.text.slice(ch + 1, end < 0 ? line.text.length : end + (ie ? 5 : 0)));

            }

            measure.innerHTML = "

" + line.getHTML(null, null, false, tabText, ch) +

                '' + htmlEscape(line.text.charAt(ch) || " ") + "" +

                extra + "

";

            var elt = document.getElementById("CodeMirror-temp-" + tempId);

            var top = elt.offsetTop, left = elt.offsetLeft;

            // Older IEs report zero offsets for spans directly after a wrap

            if (ie && ch && top == 0 && left == 0) {

                var backup = document.createElement("span");

                backup.innerHTML = "x";

                elt.parentNode.insertBefore(backup, elt.nextSibling);

                top = backup.offsetTop;

            }

  • 笙默考试管理系统-MyExamTest----codemirror

            return {top: top, left: left};

        }

        function localCoords(pos, inLineWrap) {

            var x, lh = textHeight(), y = lh * (heightAtLine(doc, pos.line) - (inLineWrap ? displayOffset : 0));

            if (pos.ch == 0) x = 0;

            else {

                var sp = measureLine(getLine(pos.line), pos.ch);

                x = sp.left;

                if (options.lineWrapping) y += Math.max(0, sp.top);

            }

            return {x: x, y: y, yBot: y + lh};

        }

        // Coords must be lineSpace-local

        function coordsChar(x, y) {

            if (y < 0) y = 0;

            var th = textHeight(), cw = charWidth(), heightPos = displayOffset + Math.floor(y / th);

  • 笙默考试管理系统-MyExamTest----codemirror

            var lineNo = lineAtHeight(doc, heightPos);

            if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc.size - 1).text.length};

            var lineObj = getLine(lineNo), text = lineObj.text;

            var tw = options.lineWrapping, innerOff = tw ? heightPos - heightAtLine(doc, lineNo) : 0;

            if (x <= 0 && innerOff == 0) return {line: lineNo, ch: 0};

            function getX(len) {

                var sp = measureLine(lineObj, len);

                if (tw) {

  • 笙默考试管理系统-MyExamTest----codemirror

                    var off = Math.round(sp.top / th);

                    return Math.max(0, sp.left + (off - innerOff) * scroller.clientWidth);

                }

                return sp.left;

你可能感兴趣的:(笙默考试管理系统,javascript,前端,java)