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

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

目录

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

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

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

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

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

  • 笙默考试管理系统-MyExamTest

 if (!posEq(to, sel.to)) {

                    if (to.line < oldTo)

                        changes.push({from: Math.max(oldFrom, from.line), to: oldTo + 1});

                    else

                        changes.push({from: Math.max(from.line, oldTo), to: to.line + 1});

                }

            }

            sel.from = from; sel.to = to;

            selectionChanged = true;

        }

  • 笙默考试管理系统-MyExamTest

        function skipHidden(pos, oldLine, oldCh) {

            function getNonHidden(dir) {

                var lNo = pos.line + dir, end = dir == 1 ? doc.size : -1;

                while (lNo != end) {

                    var line = getLine(lNo);

                    if (!line.hidden) {

                        var ch = pos.ch;

                        if (ch > oldCh || ch > line.text.length) ch = line.text.length;

                        return {line: lNo, ch: ch};

                    }

                    lNo += dir;

                }

            }

  • 笙默考试管理系统-MyExamTest

            var line = getLine(pos.line);

            if (!line.hidden) return pos;

            if (pos.line >= oldLine) return getNonHidden(1) || getNonHidden(-1);

            else return getNonHidden(-1) || getNonHidden(1);

        }

        function setCursor(line, ch, user) {

            var pos = clipPos({line: line, ch: ch || 0});

            (user ? setSelectionUser : setSelection)(pos, pos);

        }

        function clipLine(n) {return Math.max(0, Math.min(n, doc.size-1));}

        function clipPos(pos) {

            if (pos.line < 0) return {line: 0, ch: 0};

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

            var ch = pos.ch, linelen = getLine(pos.line).text.length;

            if (ch == null || ch > linelen) return {line: pos.line, ch: linelen};

            else if (ch < 0) return {line: pos.line, ch: 0};

            else return pos;

        }

  • 笙默考试管理系统-MyExamTest

        function findPosH(dir, unit) {

            var end = sel.inverted ? sel.from : sel.to, line = end.line, ch = end.ch;

            var lineObj = getLine(line);

            function findNextLine() {

                for (var l = line + dir, e = dir < 0 ? -1 : doc.size; l != e; l += dir) {

                    var lo = getLine(l);

                    if (!lo.hidden) { line = l; lineObj = lo; return true; }

                }

            }

            function moveOnce(boundToLine) {

                if (ch == (dir < 0 ? 0 : lineObj.text.length)) {

                    if (!boundToLine && findNextLine()) ch = dir < 0 ? lineObj.text.length : 0;

  • 笙默考试管理系统-MyExamTest

                    else return false;

                } else ch += dir;

                return true;

            }

            if (unit == "char") moveOnce();

            else if (unit == "column") moveOnce(true);

            else if (unit == "word") {

                var sawWord = false;

                for (;;) {

                    if (dir < 0) if (!moveOnce()) break;

                    if (isWordChar(lineObj.text.charAt(ch))) sawWord = true;

                    else if (sawWord) {if (dir < 0) {dir = 1; moveOnce();} break;}

                    if (dir > 0) if (!moveOnce()) break;

                }

            }

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