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

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

目录

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

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

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

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

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

  • 笙默考试管理系统-MyExamTest

CodeMirror.copyState = copyState;

    function startState(mode, a1, a2) {

        return mode.startState ? mode.startState(a1, a2) : true;

    }

    CodeMirror.startState = startState;

    // The character stream used by a mode's parser.

    function StringStream(string, tabSize) {

        this.pos = this.start = 0;

        this.string = string;

        this.tabSize = tabSize || 8;

    }

    StringStream.prototype = {

        eol: function() {return this.pos >= this.string.length;},

        sol: function() {return this.pos == 0;},

        peek: function() {return this.string.charAt(this.pos);},

        next: function() {

            if (this.pos < this.string.length)

                return this.string.charAt(this.pos++);

        },

  • 笙默考试管理系统-MyExamTest

        eat: function(match) {

            var ch = this.string.charAt(this.pos);

            if (typeof match == "string") var ok = ch == match;

            else var ok = ch && (match.test ? match.test(ch) : match(ch));

            if (ok) {++this.pos; return ch;}

        },

        eatWhile: function(match) {

            var start = this.pos;

            while (this.eat(match)){}

            return this.pos > start;

        },

        eatSpace: function() {

            var start = this.pos;

            while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;

            return this.pos > start;

        },

  • 笙默考试管理系统-MyExamTest

        skipToEnd: function() {this.pos = this.string.length;},

        skipTo: function(ch) {

            var found = this.string.indexOf(ch, this.pos);

            if (found > -1) {this.pos = found; return true;}

        },

        backUp: function(n) {this.pos -= n;},

        column: function() {return countColumn(this.string, this.start, this.tabSize);},

        indentation: function() {return countColumn(this.string, null, this.tabSize);},

        match: function(pattern, consume, caseInsensitive) {

            if (typeof pattern == "string") {

                function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}

                if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {

                    if (consume !== false) this.pos += pattern.length;

                    return true;

                }

            }

  • 笙默考试管理系统-MyExamTest

            else {

                var match = this.string.slice(this.pos).match(pattern);

                if (match && consume !== false) this.pos += match[0].length;

                return match;

            }

        },

        current: function(){return this.string.slice(this.start, this.pos);}

    };

    CodeMirror.StringStream = StringStream;

    function MarkedText(from, to, className, set) {

        this.from = from; this.to = to; this.style = className; this.set = set;

}

  • 笙默考试管理系统-MyExamTest

    MarkedText.prototype = {

        attach: function(line) { this.set.push(line); },

        detach: function(line) {

            var ix = indexOf(this.set, line);

            if (ix > -1) this.set.splice(ix, 1);

        },

        split: function(pos, lenBefore) {

            if (this.to <= pos && this.to != null) return null;

            var from = this.from < pos || this.from == null ? null : this.from - pos + lenBefore;

            var to = this.to == null ? null : this.to - pos + lenBefore;

            return new MarkedText(from, to, this.style, this.set);

        },

        dup: function() { return new MarkedText(null, null, this.style, this.set); },

        clipTo: function(fromOpen, from, toOpen, to, diff) {

            if (this.from != null && this.from >= from)

                this.from = Math.max(to, this.from) + diff;

            if (this.to != null && this.to > from)

                this.to = to < this.to ? this.to + diff : from;

            if (fromOpen && to > this.from && (to < this.to || this.to == null))

                this.from = null;

            if (toOpen && (from < this.to || this.to == null) && (from > this.from || this.from == null))

                this.to = null;

        },

        isDead: function() { return this.from != null && this.to != null && this.from >= this.to; },

        sameSet: function(x) { return this.set == x.set; }

    };

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