Вход Регистрация
Файл: upload/admin/view/javascript/ckeditor/plugins/codemirror/js/util/runmode-standalone.js
Строк: 160
<?php
/* Just enough of CodeMirror to run runMode under node.js */

function splitLines(string){ return string.split(/r?n|r/); };

function 
StringStream(string) {
  
this.pos this.start 0;
  
this.string string;
}
StringStream.prototype = {
  
eol: function() {return this.pos >= this.string.length;},
  
sol: function() {return this.pos == 0;},
  
peek: function() {return this.string.charAt(this.pos) || null;},
  
next: function() {
    if (
this.pos this.string.length)
      return 
this.string.charAt(this.pos++);
  },
  
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 (/[
su00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
    return 
this.pos start;
  },
  
skipToEnd: function() {this.pos this.string.length;},
  
skipTo: function(ch) {
    var 
found this.string.indexOf(chthis.pos);
    if (
found > -1) {this.pos found; return true;}
  },
  
backUp: function(n) {this.pos -= n;},
  
column: function() {return this.start;},
  
indentation: function() {return 0;},
  
match: function(patternconsumecaseInsensitive) {
    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 !== falsethis.pos += pattern.length;
        return 
true;
      }
    }
    else {
      var 
match this.string.slice(this.pos).match(pattern);
      if (
match && consume !== falsethis.pos += match[0].length;
      return 
match;
    }
  },
  
current: function(){return this.string.slice(this.startthis.pos);}
};
exports.StringStream StringStream;

exports.startState = function(modea1a2) {
  return 
mode.startState mode.startState(a1a2) : true;
};

var 
modes exports.modes = {}, mimeModes exports.mimeModes = {};
exports.defineMode = function(namemode) { modes[name] = mode; };
exports.defineMIME = function(mimespec) { mimeModes[mime] = spec; };
exports.getMode = function(optionsspec) {
  if (
typeof spec == "string" && mimeModes.hasOwnProperty(spec))
    
spec mimeModes[spec];
  if (
typeof spec == "string")
    var 
mname specconfig = {};
  else if (
spec != null)
    var 
mname spec.nameconfig spec;
  var 
mfactory modes[mname];
  if (!
mfactory) throw new Error("Unknown mode: " spec);
  return 
mfactory(optionsconfig || {});
};

exports.runMode = function(stringmodespeccallback) {
  var 
mode exports.getMode({indentUnit2}, modespec);
  var 
lines splitLines(string), state exports.startState(mode);
  for (var 
0lines.lengthe; ++i) {
    if (
icallback("n");
    var 
stream = new exports.StringStream(lines[i]);
    while (!
stream.eol()) {
      var 
style mode.token(streamstate);
      
callback(stream.current(), styleistream.start);
      
stream.start stream.pos;
    }
  }
};
?>
Онлайн: 0
Реклама