Commit b424ccfb authored by Sebastien Robin's avatar Sebastien Robin

add business template for CodeMirror

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42291 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 271f24cf
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_code_mirror</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>codemirror</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>contrib</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>csharp</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.91</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>csharpcolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
pre.code, .editbox {\n
color: #666666;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.csharp-punctuation {\n
color: green;\n
}\n
\n
span.csharp-operator {\n
color: purple;\n
}\n
\n
span.csharp-keyword {\n
color: blue;\n
}\n
\n
span.csharp-atom {\n
color: brown;\n
}\n
\n
span.csharp-variable {\n
color: black;\n
}\n
\n
span.csharp-variabledef {\n
color: #0000FF;\n
}\n
\n
span.csharp-localvariable {\n
color: #004499;\n
}\n
\n
span.csharp-property {\n
color: black;\n
}\n
\n
span.csharp-comment {\n
color: green;\n
}\n
\n
span.csharp-string {\n
color: red;\n
}\n
\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>627</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.91</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsecsharp.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Parse function for JavaScript. Makes use of the tokenizer from\n
* tokenizecsharp.js. Note that your parsers do not have to be\n
* this complicated -- if you don\'t want to recognize local variables,\n
* in many languages it is enough to just look for braces, semicolons,\n
* parentheses, etc, and know when you are inside a string or comment.\n
*\n
* See manual.html for more info about the parser interface.\n
*/\n
\n
var JSParser = Editor.Parser = (function() {\n
// Token types that can be considered to be atoms.\n
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};\n
// Setting that can be used to have JSON data indent properly.\n
var json = false;\n
// Constructor for the lexical context objects.\n
function CSharpLexical(indented, column, type, align, prev, info) {\n
// indentation at start of this line\n
this.indented = indented;\n
// column at which this scope was opened\n
this.column = column;\n
// type of scope (\'vardef\', \'stat\' (statement), \'form\' (special form), \'[\', \'{\', or \'(\')\n
this.type = type;\n
// \'[\', \'{\', or \'(\' blocks that have any text after their opening\n
// character are said to be \'aligned\' -- any lines below are\n
// indented all the way to the opening character.\n
if (align != null)\n
this.align = align;\n
// Parent scope, if any.\n
this.prev = prev;\n
this.info = info;\n
}\n
\n
// CSharp indentation rules.\n
function indentCSharp(lexical) {\n
return function(firstChars) {\n
var firstChar = firstChars && firstChars.charAt(0), type = lexical.type;\n
var closing = firstChar == type;\n
if (type == "vardef")\n
return lexical.indented + 4;\n
else if (type == "form" && firstChar == "{")\n
return lexical.indented;\n
else if (type == "stat" || type == "form")\n
return lexical.indented + indentUnit;\n
else if (lexical.info == "switch" && !closing)\n
return lexical.indented + (/^(?:case|default)\\b/.test(firstChars) ? indentUnit : 2 * indentUnit);\n
else if (lexical.align)\n
return lexical.column - (closing ? 1 : 0);\n
else\n
return lexical.indented + (closing ? 0 : indentUnit);\n
};\n
}\n
\n
// The parser-iterator-producing function itself.\n
function parseCSharp(input, basecolumn) {\n
// Wrap the input in a token stream\n
var tokens = tokenizeCSharp(input);\n
// The parser state. cc is a stack of actions that have to be\n
// performed to finish the current statement. For example we might\n
// know that we still need to find a closing parenthesis and a\n
// semicolon. Actions at the end of the stack go first. It is\n
// initialized with an infinitely looping action that consumes\n
// whole statements.\n
var cc = [statements];\n
// The lexical scope, used mostly for indentation.\n
var lexical = new CSharpLexical((basecolumn || 0) - indentUnit, 0, "block", false);\n
// Current column, and the indentation at the start of the current\n
// line. Used to create lexical scope objects.\n
var column = 0;\n
var indented = 0;\n
// Variables which are used by the mark, cont, and pass functions\n
// below to communicate with the driver loop in the \'next\'\n
// function.\n
var consume, marked;\n
\n
// The iterator object.\n
var parser = {next: next, copy: copy};\n
\n
function next(){\n
// Start by performing any \'lexical\' actions (adjusting the\n
// lexical variable), or the operations below will be working\n
// with the wrong lexical state.\n
while(cc[cc.length - 1].lex)\n
cc.pop()();\n
\n
// Fetch a token.\n
var token = tokens.next();\n
\n
// Adjust column and indented.\n
if (token.type == "whitespace" && column == 0)\n
indented = token.value.length;\n
column += token.value.length;\n
if (token.content == "\\n"){\n
indented = column = 0;\n
// If the lexical scope\'s align property is still undefined at\n
// the end of the line, it is an un-aligned scope.\n
if (!("align" in lexical))\n
lexical.align = false;\n
// Newline tokens get an indentation function associated with\n
// them.\n
token.indentation = indentCSharp(lexical);\n
}\n
// No more processing for meaningless tokens.\n
if (token.type == "whitespace" || token.type == "comment")\n
return token;\n
// When a meaningful token is found and the lexical scope\'s\n
// align is undefined, it is an aligned scope.\n
if (!("align" in lexical))\n
lexical.align = true;\n
\n
// Execute actions until one \'consumes\' the token and we can\n
// return it.\n
while(true) {\n
consume = marked = false;\n
// Take and execute the topmost action.\n
cc.pop()(token.type, token.content);\n
if (consume){\n
// Marked is used to change the style of the current token.\n
if (marked)\n
token.style = marked;\n
return token;\n
}\n
}\n
}\n
\n
// This makes a copy of the parser state. It stores all the\n
// stateful variables in a closure, and returns a function that\n
// will restore them when called with a new input stream. Note\n
// that the cc array has to be copied, because it is contantly\n
// being modified. Lexical objects are not mutated, and context\n
// objects are not mutated in a harmful way, so they can be shared\n
// between runs of the parser.\n
function copy(){\n
var _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state;\n
\n
return function copyParser(input){\n
lexical = _lexical;\n
cc = _cc.concat([]); // copies the array\n
column = indented = 0;\n
tokens = tokenizeCSharp(input, _tokenState);\n
return parser;\n
};\n
}\n
\n
// Helper function for pushing a number of actions onto the cc\n
// stack in reverse order.\n
function push(fs){\n
for (var i = fs.length - 1; i >= 0; i--)\n
cc.push(fs[i]);\n
}\n
// cont and pass are used by the action functions to add other\n
// actions to the stack. cont will cause the current token to be\n
// consumed, pass will leave it for the next action.\n
function cont(){\n
push(arguments);\n
consume = true;\n
}\n
function pass(){\n
push(arguments);\n
consume = false;\n
}\n
// Used to change the style of the current token.\n
function mark(style){\n
marked = style;\n
}\n
\n
// Push a new lexical context of the given type.\n
function pushlex(type, info) {\n
var result = function(){\n
lexical = new CSharpLexical(indented, column, type, null, lexical, info)\n
};\n
result.lex = true;\n
return result;\n
}\n
// Pop off the current lexical context.\n
function poplex(){\n
lexical = lexical.prev;\n
}\n
poplex.lex = true;\n
// The \'lex\' flag on these actions is used by the \'next\' function\n
// to know they can (and have to) be ran before moving on to the\n
// next token.\n
\n
// Creates an action that discards tokens until it finds one of\n
// the given type.\n
function expect(wanted){\n
return function expecting(type){\n
if (type == wanted) cont();\n
else cont(arguments.callee);\n
};\n
}\n
\n
// Looks for a statement, and then calls itself.\n
function statements(type){\n
return pass(statement, statements);\n
}\n
// Dispatches various types of statements based on the type of the\n
// current token.\n
function statement(type){\n
if (type == "var") cont(pushlex("vardef"), vardef1, expect(";"), poplex);\n
else if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex);\n
else if (type == "keyword b") cont(pushlex("form"), statement, poplex);\n
else if (type == "{" && json) cont(pushlex("}"), commasep(objprop, "}"), poplex);\n
else if (type == "{") cont(pushlex("}"), block, poplex);\n
else if (type == "function") cont(functiondef);\n
else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex);\n
else if (type == "variable") cont(pushlex("stat"), maybelabel);\n
else if (type == "switch") cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), block, poplex, poplex);\n
else if (type == "case") cont(expression, expect(":"));\n
else if (type == "default") cont(expect(":"));\n
else if (type == "catch") cont(pushlex("form"), expect("("), funarg, expect(")"), statement, poplex);\n
\n
else if (type == "class") cont(classdef);\n
else if (type == "keyword d") cont(statement);\n
\n
else pass(pushlex("stat"), expression, expect(";"), poplex);\n
}\n
// Dispatch expression types.\n
function expression(type){\n
if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator);\n
else if (type == "function") cont(functiondef);\n
else if (type == "keyword c") cont(expression);\n
else if (type == "(") cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator);\n
else if (type == "operator") cont(expression);\n
else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);\n
else if (type == "{") cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);\n
}\n
// Called for places where operators, function calls, or\n
// subscripts are valid. Will skip on to the next action if none\n
// is found.\n
function maybeoperator(type){\n
if (type == "operator") cont(expression);\n
else if (type == "(") cont(pushlex(")"), expression, commasep(expression, ")"), poplex, maybeoperator);\n
else if (type == ".") cont(property, maybeoperator);\n
else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);\n
}\n
// When a statement starts with a variable name, it might be a\n
// label. If no colon follows, it\'s a regular statement.\n
function maybelabel(type){\n
if (type == ":") cont(poplex, statement);\n
else if (type == "(") cont(commasep(funarg, ")"), poplex, statement); // method definition\n
else if (type == "{") cont(poplex, pushlex("}"), block, poplex); // property definition\n
else pass(maybeoperator, expect(";"), poplex);\n
}\n
// Property names need to have their style adjusted -- the\n
// tokenizer thinks they are variables.\n
function property(type){\n
if (type == "variable") {mark("csharp-property"); cont();}\n
}\n
// This parses a property and its value in an object literal.\n
function objprop(type){\n
if (type == "variable") mark("csharp-property");\n
if (atomicTypes.hasOwnProperty(type)) cont(expect(":"), expression);\n
}\n
// Parses a comma-separated list of the things that are recognized\n
// by the \'what\' argument.\n
function commasep(what, end){\n
function proceed(type) {\n
if (type == ",") cont(what, proceed);\n
else if (type == end) cont();\n
else cont(expect(end));\n
};\n
return function commaSeparated(type) {\n
if (type == end) cont();\n
else pass(what, proceed);\n
};\n
}\n
// Look for statements until a closing brace is found.\n
function block(type){\n
if (type == "}") cont();\n
else pass(statement, block);\n
}\n
// Variable definitions are split into two actions -- 1 looks for\n
// a name or the end of the definition, 2 looks for an \'=\' sign or\n
// a comma.\n
function vardef1(type, value){\n
if (type == "variable"){cont(vardef2);}\n
else cont();\n
}\n
function vardef2(type, value){\n
if (value == "=") cont(expression, vardef2);\n
else if (type == ",") cont(vardef1);\n
}\n
// For loops.\n
function forspec1(type){\n
if (type == "var") cont(vardef1, forspec2);\n
else if (type == ";") pass(forspec2);\n
else if (type == "variable") cont(formaybein);\n
else pass(forspec2);\n
}\n
function formaybein(type, value){\n
if (value == "in") cont(expression);\n
else cont(maybeoperator, forspec2);\n
}\n
function forspec2(type, value){\n
if (type == ";") cont(forspec3);\n
else if (value == "in") cont(expression);\n
else cont(expression, expect(";"), forspec3);\n
}\n
function forspec3(type) {\n
if (type == ")") pass();\n
else cont(expression);\n
}\n
// A function definition creates a new context, and the variables\n
// in its argument list have to be added to this context.\n
function functiondef(type, value){\n
if (type == "variable") cont(functiondef);\n
else if (type == "(") cont(commasep(funarg, ")"), statement);\n
}\n
function funarg(type, value){\n
if (type == "variable"){cont();}\n
}\n
\n
function classdef(type) {\n
if (type == "variable") cont(classdef, statement);\n
else if (type == ":") cont(classdef, statement);\n
}\n
\n
return parser;\n
}\n
\n
return {\n
make: parseCSharp,\n
electricChars: "{}:",\n
configure: function(obj) {\n
if (obj.json != null) json = obj.json;\n
}\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>12902</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>tokenizecsharp.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Tokenizer for CSharp code */\n
\n
var tokenizeCSharp = (function() {\n
// Advance the stream until the given character (not preceded by a\n
// backslash) is encountered, or the end of the line is reached.\n
function nextUntilUnescaped(source, end) {\n
var escaped = false;\n
var next;\n
while (!source.endOfLine()) {\n
var next = source.next();\n
if (next == end && !escaped)\n
return false;\n
escaped = !escaped && next == "\\\\";\n
}\n
return escaped;\n
}\n
\n
// A map of JavaScript\'s keywords. The a/b/c keyword distinction is\n
// very rough, but it gives the parser enough information to parse\n
// correct code correctly (we don\'t care that much how we parse\n
// incorrect code). The style information included in these objects\n
// is used by the highlighter to pick the correct CSS style for a\n
// token.\n
var keywords = function(){\n
function result(type, style){\n
return {type: type, style: "csharp-" + style};\n
}\n
// keywords that take a parenthised expression, and then a\n
// statement (if)\n
var keywordA = result("keyword a", "keyword");\n
// keywords that take just a statement (else)\n
var keywordB = result("keyword b", "keyword");\n
// keywords that optionally take an expression, and form a\n
// statement (return)\n
var keywordC = result("keyword c", "keyword");\n
var operator = result("operator", "keyword");\n
var atom = result("atom", "atom");\n
// just a keyword with no indentation implications\n
var keywordD = result("keyword d", "keyword"); \n
\n
return {\n
"if": keywordA, "while": keywordA, "with": keywordA,\n
"else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB,\n
"return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "delete": keywordC, "throw": keywordC,\n
"in": operator, "typeof": operator, "instanceof": operator,\n
"var": result("var", "keyword"), "function": result("function", "keyword"), "catch": result("catch", "keyword"),\n
"for": result("for", "keyword"), "switch": result("switch", "keyword"),\n
"case": result("case", "keyword"), "default": result("default", "keyword"),\n
"true": atom, "false": atom, "null": atom,\n
\n
"class": result("class", "keyword"), "namespace": result("class", "keyword"),\n
\n
"public": keywordD, "private": keywordD, "protected": keywordD, "internal": keywordD,\n
"extern": keywordD, "override": keywordD, "virtual": keywordD, "abstract": keywordD, \n
"static": keywordD, "out": keywordD, "ref": keywordD, "const": keywordD,\n
\n
"foreach": result("for", "keyword"), "using": keywordC,\n
\n
"int": keywordD, "double": keywordD, "long": keywordD, "bool": keywordD, "char": keywordD, \n
"void": keywordD, "string": keywordD, "byte": keywordD, "sbyte": keywordD, "decimal": keywordD,\n
"float": keywordD, "uint": keywordD, "ulong": keywordD, "object": keywordD,\n
"short": keywordD, "ushort": keywordD,\n
\n
"get": keywordD, "set": keywordD, "value": keywordD \n
};\n
}();\n
\n
// Some helper regexps\n
var isOperatorChar = /[+\\-*&%=<>!?|]/;\n
var isHexDigit = /[0-9A-Fa-f]/;\n
var isWordChar = /[\\w\\$_]/;\n
\n
// Wrapper around jsToken that helps maintain parser state (whether\n
// we are inside of a multi-line comment and whether the next token\n
// could be a regular expression).\n
function jsTokenState(inside, regexp) {\n
return function(source, setState) {\n
var newInside = inside;\n
var type = jsToken(inside, regexp, source, function(c) {newInside = c;});\n
var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\\[{}\\(,;:]$/);\n
if (newRegexp != regexp || newInside != inside)\n
setState(jsTokenState(newInside, newRegexp));\n
return type;\n
};\n
}\n
\n
// The token reader, inteded to be used by the tokenizer from\n
// tokenize.js (through jsTokenState). Advances the source stream\n
// over a token, and returns an object containing the type and style\n
// of that token.\n
function jsToken(inside, regexp, source, setInside) {\n
function readHexNumber(){\n
source.next(); // skip the \'x\'\n
source.nextWhileMatches(isHexDigit);\n
return {type: "number", style: "csharp-atom"};\n
}\n
\n
function readNumber() {\n
source.nextWhileMatches(/[0-9]/);\n
if (source.equals(".")){\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
if (source.equals("e") || source.equals("E")){\n
source.next();\n
if (source.equals("-"))\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
return {type: "number", style: "csharp-atom"};\n
}\n
// Read a word, look it up in keywords. If not found, it is a\n
// variable, otherwise it is a keyword of the type found.\n
function readWord() {\n
source.nextWhileMatches(isWordChar);\n
var word = source.get();\n
var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];\n
return known ? {type: known.type, style: known.style, content: word} :\n
{type: "variable", style: "csharp-variable", content: word};\n
}\n
function readRegexp() {\n
nextUntilUnescaped(source, "/");\n
source.nextWhileMatches(/[gi]/);\n
return {type: "regexp", style: "csharp-string"};\n
}\n
// Mutli-line comments are tricky. We want to return the newlines\n
// embedded in them as regular newline tokens, and then continue\n
// returning a comment token for every line of the comment. So\n
// some state has to be saved (inside) to indicate whether we are\n
// inside a /* */ sequence.\n
function readMultilineComment(start){\n
var newInside = "/*";\n
var maybeEnd = (start == "*");\n
while (true) {\n
if (source.endOfLine())\n
break;\n
var next = source.next();\n
if (next == "/" && maybeEnd){\n
newInside = null;\n
break;\n
}\n
maybeEnd = (next == "*");\n
}\n
setInside(newInside);\n
return {type: "comment", style: "csharp-comment"};\n
}\n
function readOperator() {\n
source.nextWhileMatches(isOperatorChar);\n
return {type: "operator", style: "csharp-operator"};\n
}\n
function readString(quote) {\n
var endBackSlash = nextUntilUnescaped(source, quote);\n
setInside(endBackSlash ? quote : null);\n
return {type: "string", style: "csharp-string"};\n
}\n
\n
// Fetch the next token. Dispatches on first character in the\n
// stream, or first two characters when the first is a slash.\n
if (inside == "\\"" || inside == "\'")\n
return readString(inside);\n
var ch = source.next();\n
if (inside == "/*")\n
return readMultilineComment(ch);\n
else if (ch == "\\"" || ch == "\'")\n
return readString(ch);\n
// with punctuation, the type of the token is the symbol itself\n
else if (/[\\[\\]{}\\(\\),;\\:\\.]/.test(ch))\n
return {type: ch, style: "csharp-punctuation"};\n
else if (ch == "0" && (source.equals("x") || source.equals("X")))\n
return readHexNumber();\n
else if (/[0-9]/.test(ch))\n
return readNumber();\n
else if (ch == "/"){\n
if (source.equals("*"))\n
{ source.next(); return readMultilineComment(ch); }\n
else if (source.equals("/"))\n
{ nextUntilUnescaped(source, null); return {type: "comment", style: "csharp-comment"};}\n
else if (regexp)\n
return readRegexp();\n
else\n
return readOperator();\n
}\n
else if (ch == "#") { // treat c# regions like comments\n
nextUntilUnescaped(source, null); return {type: "comment", style: "csharp-comment"};\n
}\n
else if (isOperatorChar.test(ch))\n
return readOperator();\n
else\n
return readWord();\n
}\n
\n
// The external interface to the tokenizer.\n
return function(source, startState) {\n
return tokenizer(source, startState || jsTokenState(false, true));\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>7872</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>lua</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>luacolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
pre.code, .editbox {\n
color: #666666;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.lua-comment {\n
color: #BB9977;\n
}\n
\n
span.lua-keyword {\n
font-weight: bold;\n
color: blue;\n
}\n
\n
span.lua-string {\n
color: #AA2222;\n
}\n
\n
span.lua-stdfunc {\n
font-weight: bold;\n
color: #077;\n
}\n
span.lua-customfunc {\n
font-weight: bold;\n
color: #0AA;\n
}\n
\n
\n
span.lua-identifier {\n
color: black;\n
}\n
\n
span.lua-number {\n
color: #3A3;\n
}\n
\n
span.lua-token {\n
color: #151;\n
}\n
\n
span.lua-error {\n
color: #FFF;\n
background-color: #F00;\n
}\n
\n
\n
\n
\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>634</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parselua.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* \n
Simple parser for LUA \n
Written for Lua 5.1, based on parsecss and other parsers. \n
features: highlights keywords, strings, comments (no leveling supported! ("[==[")),tokens, basic indenting\n
\n
to make this parser highlight your special functions pass table with this functions names to parserConfig argument of creator,\n
\t\n
parserConfig: ["myfunction1","myfunction2"],\n
*/\n
\n
\n
function findFirstRegexp(words) {\n
return new RegExp("^(?:" + words.join("|") + ")", "i");\n
}\n
\n
function matchRegexp(words) {\n
return new RegExp("^(?:" + words.join("|") + ")$", "i");\n
}\n
\n
\n
\n
var luaCustomFunctions= matchRegexp([]);\n
\n
function configureLUA(parserConfig){\n
\tif(parserConfig)\n
\tluaCustomFunctions= matchRegexp(parserConfig);\n
}\n
\n
\n
//long list of standard functions from lua manual\n
var luaStdFunctions = matchRegexp([\n
"_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall",\n
\n
"coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield",\n
\n
"debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback",\n
\n
"close","flush","lines","read","seek","setvbuf","write",\n
\n
"io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write",\n
\n
"math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh",\n
\n
"os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname",\n
\n
"package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall",\n
\n
"string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper",\n
\n
"table.concat","table.insert","table.maxn","table.remove","table.sort"\n
]);\n
\n
\n
\n
var luaKeywords = matchRegexp(["and","break","elseif","false","nil","not","or","return",\n
\t\t\t\t"true","function", "end", "if", "then", "else", "do", \n
\t\t\t\t"while", "repeat", "until", "for", "in", "local" ]);\n
\n
var luaIndentKeys = matchRegexp(["function", "if","repeat","for","while", "[\\(]", "{"]);\n
var luaUnindentKeys = matchRegexp(["end", "until", "[\\)]", "}"]);\n
\n
var luaUnindentKeys2 = findFirstRegexp(["end", "until", "[\\)]", "}"]);\n
var luaMiddleKeys = findFirstRegexp(["else","elseif"]);\n
\n
\n
\n
var LUAParser = Editor.Parser = (function() {\n
var tokenizeLUA = (function() {\n
function normal(source, setState) {\n
var ch = source.next();\n
\n
if (ch == "-" && source.equals("-")) {\n
source.next();\n
\t\tsetState(inSLComment);\n
return null;\n
} \n
\telse if (ch == "\\"" || ch == "\'") {\n
setState(inString(ch));\n
return null;\n
}\n
if (ch == "[" && (source.equals("[") || source.equals("="))) {\n
var level = 0;\n
\t\twhile(source.equals("=")){\n
\t\t\tlevel ++;\n
\t\t\tsource.next();\n
\t\t}\n
\t\tif(! source.equals("[") )\n
\t\t\treturn "lua-error";\t\t\n
\t\tsetState(inMLSomething(level,"lua-string"));\n
return null;\n
} \n
\t \n
else if (ch == "=") {\n
\tif (source.equals("="))\n
\t\tsource.next();\n
return "lua-token";\n
}\n
\t\n
else if (ch == ".") {\n
\tif (source.equals("."))\n
\t\tsource.next();\n
\tif (source.equals("."))\n
\t\tsource.next();\n
return "lua-token";\n
}\n
\n
else if (ch == "+" || ch == "-" || ch == "*" || ch == "/" || ch == "%" || ch == "^" || ch == "#" ) {\n
return "lua-token";\n
}\n
else if (ch == ">" || ch == "<" || ch == "(" || ch == ")" || ch == "{" || ch == "}" || ch == "[" ) {\n
return "lua-token";\n
}\n
else if (ch == "]" || ch == ";" || ch == ":" || ch == ",") {\n
return "lua-token";\n
}\n
else if (source.equals("=") && (ch == "~" || ch == "<" || ch == ">")) {\n
source.next();\n
return "lua-token";\n
}\n
\n
else if (/\\d/.test(ch)) {\n
source.nextWhileMatches(/[\\w.%]/);\n
return "lua-number";\n
}\n
else {\n
source.nextWhileMatches(/[\\w\\\\\\-_.]/);\n
return "lua-identifier";\n
}\n
}\n
\n
function inSLComment(source, setState) {\n
var start = true;\n
\tvar count=0;\n
while (!source.endOfLine()) {\n
\t \tvar ch = source.next();\n
\t\tvar level = 0;\n
\t\tif ((ch =="[") && start){\n
\t\t\twhile(source.equals("=")){\n
\t\t\tsource.next();\n
\t\t\tlevel++;\n
\t\t\t}\n
\t\t\tif (source.equals("[")){\n
\t\t\t\tsetState(inMLSomething(level,"lua-comment"));\n
\t\t\treturn null;\n
\t\t\t\t}\n
\t\t }\n
\t\t start = false;\t\n
\t}\n
\tsetState(normal); \t\t\n
return "lua-comment";\n
\t\n
}\n
\n
function inMLSomething(level,what) {\n
\t//wat sholud be "lua-string" or "lua-comment", level is the number of "=" in opening mark.\n
\treturn function(source, setState){\n
var dashes = 0;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (dashes == level+1 && ch == "]" ) {\n
setState(normal);\n
break;\n
}\n
\t\tif (dashes == 0) \n
\t\t\tdashes = (ch == "]") ? 1:0;\n
\t\telse\n
\t\t\tdashes = (ch == "=") ? dashes + 1 : 0;\n
}\n
return what;\n
\t }\n
}\n
\n
\n
function inString(quote) {\n
return function(source, setState) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (ch == quote && !escaped)\n
break;\n
escaped = !escaped && ch == "\\\\";\n
}\n
if (!escaped)\n
setState(normal);\n
return "lua-string";\n
};\n
}\n
\n
return function(source, startState) {\n
return tokenizer(source, startState || normal);\n
};\n
})();\n
\n
function indentLUA(indentDepth, base) {\n
return function(nextChars) {\n
\n
var closing = (luaUnindentKeys2.test(nextChars) || luaMiddleKeys.test(nextChars));\n
\n
\t\n
\treturn base + ( indentUnit * (indentDepth - (closing?1:0)) );\n
};\n
}\n
\n
\n
function parseLUA(source,basecolumn) {\n
basecolumn = basecolumn || 0;\n
\n
\tvar tokens = tokenizeLUA(source);\n
var indentDepth = 0;\n
\n
var iter = {\n
next: function() {\n
var token = tokens.next(), style = token.style, content = token.content;\n
\n
\n
\t\n
\tif (style == "lua-identifier" && luaKeywords.test(content)){\n
\t token.style = "lua-keyword";\n
\t}\t\n
\tif (style == "lua-identifier" && luaStdFunctions.test(content)){\n
\t token.style = "lua-stdfunc";\n
\t}\n
\tif (style == "lua-identifier" && luaCustomFunctions.test(content)){\n
\t token.style = "lua-customfunc";\n
\t}\n
\n
\tif (luaIndentKeys.test(content))\n
\tindentDepth++;\n
\telse if (luaUnindentKeys.test(content))\n
\t\tindentDepth--;\n
\n
\n
if (content == "\\n")\n
token.indentation = indentLUA( indentDepth, basecolumn);\n
\n
return token;\n
},\n
\n
copy: function() {\n
var _tokenState = tokens.state, _indentDepth = indentDepth;\n
return function(source) {\n
tokens = tokenizeLUA(source, _tokenState);\n
\n
\t indentDepth = _indentDepth;\n
return iter;\n
};\n
}\n
};\n
return iter;\n
}\n
\n
return {make: parseLUA, configure:configureLUA, electricChars: "delf})"}; //en[d] els[e] unti[l] elsei[f] // this should be taken from Keys keywords\n
})();\n
\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>7721</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ometa</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>ometacolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
pre.code, .editbox {\n
color: #666666;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.js-punctuation {\n
color: #666666;\n
}\n
\n
span.js-operator {\n
color: #E1570F;\n
}\n
\n
span.js-keyword {\n
color: #770088;\n
}\n
\n
span.js-atom {\n
color: #228811;\n
}\n
\n
span.js-variable {\n
color: black;\n
}\n
\n
span.js-variabledef {\n
color: #0000FF;\n
}\n
\n
span.js-localvariable {\n
color: #004499;\n
}\n
\n
span.js-property {\n
color: black;\n
}\n
\n
span.js-comment {\n
color: #AA7700;\n
}\n
\n
span.js-string {\n
color: #AA2222;\n
}\n
\n
span.ometa-binding {\n
color: #FF0000;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>642</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parseometa.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Parse function for JavaScript. Makes use of the tokenizer from\n
* tokenizejavascript.js. Note that your parsers do not have to be\n
* this complicated -- if you don\'t want to recognize local variables,\n
* in many languages it is enough to just look for braces, semicolons,\n
* parentheses, etc, and know when you are inside a string or comment.\n
*\n
* See manual.html for more info about the parser interface.\n
*/\n
\n
var JSParser = Editor.Parser = (function() {\n
// Token types that can be considered to be atoms.\n
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};\n
// Setting that can be used to have JSON data indent properly.\n
var json = false;\n
// Constructor for the lexical context objects.\n
function JSLexical(indented, column, type, align, prev, info) {\n
// indentation at start of this line\n
this.indented = indented;\n
// column at which this scope was opened\n
this.column = column;\n
// type of scope (\'vardef\', \'stat\' (statement), \'form\' (special form), \'[\', \'{\', or \'(\')\n
this.type = type;\n
// \'[\', \'{\', or \'(\' blocks that have any text after their opening\n
// character are said to be \'aligned\' -- any lines below are\n
// indented all the way to the opening character.\n
if (align != null)\n
this.align = align;\n
// Parent scope, if any.\n
this.prev = prev;\n
this.info = info;\n
}\n
\n
// My favourite JavaScript indentation rules.\n
function indentJS(lexical) {\n
return function(firstChars) {\n
var firstChar = firstChars && firstChars.charAt(0), type = lexical.type;\n
var closing = firstChar == type;\n
if (type == "vardef")\n
return lexical.indented + 4;\n
else if (type == "form" && firstChar == "{")\n
return lexical.indented;\n
else if (type == "stat" || type == "form")\n
return lexical.indented + indentUnit;\n
else if (lexical.info == "switch" && !closing)\n
return lexical.indented + (/^(?:case|default)\\b/.test(firstChars) ? indentUnit : 2 * indentUnit);\n
else if (lexical.align)\n
return lexical.column - (closing ? 1 : 0);\n
else\n
return lexical.indented + (closing ? 0 : indentUnit);\n
};\n
}\n
\n
// The parser-iterator-producing function itself.\n
function parseJS(input, basecolumn) {\n
// Wrap the input in a token stream\n
var tokens = tokenizeJavaScript(input);\n
// The parser state. cc is a stack of actions that have to be\n
// performed to finish the current statement. For example we might\n
// know that we still need to find a closing parenthesis and a\n
// semicolon. Actions at the end of the stack go first. It is\n
// initialized with an infinitely looping action that consumes\n
// whole statements.\n
var cc = [json ? expressions : statements];\n
// Context contains information about the current local scope, the\n
// variables defined in that, and the scopes above it.\n
var context = null;\n
// The lexical scope, used mostly for indentation.\n
var lexical = new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false);\n
// Current column, and the indentation at the start of the current\n
// line. Used to create lexical scope objects.\n
var column = 0;\n
var indented = 0;\n
// Variables which are used by the mark, cont, and pass functions\n
// below to communicate with the driver loop in the \'next\'\n
// function.\n
var consume, marked;\n
\n
// The iterator object.\n
var parser = {next: next, copy: copy};\n
\n
function next(){\n
// Start by performing any \'lexical\' actions (adjusting the\n
// lexical variable), or the operations below will be working\n
// with the wrong lexical state.\n
while(cc[cc.length - 1].lex)\n
cc.pop()();\n
\n
// Fetch a token.\n
var token = tokens.next();\n
\n
// Adjust column and indented.\n
if (token.type == "whitespace" && column == 0)\n
indented = token.value.length;\n
column += token.value.length;\n
if (token.content == "\\n"){\n
indented = column = 0;\n
// If the lexical scope\'s align property is still undefined at\n
// the end of the line, it is an un-aligned scope.\n
if (!("align" in lexical))\n
lexical.align = false;\n
// Newline tokens get an indentation function associated with\n
// them.\n
token.indentation = indentJS(lexical);\n
// special handling for multiline strings: keep everything in the first\n
// column, as spaces at the start of a multiline string are significant\n
if (lexical.info == "multilineString") {\n
lexical.align = false;\n
token.indentation = function () { return 0; };\n
}\n
}\n
// No more processing for meaningless tokens.\n
if (token.type == "whitespace" || token.type == "comment")\n
return token;\n
// Take note when a multiline string is found, so as to\n
// correctly handle indentation at the end of the line\n
// (see above, line 95)\n
if (token.type == "multilineString")\n
lexical.info = \'multilineString\';\n
// When a meaningful token is found and the lexical scope\'s\n
// align is undefined, it is an aligned scope.\n
if (!("align" in lexical))\n
lexical.align = true;\n
\n
// Execute actions until one \'consumes\' the token and we can\n
// return it.\n
while(true) {\n
consume = marked = false;\n
// Take and execute the topmost action.\n
cc.pop()(token.type, token.content);\n
if (consume){\n
// Marked is used to change the style of the current token.\n
if (marked)\n
token.style = marked;\n
// Here we differentiate between local and global variables.\n
else if (token.type == "variable" && inScope(token.content))\n
token.style = "js-localvariable";\n
return token;\n
}\n
}\n
}\n
\n
// This makes a copy of the parser state. It stores all the\n
// stateful variables in a closure, and returns a function that\n
// will restore them when called with a new input stream. Note\n
// that the cc array has to be copied, because it is contantly\n
// being modified. Lexical objects are not mutated, and context\n
// objects are not mutated in a harmful way, so they can be shared\n
// between runs of the parser.\n
function copy(){\n
var _context = context, _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state;\n
\n
return function copyParser(input){\n
context = _context;\n
lexical = _lexical;\n
cc = _cc.concat([]); // copies the array\n
column = indented = 0;\n
tokens = tokenizeJavaScript(input, _tokenState);\n
return parser;\n
};\n
}\n
\n
// Helper function for pushing a number of actions onto the cc\n
// stack in reverse order.\n
function push(fs){\n
for (var i = fs.length - 1; i >= 0; i--)\n
cc.push(fs[i]);\n
}\n
// cont and pass are used by the action functions to add other\n
// actions to the stack. cont will cause the current token to be\n
// consumed, pass will leave it for the next action.\n
function cont(){\n
push(arguments);\n
consume = true;\n
}\n
function pass(){\n
push(arguments);\n
consume = false;\n
}\n
// Used to change the style of the current token.\n
function mark(style){\n
marked = style;\n
}\n
\n
// Push a new scope. Will automatically link the current scope.\n
function pushcontext(){\n
context = {prev: context, vars: {"this": true, "arguments": true}};\n
}\n
// Pop off the current scope.\n
function popcontext(){\n
context = context.prev;\n
}\n
// Register a variable in the current scope.\n
function register(varname){\n
if (context){\n
mark("js-variabledef");\n
context.vars[varname] = true;\n
}\n
}\n
// Check whether a variable is defined in the current scope.\n
function inScope(varname){\n
var cursor = context;\n
while (cursor) {\n
if (cursor.vars[varname])\n
return true;\n
cursor = cursor.prev;\n
}\n
return false;\n
}\n
\n
// Push a new lexical context of the given type.\n
function pushlex(type, info) {\n
var result = function(){\n
lexical = new JSLexical(indented, column, type, null, lexical, info)\n
};\n
result.lex = true;\n
return result;\n
}\n
// Pop off the current lexical context.\n
function poplex(){\n
lexical = lexical.prev;\n
}\n
poplex.lex = true;\n
// The \'lex\' flag on these actions is used by the \'next\' function\n
// to know they can (and have to) be ran before moving on to the\n
// next token.\n
\n
// Creates an action that discards tokens until it finds one of\n
// the given type.\n
function expect(wanted){\n
return function expecting(type){\n
if (type == wanted) cont();\n
else cont(arguments.callee);\n
};\n
}\n
\n
// Looks for a statement, and then calls itself.\n
function statements(type){\n
return pass(statement, statements);\n
}\n
function expressions(type){\n
return pass(expression, expressions);\n
}\n
// Dispatches various types of statements based on the type of the\n
// current token.\n
function statement(type){\n
if (type == "var") cont(pushlex("vardef"), vardef1, expect(";"), poplex);\n
else if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex);\n
else if (type == "keyword b") cont(pushlex("form"), statement, poplex);\n
else if (type == "{") cont(pushlex("}"), block, poplex);\n
else if (type == "function") cont(functiondef);\n
else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex);\n
else if (type == "variable") cont(pushlex("stat"), maybelabel);\n
else if (type == "switch") cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), block, poplex, poplex);\n
else if (type == "case") cont(expression, expect(":"));\n
else if (type == "default") cont(expect(":"));\n
else if (type == "catch") cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), statement, poplex, popcontext);\n
else pass(pushlex("stat"), expression, expect(";"), poplex);\n
}\n
// Dispatch expression types.\n
function expression(type){\n
if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator);\n
else if (type == "function") cont(functiondef);\n
else if (type == "keyword c") cont(expression);\n
else if (type == "(") cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator);\n
else if (type == "operator") cont(expression);\n
else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);\n
else if (type == "{") cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);\n
else cont();\n
}\n
// Called for places where operators, function calls, or\n
// subscripts are valid. Will skip on to the next action if none\n
// is found.\n
function maybeoperator(type){\n
if (type == "operator") cont(expression);\n
else if (type == "(") cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);\n
else if (type == ".") cont(property, maybeoperator);\n
else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);\n
}\n
// When a statement starts with a variable name, it might be a\n
// label. If no colon follows, it\'s a regular statement.\n
function maybelabel(type){\n
if (type == ":") cont(poplex, statement);\n
else pass(maybeoperator, expect(";"), poplex);\n
}\n
// Property names need to have their style adjusted -- the\n
// tokenizer thinks they are variables.\n
function property(type){\n
if (type == "variable") {mark("js-property"); cont();}\n
}\n
// This parses a property and its value in an object literal.\n
function objprop(type){\n
if (type == "variable") mark("js-property");\n
if (atomicTypes.hasOwnProperty(type)) cont(expect(":"), expression);\n
}\n
// Parses a comma-separated list of the things that are recognized\n
// by the \'what\' argument.\n
function commasep(what, end){\n
function proceed(type) {\n
if (type == ",") cont(what, proceed);\n
else if (type == end) cont();\n
else cont(expect(end));\n
}\n
return function commaSeparated(type) {\n
if (type == end) cont();\n
else pass(what, proceed);\n
};\n
}\n
// Look for statements until a closing brace is found.\n
function block(type){\n
if (type == "}") cont();\n
else pass(statement, block);\n
}\n
// Variable definitions are split into two actions -- 1 looks for\n
// a name or the end of the definition, 2 looks for an \'=\' sign or\n
// a comma.\n
function vardef1(type, value){\n
if (type == "variable"){register(value); cont(vardef2);}\n
else cont();\n
}\n
function vardef2(type, value){\n
if (value == "=") cont(expression, vardef2);\n
else if (type == ",") cont(vardef1);\n
}\n
// For loops.\n
function forspec1(type){\n
if (type == "var") cont(vardef1, forspec2);\n
else if (type == ";") pass(forspec2);\n
else if (type == "variable") cont(formaybein);\n
else pass(forspec2);\n
}\n
function formaybein(type, value){\n
if (value == "in") cont(expression);\n
else cont(maybeoperator, forspec2);\n
}\n
function forspec2(type, value){\n
if (type == ";") cont(forspec3);\n
else if (value == "in") cont(expression);\n
else cont(expression, expect(";"), forspec3);\n
}\n
function forspec3(type) {\n
if (type == ")") pass();\n
else cont(expression);\n
}\n
// A function definition creates a new context, and the variables\n
// in its argument list have to be added to this context.\n
function functiondef(type, value){\n
if (type == "variable"){register(value); cont(functiondef);}\n
else if (type == "(") cont(pushcontext, commasep(funarg, ")"), statement, popcontext);\n
}\n
function funarg(type, value){\n
if (type == "variable"){register(value); cont();}\n
}\n
\n
return parser;\n
}\n
\n
return {\n
make: parseJS,\n
electricChars: "{}:",\n
configure: function(obj) {\n
if (obj.json != null) json = obj.json;\n
}\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>14221</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>tokenizeometa.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Tokenizer for JavaScript code */\n
\n
var tokenizeJavaScript = (function() {\n
// Advance the stream until the given character (not preceded by a\n
// backslash) is encountered, or the end of the line is reached.\n
function nextUntilUnescaped(source, end) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var next = source.next();\n
if (next == end && !escaped)\n
return false;\n
escaped = !escaped && next == "\\\\";\n
}\n
return escaped;\n
}\n
\n
// A map of JavaScript\'s keywords. The a/b/c keyword distinction is\n
// very rough, but it gives the parser enough information to parse\n
// correct code correctly (we don\'t care that much how we parse\n
// incorrect code). The style information included in these objects\n
// is used by the highlighter to pick the correct CSS style for a\n
// token.\n
var keywords = function(){\n
function result(type, style){\n
return {type: type, style: "js-" + style};\n
}\n
// keywords that take a parenthised expression, and then a\n
// statement (if)\n
var keywordA = result("keyword a", "keyword");\n
// keywords that take just a statement (else)\n
var keywordB = result("keyword b", "keyword");\n
// keywords that optionally take an expression, and form a\n
// statement (return)\n
var keywordC = result("keyword c", "keyword");\n
var operator = result("operator", "keyword");\n
var atom = result("atom", "atom");\n
return {\n
"if": keywordA, "while": keywordA, "with": keywordA,\n
"else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB,\n
"return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "delete": keywordC, "throw": keywordC,\n
"in": operator, "typeof": operator, "instanceof": operator,\n
"var": result("var", "keyword"), "function": result("function", "keyword"), "catch": result("catch", "keyword"),\n
"for": result("for", "keyword"), "switch": result("switch", "keyword"),\n
"case": result("case", "keyword"), "default": result("default", "keyword"),\n
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,\n
"ometa": keywordB\n
};\n
}();\n
\n
// Some helper regexps\n
var isOperatorChar = /[+\\-*&%=<>!?|~]/;\n
var isHexDigit = /[0-9A-Fa-f]/;\n
var isWordChar = /[\\w\\$_]/;\n
\n
// Wrapper around jsToken that helps maintain parser state (whether\n
// we are inside of a multi-line comment and whether the next token\n
// could be a regular expression).\n
function jsTokenState(inside, regexp) {\n
return function(source, setState) {\n
var newInside = inside;\n
var type = jsToken(inside, regexp, source, function(c) {newInside = c;});\n
var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\\[{}\\(,;:]$/);\n
if (newRegexp != regexp || newInside != inside)\n
setState(jsTokenState(newInside, newRegexp));\n
return type;\n
};\n
}\n
\n
// The token reader, intended to be used by the tokenizer from\n
// tokenize.js (through jsTokenState). Advances the source stream\n
// over a token, and returns an object containing the type and style\n
// of that token.\n
function jsToken(inside, regexp, source, setInside) {\n
function readHexNumber(){\n
source.next(); // skip the \'x\'\n
source.nextWhileMatches(isHexDigit);\n
return {type: "number", style: "js-atom"};\n
}\n
\n
function readNumber() {\n
source.nextWhileMatches(/[0-9]/);\n
if (source.equals(".")){\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
if (source.equals("e") || source.equals("E")){\n
source.next();\n
if (source.equals("-"))\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
return {type: "number", style: "js-atom"};\n
}\n
// Read a word, look it up in keywords. If not found, it is a\n
// variable, otherwise it is a keyword of the type found.\n
function readWord() {\n
source.nextWhileMatches(isWordChar);\n
var word = source.get();\n
var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];\n
return known ? {type: known.type, style: known.style, content: word} :\n
{type: "variable", style: "js-variable", content: word};\n
}\n
function readRegexp() {\n
nextUntilUnescaped(source, "/");\n
source.nextWhileMatches(/[gi]/);\n
return {type: "regexp", style: "js-string"};\n
}\n
// Mutli-line comments are tricky. We want to return the newlines\n
// embedded in them as regular newline tokens, and then continue\n
// returning a comment token for every line of the comment. So\n
// some state has to be saved (inside) to indicate whether we are\n
// inside a /* */ sequence.\n
function readMultilineComment(start){\n
var newInside = "/*";\n
var maybeEnd = (start == "*");\n
while (true) {\n
if (source.endOfLine())\n
break;\n
var next = source.next();\n
if (next == "/" && maybeEnd){\n
newInside = null;\n
break;\n
}\n
maybeEnd = (next == "*");\n
}\n
setInside(newInside);\n
return {type: "comment", style: "js-comment"};\n
}\n
function readMultilineString(start, quotes) {\n
var newInside = quotes;\n
var quote = quotes.charAt(0);\n
var maybeEnd = (start == quote);\n
while (true) {\n
if (source.endOfLine())\n
break;\n
var next = source.next();\n
if (next == quote && source.peek() == quote && maybeEnd) {\n
source.next();\n
newInside = null;\n
break;\n
}\n
maybeEnd = (next == quote);\n
}\n
setInside(newInside);\n
return {type: "multilineString", style: "js-string"};\n
}\n
function readOperator() {\n
source.nextWhileMatches(isOperatorChar);\n
return {type: "operator", style: "js-operator"};\n
}\n
function readString(quote) {\n
var endBackSlash = nextUntilUnescaped(source, quote);\n
setInside(endBackSlash ? quote : null);\n
return {type: "string", style: "js-string"};\n
}\n
function readOmetaIdentifierString() {\n
source.nextWhileMatches(isWordChar);\n
return {type: "string", style: "js-string"};\n
}\n
function readOmetaBinding() {\n
source.nextWhileMatches(isWordChar);\n
return {type: "variable", style: "ometa-binding"};\n
}\n
\n
// Fetch the next token. Dispatches on first character in the\n
// stream, or first two characters when the first is a slash.\n
if (inside == "\\"" || inside == "\'")\n
return readString(inside);\n
var ch = source.next();\n
if (inside == "/*")\n
return readMultilineComment(ch);\n
if (inside == \'"""\' || inside == "\'\'\'")\n
return readMultilineString(ch, inside);\n
if (ch == \'"\' && source.lookAhead(\'""\', true) || ch == "\'" && source.lookAhead("\'\'", true))\n
return readMultilineString(\'-\', ch+ch+ch); // work as far as \'-\' is not \'"\' nor "\'"\n
else if (ch == "\\"" || ch == "\'")\n
return readString(ch);\n
else if (ch == "`" || ch == "#" )\n
return readOmetaIdentifierString();\n
else if (ch == \':\' && isWordChar.test(source.peek())) \n
return readOmetaBinding();\n
// with punctuation, the type of the token is the symbol itself\n
else if (/[\\[\\]{}\\(\\),;\\:\\.]/.test(ch))\n
return {type: ch, style: "js-punctuation"};\n
else if (ch == "0" && (source.equals("x") || source.equals("X")))\n
return readHexNumber();\n
else if (/[0-9]/.test(ch))\n
return readNumber();\n
else if (ch == "/"){\n
if (source.equals("*"))\n
{ source.next(); return readMultilineComment(ch); }\n
else if (source.equals("/"))\n
{ nextUntilUnescaped(source, null); return {type: "comment", style: "js-comment"};}\n
else if (regexp)\n
return readRegexp();\n
else\n
return readOperator();\n
}\n
else if (isOperatorChar.test(ch))\n
return readOperator();\n
else\n
return readWord();\n
}\n
\n
// The external interface to the tokenizer.\n
return function(source, startState) {\n
return tokenizer(source, startState || jsTokenState(false, true));\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>8070</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>php</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>phpcolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.\n
The copyrights embodied in the content of this file are licensed by\n
Yahoo! Inc. under the BSD (revised) open source license\n
\n
@author Dan Vlad Dascalescu <dandv@yahoo-inc.com>\n
*/\n
\n
html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
}\n
\n
/*We should define specific styles for every element of the syntax.\n
the setting below will cause some annoying color to show through if we missed\n
defining a style for a token. This is also the "color" of the whitespace and\n
of the cursor.\n
*/\n
pre.code, .editbox {\n
color: red;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.php-punctuation {\n
color: blue;\n
}\n
\n
span.php-keyword {\n
color: #770088;\n
font-weight: bold;\n
}\n
\n
span.php-operator {\n
color: blue;\n
}\n
\n
/* __FILE__ etc.; http://php.net/manual/en/reserved.php */\n
span.php-compile-time-constant {\n
color: #776088;\n
font-weight: bold;\n
}\n
\n
/* output of get_defined_constants(). Differs from http://php.net/manual/en/reserved.constants.php */\n
span.php-predefined-constant {\n
color: darkgreen;\n
font-weight: bold;\n
}\n
\n
/* PHP reserved "language constructs"... echo() etc.; http://php.net/manual/en/reserved.php */\n
span.php-reserved-language-construct {\n
color: green;\n
font-weight: bold;\n
}\n
\n
/* PHP built-in functions: glob(), chr() etc.; output of get_defined_functions()["internal"] */\n
span.php-predefined-function {\n
color: green;\n
}\n
\n
/* PHP predefined classes: PDO, Exception etc.; output of get_declared_classes() and different from http://php.net/manual/en/reserved.classes.php */\n
span.php-predefined-class {\n
color: green;\n
}\n
\n
span.php-atom {\n
color: #228811;\n
}\n
\n
/* class, interface, namespace or function names, but not $variables */\n
span.php-t_string {\n
color: black;\n
}\n
\n
span.php-variable {\n
color: black;\n
font-weight: bold;\n
}\n
\n
\n
span.js-localvariable {\n
color: #004499;\n
}\n
\n
span.php-comment {\n
color: #AA7700;\n
font-stretch: condensed;\n
/* font-style: italic; This causes line height to slightly change, getting line numbers out of sync */\n
}\n
\n
span.php-string-single-quoted {\n
color: #AA2222;\n
}\n
/* double quoted strings allow interpolation */\n
span.php-string-double-quoted {\n
color: #AA2222;\n
font-weight: bold;\n
}\n
\n
span.syntax-error {\n
background-color: red;\n
}\n
\n
span.deprecated {\n
font-size: smaller;\n
}\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2325</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsephp.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.\n
The copyrights embodied in the content of this file are licensed by\n
Yahoo! Inc. under the BSD (revised) open source license\n
\n
@author Dan Vlad Dascalescu <dandv@yahoo-inc.com>\n
\n
\n
Parse function for PHP. Makes use of the tokenizer from tokenizephp.js.\n
Based on parsejavascript.js by Marijn Haverbeke.\n
\n
\n
Features:\n
+ special "deprecated" style for PHP4 keywords like \'var\'\n
+ support for PHP 5.3 keywords: \'namespace\', \'use\'\n
+ 911 predefined constants, 1301 predefined functions, 105 predeclared classes\n
from a typical PHP installation in a LAMP environment\n
+ new feature: syntax error flagging, thus enabling strict parsing of:\n
+ function definitions with explicitly or implicitly typed arguments and default values\n
+ modifiers (public, static etc.) applied to method and member definitions\n
+ foreach(array_expression as $key [=> $value]) loops\n
+ differentiation between single-quoted strings and double-quoted interpolating strings\n
\n
*/\n
\n
\n
// add the Array.indexOf method for JS engines that don\'t support it (e.g. IE)\n
// code from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Array/IndexOf\n
if (!Array.prototype.indexOf)\n
{\n
Array.prototype.indexOf = function(elt /*, from*/)\n
{\n
var len = this.length;\n
\n
var from = Number(arguments[1]) || 0;\n
from = (from < 0)\n
? Math.ceil(from)\n
: Math.floor(from);\n
if (from < 0)\n
from += len;\n
\n
for (; from < len; from++)\n
{\n
if (from in this &&\n
this[from] === elt)\n
return from;\n
}\n
return -1;\n
};\n
}\n
\n
\n
var PHPParser = Editor.Parser = (function() {\n
// Token types that can be considered to be atoms, part of operator expressions\n
var atomicTypes = {\n
"atom": true, "number": true, "variable": true, "string": true\n
};\n
// Constructor for the lexical context objects.\n
function PHPLexical(indented, column, type, align, prev, info) {\n
// indentation at start of this line\n
this.indented = indented;\n
// column at which this scope was opened\n
this.column = column;\n
// type of scope (\'stat\' (statement), \'form\' (special form), \'[\', \'{\', or \'(\')\n
this.type = type;\n
// \'[\', \'{\', or \'(\' blocks that have any text after their opening\n
// character are said to be \'aligned\' -- any lines below are\n
// indented all the way to the opening character.\n
if (align != null)\n
this.align = align;\n
// Parent scope, if any.\n
this.prev = prev;\n
this.info = info;\n
}\n
\n
// PHP indentation rules\n
function indentPHP(lexical) {\n
return function(firstChars) {\n
var firstChar = firstChars && firstChars.charAt(0), type = lexical.type;\n
var closing = firstChar == type;\n
if (type == "form" && firstChar == "{")\n
return lexical.indented;\n
else if (type == "stat" || type == "form")\n
return lexical.indented + indentUnit;\n
else if (lexical.info == "switch" && !closing)\n
return lexical.indented + (/^(?:case|default)\\b/.test(firstChars) ? indentUnit : 2 * indentUnit);\n
else if (lexical.align)\n
return lexical.column - (closing ? 1 : 0);\n
else\n
return lexical.indented + (closing ? 0 : indentUnit);\n
};\n
}\n
\n
// The parser-iterator-producing function itself.\n
function parsePHP(input, basecolumn) {\n
// Wrap the input in a token stream\n
var tokens = tokenizePHP(input);\n
// The parser state. cc is a stack of actions that have to be\n
// performed to finish the current statement. For example we might\n
// know that we still need to find a closing parenthesis and a\n
// semicolon. Actions at the end of the stack go first. It is\n
// initialized with an infinitely looping action that consumes\n
// whole statements.\n
var cc = [statements];\n
// The lexical scope, used mostly for indentation.\n
var lexical = new PHPLexical((basecolumn || 0) - indentUnit, 0, "block", false);\n
// Current column, and the indentation at the start of the current\n
// line. Used to create lexical scope objects.\n
var column = 0;\n
var indented = 0;\n
// Variables which are used by the mark, cont, and pass functions\n
// below to communicate with the driver loop in the \'next\' function.\n
var consume, marked;\n
\n
// The iterator object.\n
var parser = {next: next, copy: copy};\n
\n
// parsing is accomplished by calling next() repeatedly\n
function next(){\n
// Start by performing any \'lexical\' actions (adjusting the\n
// lexical variable), or the operations below will be working\n
// with the wrong lexical state.\n
while(cc[cc.length - 1].lex)\n
cc.pop()();\n
\n
// Fetch the next token.\n
var token = tokens.next();\n
\n
// Adjust column and indented.\n
if (token.type == "whitespace" && column == 0)\n
indented = token.value.length;\n
column += token.value.length;\n
if (token.content == "\\n"){\n
indented = column = 0;\n
// If the lexical scope\'s align property is still undefined at\n
// the end of the line, it is an un-aligned scope.\n
if (!("align" in lexical))\n
lexical.align = false;\n
// Newline tokens get an indentation function associated with\n
// them.\n
token.indentation = indentPHP(lexical);\n
}\n
// No more processing for meaningless tokens.\n
if (token.type == "whitespace" || token.type == "comment"\n
|| token.type == "string_not_terminated" )\n
return token;\n
// When a meaningful token is found and the lexical scope\'s\n
// align is undefined, it is an aligned scope.\n
if (!("align" in lexical))\n
lexical.align = true;\n
\n
// Execute actions until one \'consumes\' the token and we can\n
// return it. \'marked\' is used to change the style of the current token.\n
while(true) {\n
consume = marked = false;\n
// Take and execute the topmost action.\n
var action = cc.pop();\n
action(token);\n
\n
if (consume){\n
if (marked)\n
token.style = marked;\n
// Here we differentiate between local and global variables.\n
return token;\n
}\n
}\n
return 1; // Firebug workaround for http://code.google.com/p/fbug/issues/detail?id=1239#c1\n
}\n
\n
// This makes a copy of the parser state. It stores all the\n
// stateful variables in a closure, and returns a function that\n
// will restore them when called with a new input stream. Note\n
// that the cc array has to be copied, because it is contantly\n
// being modified. Lexical objects are not mutated, so they can\n
// be shared between runs of the parser.\n
function copy(){\n
var _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state;\n
\n
return function copyParser(input){\n
lexical = _lexical;\n
cc = _cc.concat([]); // copies the array\n
column = indented = 0;\n
tokens = tokenizePHP(input, _tokenState);\n
return parser;\n
};\n
}\n
\n
// Helper function for pushing a number of actions onto the cc\n
// stack in reverse order.\n
function push(fs){\n
for (var i = fs.length - 1; i >= 0; i--)\n
cc.push(fs[i]);\n
}\n
// cont and pass are used by the action functions to add other\n
// actions to the stack. cont will cause the current token to be\n
// consumed, pass will leave it for the next action.\n
function cont(){\n
push(arguments);\n
consume = true;\n
}\n
function pass(){\n
push(arguments);\n
consume = false;\n
}\n
// Used to change the style of the current token.\n
function mark(style){\n
marked = style;\n
}\n
// Add a lyer of style to the current token, for example syntax-error\n
function mark_add(style){\n
marked = marked + \' \' + style;\n
}\n
\n
// Push a new lexical context of the given type.\n
function pushlex(type, info) {\n
var result = function pushlexing() {\n
lexical = new PHPLexical(indented, column, type, null, lexical, info)\n
};\n
result.lex = true;\n
return result;\n
}\n
// Pop off the current lexical context.\n
function poplex(){\n
lexical = lexical.prev;\n
}\n
poplex.lex = true;\n
// The \'lex\' flag on these actions is used by the \'next\' function\n
// to know they can (and have to) be ran before moving on to the\n
// next token.\n
\n
// Creates an action that discards tokens until it finds one of\n
// the given type. This will ignore (and recover from) syntax errors.\n
function expect(wanted){\n
return function expecting(token){\n
if (token.type == wanted) cont(); // consume the token\n
else {\n
cont(arguments.callee); // continue expecting() - call itself\n
}\n
};\n
}\n
\n
// Require a specific token type, or one of the tokens passed in the \'wanted\' array\n
// Used to detect blatant syntax errors. \'execute\' is used to pass extra code\n
// to be executed if the token is matched. For example, a \'(\' match could\n
// \'execute\' a cont( compasep(funcarg), require(")") )\n
function require(wanted, execute){\n
return function requiring(token){\n
var ok;\n
var type = token.type;\n
if (typeof(wanted) == "string")\n
ok = (type == wanted) -1;\n
else\n
ok = wanted.indexOf(type);\n
if (ok >= 0) {\n
if (execute && typeof(execute[ok]) == "function")\n
execute[ok](token);\n
cont(); // just consume the token\n
}\n
else {\n
if (!marked) mark(token.style);\n
mark_add("syntax-error");\n
cont(arguments.callee);\n
}\n
};\n
}\n
\n
// Looks for a statement, and then calls itself.\n
function statements(token){\n
return pass(statement, statements);\n
}\n
// Dispatches various types of statements based on the type of the current token.\n
function statement(token){\n
var type = token.type;\n
if (type == "keyword a") cont(pushlex("form"), expression, altsyntax, statement, poplex);\n
else if (type == "keyword b") cont(pushlex("form"), statement, poplex);\n
else if (type == "{") cont(pushlex("}"), block, poplex);\n
else if (type == "function") funcdef();\n
// technically, "class implode {...}" is correct, but we\'ll flag that as an error because it overrides a predefined function\n
else if (type == "class") classdef();\n
else if (type == "foreach") cont(pushlex("form"), require("("), pushlex(")"), expression, require("as"), require("variable"), /* => $value */ expect(")"), altsyntax, poplex, statement, poplex);\n
else if (type == "for") cont(pushlex("form"), require("("), pushlex(")"), expression, require(";"), expression, require(";"), expression, require(")"), altsyntax, poplex, statement, poplex);\n
// public final function foo(), protected static $bar;\n
else if (type == "modifier") cont(require(["modifier", "variable", "function", "abstract"], [null, null, funcdef, absfun]));\n
else if (type == "abstract") abs();\n
else if (type == "switch") cont(pushlex("form"), require("("), expression, require(")"), pushlex("}", "switch"), require([":", "{"]), block, poplex, poplex);\n
else if (type == "case") cont(expression, require(":"));\n
else if (type == "default") cont(require(":"));\n
else if (type == "catch") cont(pushlex("form"), require("("), require("t_string"), require("variable"), require(")"), statement, poplex);\n
else if (type == "const") cont(require("t_string")); // \'const static x=5\' is a syntax error\n
// technically, "namespace implode {...}" is correct, but we\'ll flag that as an error because it overrides a predefined function\n
else if (type == "namespace") cont(namespacedef, require(";"));\n
// $variables may be followed by operators, () for variable function calls, or [] subscripts\n
else pass(pushlex("stat"), expression, require(";"), poplex);\n
}\n
// Dispatch expression types.\n
function expression(token){\n
var type = token.type;\n
if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator);\n
else if (type == "<<<") cont(require("string"), maybeoperator); // heredoc/nowdoc\n
else if (type == "t_string") cont(maybe_double_colon, maybeoperator);\n
else if (type == "keyword c" || type == "operator") cont(expression);\n
// lambda\n
else if (type == "function") lambdadef();\n
// function call or parenthesized expression: $a = ($b + 1) * 2;\n
else if (type == "(") cont(pushlex(")"), commasep(expression), require(")"), poplex, maybeoperator);\n
}\n
// Called for places where operators, function calls, or subscripts are\n
// valid. Will skip on to the next action if none is found.\n
function maybeoperator(token){\n
var type = token.type;\n
if (type == "operator") {\n
if (token.content == "?") cont(expression, require(":"), expression); // ternary operator\n
else cont(expression);\n
}\n
else if (type == "(") cont(pushlex(")"), expression, commasep(expression), require(")"), poplex, maybeoperator /* $varfunc() + 3 */);\n
else if (type == "[") cont(pushlex("]"), expression, require("]"), maybeoperator /* for multidimensional arrays, or $func[$i]() */, poplex);\n
}\n
// A regular use of the double colon to specify a class, as in self::func() or myclass::$var;\n
// Differs from `namespace` or `use` in that only one class can be the parent; chains (A::B::$var) are a syntax error.\n
function maybe_double_colon(token) {\n
if (token.type == "t_double_colon")\n
// A::$var, A::func(), A::const\n
cont(require(["t_string", "variable"]), maybeoperator);\n
else {\n
// a t_string wasn\'t followed by ::, such as in a function call: foo()\n
pass(expression)\n
}\n
}\n
// the declaration or definition of a function\n
function funcdef() {\n
cont(require("t_string"), require("("), pushlex(")"), commasep(funcarg), require(")"), poplex, block);\n
}\n
// the declaration or definition of a lambda\n
function lambdadef() {\n
cont(require("("), pushlex(")"), commasep(funcarg), require(")"), maybe_lambda_use, poplex, require("{"), pushlex("}"), block, poplex);\n
}\n
// optional lambda \'use\' statement\n
function maybe_lambda_use(token) {\n
if(token.type == "namespace") {\n
cont(require(\'(\'), commasep(funcarg), require(\')\'));\n
}\n
else {\n
pass(expression);\n
}\n
}\n
// the definition of a class\n
function classdef() {\n
cont(require("t_string"), expect("{"), pushlex("}"), block, poplex);\n
}\n
// either funcdef if the current token is "function", or the keyword "function" + funcdef\n
function absfun(token) {\n
if(token.type == "function") funcdef();\n
else cont(require(["function"], [funcdef]));\n
}\n
// the abstract class or function (with optional modifier)\n
function abs(token) {\n
cont(require(["modifier", "function", "class"], [absfun, funcdef, classdef]));\n
}\n
// Parses a comma-separated list of the things that are recognized\n
// by the \'what\' argument.\n
function commasep(what){\n
function proceed(token) {\n
if (token.type == ",") cont(what, proceed);\n
}\n
return function commaSeparated() {\n
pass(what, proceed);\n
};\n
}\n
// Look for statements until a closing brace is found.\n
function block(token) {\n
if (token.type == "}") cont();\n
else pass(statement, block);\n
}\n
function empty_parens_if_array(token) {\n
if(token.content == "array")\n
cont(require("("), require(")"));\n
}\n
function maybedefaultparameter(token){\n
if (token.content == "=") cont(require(["t_string", "string", "number", "atom"], [empty_parens_if_array, null, null]));\n
}\n
function var_or_reference(token) {\n
if(token.type == "variable") cont(maybedefaultparameter);\n
else if(token.content == "&") cont(require("variable"), maybedefaultparameter);\n
}\n
// support for default arguments: http://us.php.net/manual/en/functions.arguments.php#functions.arguments.default\n
function funcarg(token){\n
// function foo(myclass $obj) {...} or function foo(myclass &objref) {...}\n
if (token.type == "t_string") cont(var_or_reference);\n
// function foo($var) {...} or function foo(&$ref) {...}\n
else var_or_reference(token);\n
}\n
\n
// A namespace definition or use\n
function maybe_double_colon_def(token) {\n
if (token.type == "t_double_colon")\n
cont(namespacedef);\n
}\n
function namespacedef(token) {\n
pass(require("t_string"), maybe_double_colon_def);\n
}\n
\n
function altsyntax(token){\n
\tif(token.content==\':\')\n
\t\tcont(altsyntaxBlock,poplex);\n
}\n
\n
function altsyntaxBlock(token){\n
\tif (token.type == "altsyntaxend") cont(require(\';\'));\n
else pass(statement, altsyntaxBlock);\n
}\n
\n
\n
return parser;\n
}\n
\n
return {make: parsePHP, electricChars: "{}:"};\n
\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>16866</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.92</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsephphtmlmixed.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.\n
The copyrights embodied in the content of this file are licensed by\n
Yahoo! Inc. under the BSD (revised) open source license\n
\n
@author Dan Vlad Dascalescu <dandv@yahoo-inc.com>\n
\n
Based on parsehtmlmixed.js by Marijn Haverbeke.\n
*/\n
\n
var PHPHTMLMixedParser = Editor.Parser = (function() {\n
var processingInstructions = ["<?php"];\n
\n
if (!(PHPParser && CSSParser && JSParser && XMLParser))\n
throw new Error("PHP, CSS, JS, and XML parsers must be loaded for PHP+HTML mixed mode to work.");\n
XMLParser.configure({useHTMLKludges: true});\n
\n
function parseMixed(stream) {\n
var htmlParser = XMLParser.make(stream), localParser = null,\n
inTag = false, lastAtt = null, phpParserState = null;\n
var iter = {next: top, copy: copy};\n
\n
function top() {\n
var token = htmlParser.next();\n
if (token.content == "<")\n
inTag = true;\n
else if (token.style == "xml-tagname" && inTag === true)\n
inTag = token.content.toLowerCase();\n
else if (token.style == "xml-attname")\n
lastAtt = token.content;\n
else if (token.type == "xml-processing") {\n
// see if this opens a PHP block\n
for (var i = 0; i < processingInstructions.length; i++)\n
if (processingInstructions[i] == token.content) {\n
iter.next = local(PHPParser, "?>");\n
break;\n
}\n
}\n
else if (token.style == "xml-attribute" && token.content == "\\"php\\"" && inTag == "script" && lastAtt == "language")\n
inTag = "script/php";\n
// "xml-processing" tokens are ignored, because they should be handled by a specific local parser\n
else if (token.content == ">") {\n
if (inTag == "script/php")\n
iter.next = local(PHPParser, "</script>");\n
else if (inTag == "script")\n
iter.next = local(JSParser, "</script");\n
else if (inTag == "style")\n
iter.next = local(CSSParser, "</style");\n
lastAtt = null;\n
inTag = false;\n
}\n
return token;\n
}\n
function local(parser, tag) {\n
var baseIndent = htmlParser.indentation();\n
if (parser == PHPParser && phpParserState)\n
localParser = phpParserState(stream);\n
else\n
localParser = parser.make(stream, baseIndent + indentUnit);\n
\n
return function() {\n
if (stream.lookAhead(tag, false, false, true)) {\n
if (parser == PHPParser) phpParserState = localParser.copy();\n
localParser = null;\n
iter.next = top;\n
return top(); // pass the ending tag to the enclosing parser\n
}\n
\n
var token = localParser.next();\n
var lt = token.value.lastIndexOf("<"), sz = Math.min(token.value.length - lt, tag.length);\n
if (lt != -1 && token.value.slice(lt, lt + sz).toLowerCase() == tag.slice(0, sz) &&\n
stream.lookAhead(tag.slice(sz), false, false, true)) {\n
stream.push(token.value.slice(lt));\n
token.value = token.value.slice(0, lt);\n
}\n
\n
if (token.indentation) {\n
var oldIndent = token.indentation;\n
token.indentation = function(chars) {\n
if (chars == "</")\n
return baseIndent;\n
else\n
return oldIndent(chars);\n
}\n
}\n
\n
return token;\n
};\n
}\n
\n
function copy() {\n
var _html = htmlParser.copy(), _local = localParser && localParser.copy(),\n
_next = iter.next, _inTag = inTag, _lastAtt = lastAtt, _php = phpParserState;\n
return function(_stream) {\n
stream = _stream;\n
htmlParser = _html(_stream);\n
localParser = _local && _local(_stream);\n
phpParserState = _php;\n
iter.next = _next;\n
inTag = _inTag;\n
lastAtt = _lastAtt;\n
return iter;\n
};\n
}\n
return iter;\n
}\n
\n
return {\n
make: parseMixed,\n
electricChars: "{}/:",\n
configure: function(conf) {\n
if (conf.opening != null) processingInstructions = conf.opening;\n
}\n
};\n
\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>3981</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.93</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>tokenizephp.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.\n
The copyrights embodied in the content of this file are licensed by\n
Yahoo! Inc. under the BSD (revised) open source license\n
\n
@author Vlad Dan Dascalescu <dandv@yahoo-inc.com>\n
\n
\n
Tokenizer for PHP code\n
\n
References:\n
+ http://php.net/manual/en/reserved.php\n
+ http://php.net/tokens\n
+ get_defined_constants(), get_defined_functions(), get_declared_classes()\n
executed on a realistic (not vanilla) PHP installation with typical LAMP modules.\n
Specifically, the PHP bundled with the Uniform Web Server (www.uniformserver.com).\n
\n
*/\n
\n
\n
// add the forEach method for JS engines that don\'t support it (e.g. IE)\n
// code from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Objects:Array:forEach\n
if (!Array.prototype.forEach)\n
{\n
Array.prototype.forEach = function(fun /*, thisp*/)\n
{\n
var len = this.length;\n
if (typeof fun != "function")\n
throw new TypeError();\n
\n
var thisp = arguments[1];\n
for (var i = 0; i < len; i++)\n
{\n
if (i in this)\n
fun.call(thisp, this[i], i, this);\n
}\n
};\n
}\n
\n
\n
var tokenizePHP = (function() {\n
/* A map of PHP\'s reserved words (keywords, predefined classes, functions and\n
constants. Each token has a type (\'keyword\', \'operator\' etc.) and a style.\n
The style corresponds to the CSS span class in phpcolors.css.\n
\n
Keywords can be of three types:\n
a - takes an expression and forms a statement - e.g. if\n
b - takes just a statement - e.g. else\n
c - takes an optinoal expression, but no statement - e.g. return\n
This distinction gives the parser enough information to parse\n
correct code correctly (we don\'t care that much how we parse\n
incorrect code).\n
\n
Reference: http://us.php.net/manual/en/reserved.php\n
*/\n
var keywords = function(){\n
function token(type, style){\n
return {type: type, style: style};\n
}\n
var result = {};\n
\n
// for each(var element in ["...", "..."]) can pick up elements added to\n
// Array.prototype, so we\'ll use the loop structure below. See also\n
// http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/for_each...in\n
\n
// keywords that take an expression and form a statement\n
["if", "elseif", "while", "declare"].forEach(function(element, index, array) {\n
result[element] = token("keyword a", "php-keyword");\n
});\n
\n
// keywords that take just a statement\n
["do", "else", "try" ].forEach(function(element, index, array) {\n
result[element] = token("keyword b", "php-keyword");\n
});\n
\n
// keywords that take an optional expression, but no statement\n
["return", "break", "continue", // the expression is optional\n
"new", "clone", "throw" // the expression is mandatory\n
].forEach(function(element, index, array) {\n
result[element] = token("keyword c", "php-keyword");\n
});\n
\n
["__CLASS__", "__DIR__", "__FILE__", "__FUNCTION__", "__METHOD__", "__NAMESPACE__"].forEach(function(element, index, array) {\n
result[element] = token("atom", "php-compile-time-constant");\n
});\n
\n
["true", "false", "null"].forEach(function(element, index, array) {\n
result[element] = token("atom", "php-atom");\n
});\n
\n
["and", "or", "xor", "instanceof"].forEach(function(element, index, array) {\n
result[element] = token("operator", "php-keyword php-operator");\n
});\n
\n
["class", "interface"].forEach(function(element, index, array) {\n
result[element] = token("class", "php-keyword");\n
});\n
["namespace", "use", "extends", "implements"].forEach(function(element, index, array) {\n
result[element] = token("namespace", "php-keyword");\n
});\n
\n
// reserved "language constructs"... http://php.net/manual/en/reserved.php\n
[ "die", "echo", "empty", "exit", "eval", "include", "include_once", "isset",\n
"list", "require", "require_once", "return", "print", "unset",\n
"array" // a keyword rather, but mandates a parenthesized parameter list\n
].forEach(function(element, index, array) {\n
result[element] = token("t_string", "php-reserved-language-construct");\n
});\n
\n
result["switch"] = token("switch", "php-keyword");\n
result["case"] = token("case", "php-keyword");\n
result["default"] = token("default", "php-keyword");\n
result["catch"] = token("catch", "php-keyword");\n
result["function"] = token("function", "php-keyword");\n
\n
// http://php.net/manual/en/control-structures.alternative-syntax.php must be followed by a \':\'\n
["endif", "endwhile", "endfor", "endforeach", "endswitch", "enddeclare"].forEach(function(element, index, array) {\n
result[element] = token("altsyntaxend", "php-keyword");\n
});\n
\n
result["const"] = token("const", "php-keyword");\n
\n
["final", "private", "protected", "public", "global", "static"].forEach(function(element, index, array) {\n
result[element] = token("modifier", "php-keyword");\n
});\n
result["var"] = token("modifier", "php-keyword deprecated");\n
result["abstract"] = token("abstract", "php-keyword");\n
\n
result["foreach"] = token("foreach", "php-keyword");\n
result["as"] = token("as", "php-keyword");\n
result["for"] = token("for", "php-keyword");\n
\n
// PHP built-in functions - output of get_defined_functions()["internal"]\n
[ "zend_version", "func_num_args", "func_get_arg", "func_get_args", "strlen",\n
"strcmp", "strncmp", "strcasecmp", "strncasecmp", "each", "error_reporting",\n
"define", "defined", "get_class", "get_parent_class", "method_exists",\n
"property_exists", "class_exists", "interface_exists", "function_exists",\n
"get_included_files", "get_required_files", "is_subclass_of", "is_a",\n
"get_class_vars", "get_object_vars", "get_class_methods", "trigger_error",\n
"user_error", "set_error_handler", "restore_error_handler",\n
"set_exception_handler", "restore_exception_handler", "get_declared_classes",\n
"get_declared_interfaces", "get_defined_functions", "get_defined_vars",\n
"create_function", "get_resource_type", "get_loaded_extensions",\n
"extension_loaded", "get_extension_funcs", "get_defined_constants",\n
"debug_backtrace", "debug_print_backtrace", "bcadd", "bcsub", "bcmul", "bcdiv",\n
"bcmod", "bcpow", "bcsqrt", "bcscale", "bccomp", "bcpowmod", "jdtogregorian",\n
"gregoriantojd", "jdtojulian", "juliantojd", "jdtojewish", "jewishtojd",\n
"jdtofrench", "frenchtojd", "jddayofweek", "jdmonthname", "easter_date",\n
"easter_days", "unixtojd", "jdtounix", "cal_to_jd", "cal_from_jd",\n
"cal_days_in_month", "cal_info", "variant_set", "variant_add", "variant_cat",\n
"variant_sub", "variant_mul", "variant_and", "variant_div", "variant_eqv",\n
"variant_idiv", "variant_imp", "variant_mod", "variant_or", "variant_pow",\n
"variant_xor", "variant_abs", "variant_fix", "variant_int", "variant_neg",\n
"variant_not", "variant_round", "variant_cmp", "variant_date_to_timestamp",\n
"variant_date_from_timestamp", "variant_get_type", "variant_set_type",\n
"variant_cast", "com_create_guid", "com_event_sink", "com_print_typeinfo",\n
"com_message_pump", "com_load_typelib", "com_get_active_object", "ctype_alnum",\n
"ctype_alpha", "ctype_cntrl", "ctype_digit", "ctype_lower", "ctype_graph",\n
"ctype_print", "ctype_punct", "ctype_space", "ctype_upper", "ctype_xdigit",\n
"strtotime", "date", "idate", "gmdate", "mktime", "gmmktime", "checkdate",\n
"strftime", "gmstrftime", "time", "localtime", "getdate", "date_create",\n
"date_parse", "date_format", "date_modify", "date_timezone_get",\n
"date_timezone_set", "date_offset_get", "date_time_set", "date_date_set",\n
"date_isodate_set", "timezone_open", "timezone_name_get",\n
"timezone_name_from_abbr", "timezone_offset_get", "timezone_transitions_get",\n
"timezone_identifiers_list", "timezone_abbreviations_list",\n
"date_default_timezone_set", "date_default_timezone_get", "date_sunrise",\n
"date_sunset", "date_sun_info", "filter_input", "filter_var",\n
"filter_input_array", "filter_var_array", "filter_list", "filter_has_var",\n
"filter_id", "ftp_connect", "ftp_login", "ftp_pwd", "ftp_cdup", "ftp_chdir",\n
"ftp_exec", "ftp_raw", "ftp_mkdir", "ftp_rmdir", "ftp_chmod", "ftp_alloc",\n
"ftp_nlist", "ftp_rawlist", "ftp_systype", "ftp_pasv", "ftp_get", "ftp_fget",\n
"ftp_put", "ftp_fput", "ftp_size", "ftp_mdtm", "ftp_rename", "ftp_delete",\n
"ftp_site", "ftp_close", "ftp_set_option", "ftp_get_option", "ftp_nb_fget",\n
"ftp_nb_get", "ftp_nb_continue", "ftp_nb_put", "ftp_nb_fput", "ftp_quit",\n
"hash", "hash_file", "hash_hmac", "hash_hmac_file", "hash_init", "hash_update",\n
"hash_update_stream", "hash_update_file", "hash_final", "hash_algos", "iconv",\n
"ob_iconv_handler", "iconv_get_encoding", "iconv_set_encoding", "iconv_strlen",\n
"iconv_substr", "iconv_strpos", "iconv_strrpos", "iconv_mime_encode",\n
"iconv_mime_decode", "iconv_mime_decode_headers", "json_encode", "json_decode",\n
"odbc_autocommit", "odbc_binmode", "odbc_close", "odbc_close_all",\n
"odbc_columns", "odbc_commit", "odbc_connect", "odbc_cursor",\n
"odbc_data_source", "odbc_execute", "odbc_error", "odbc_errormsg", "odbc_exec",\n
"odbc_fetch_array", "odbc_fetch_object", "odbc_fetch_row", "odbc_fetch_into",\n
"odbc_field_len", "odbc_field_scale", "odbc_field_name", "odbc_field_type",\n
"odbc_field_num", "odbc_free_result", "odbc_gettypeinfo", "odbc_longreadlen",\n
"odbc_next_result", "odbc_num_fields", "odbc_num_rows", "odbc_pconnect",\n
"odbc_prepare", "odbc_result", "odbc_result_all", "odbc_rollback",\n
"odbc_setoption", "odbc_specialcolumns", "odbc_statistics", "odbc_tables",\n
"odbc_primarykeys", "odbc_columnprivileges", "odbc_tableprivileges",\n
"odbc_foreignkeys", "odbc_procedures", "odbc_procedurecolumns", "odbc_do",\n
"odbc_field_precision", "preg_match", "preg_match_all", "preg_replace",\n
"preg_replace_callback", "preg_split", "preg_quote", "preg_grep",\n
"preg_last_error", "session_name", "session_module_name", "session_save_path",\n
"session_id", "session_regenerate_id", "session_decode", "session_register",\n
"session_unregister", "session_is_registered", "session_encode",\n
"session_start", "session_destroy", "session_unset",\n
"session_set_save_handler", "session_cache_limiter", "session_cache_expire",\n
"session_set_cookie_params", "session_get_cookie_params",\n
"session_write_close", "session_commit", "spl_classes", "spl_autoload",\n
"spl_autoload_extensions", "spl_autoload_register", "spl_autoload_unregister",\n
"spl_autoload_functions", "spl_autoload_call", "class_parents",\n
"class_implements", "spl_object_hash", "iterator_to_array", "iterator_count",\n
"iterator_apply", "constant", "bin2hex", "sleep", "usleep", "flush",\n
"wordwrap", "htmlspecialchars", "htmlentities", "html_entity_decode",\n
"htmlspecialchars_decode", "get_html_translation_table", "sha1", "sha1_file",\n
"md5", "md5_file", "crc32", "iptcparse", "iptcembed", "getimagesize",\n
"image_type_to_mime_type", "image_type_to_extension", "phpinfo", "phpversion",\n
"phpcredits", "php_logo_guid", "php_real_logo_guid", "php_egg_logo_guid",\n
"zend_logo_guid", "php_sapi_name", "php_uname", "php_ini_scanned_files",\n
"strnatcmp", "strnatcasecmp", "substr_count", "strspn", "strcspn", "strtok",\n
"strtoupper", "strtolower", "strpos", "stripos", "strrpos", "strripos",\n
"strrev", "hebrev", "hebrevc", "nl2br", "basename", "dirname", "pathinfo",\n
"stripslashes", "stripcslashes", "strstr", "stristr", "strrchr", "str_shuffle",\n
"str_word_count", "str_split", "strpbrk", "substr_compare", "strcoll",\n
"substr", "substr_replace", "quotemeta", "ucfirst", "ucwords", "strtr",\n
"addslashes", "addcslashes", "rtrim", "str_replace", "str_ireplace",\n
"str_repeat", "count_chars", "chunk_split", "trim", "ltrim", "strip_tags",\n
"similar_text", "explode", "implode", "setlocale", "localeconv", "soundex",\n
"levenshtein", "chr", "ord", "parse_str", "str_pad", "chop", "strchr",\n
"sprintf", "printf", "vprintf", "vsprintf", "fprintf", "vfprintf", "sscanf",\n
"fscanf", "parse_url", "urlencode", "urldecode", "rawurlencode",\n
"rawurldecode", "http_build_query", "unlink", "exec", "system",\n
"escapeshellcmd", "escapeshellarg", "passthru", "shell_exec", "proc_open",\n
"proc_close", "proc_terminate", "proc_get_status", "rand", "srand",\n
"getrandmax", "mt_rand", "mt_srand", "mt_getrandmax", "getservbyname",\n
"getservbyport", "getprotobyname", "getprotobynumber", "getmyuid", "getmygid",\n
"getmypid", "getmyinode", "getlastmod", "base64_decode", "base64_encode",\n
"convert_uuencode", "convert_uudecode", "abs", "ceil", "floor", "round", "sin",\n
"cos", "tan", "asin", "acos", "atan", "atan2", "sinh", "cosh", "tanh", "pi",\n
"is_finite", "is_nan", "is_infinite", "pow", "exp", "log", "log10", "sqrt",\n
"hypot", "deg2rad", "rad2deg", "bindec", "hexdec", "octdec", "decbin",\n
"decoct", "dechex", "base_convert", "number_format", "fmod", "ip2long",\n
"long2ip", "getenv", "putenv", "microtime", "gettimeofday", "uniqid",\n
"quoted_printable_decode", "convert_cyr_string", "get_current_user",\n
"set_time_limit", "get_cfg_var", "magic_quotes_runtime",\n
"set_magic_quotes_runtime", "get_magic_quotes_gpc", "get_magic_quotes_runtime",\n
"import_request_variables", "error_log", "error_get_last", "call_user_func",\n
"call_user_func_array", "call_user_method", "call_user_method_array",\n
"serialize", "unserialize", "var_dump", "var_export", "debug_zval_dump",\n
"print_r", "memory_get_usage", "memory_get_peak_usage",\n
"register_shutdown_function", "register_tick_function",\n
"unregister_tick_function", "highlight_file", "show_source",\n
"highlight_string", "php_strip_whitespace", "ini_get", "ini_get_all",\n
"ini_set", "ini_alter", "ini_restore", "get_include_path", "set_include_path",\n
"restore_include_path", "setcookie", "setrawcookie", "header", "headers_sent",\n
"headers_list", "connection_aborted", "connection_status", "ignore_user_abort",\n
"parse_ini_file", "is_uploaded_file", "move_uploaded_file", "gethostbyaddr",\n
"gethostbyname", "gethostbynamel", "intval", "floatval", "doubleval", "strval",\n
"gettype", "settype", "is_null", "is_resource", "is_bool", "is_long",\n
"is_float", "is_int", "is_integer", "is_double", "is_real", "is_numeric",\n
"is_string", "is_array", "is_object", "is_scalar", "is_callable", "ereg",\n
"ereg_replace", "eregi", "eregi_replace", "split", "spliti", "join",\n
"sql_regcase", "dl", "pclose", "popen", "readfile", "rewind", "rmdir", "umask",\n
"fclose", "feof", "fgetc", "fgets", "fgetss", "fread", "fopen", "fpassthru",\n
"ftruncate", "fstat", "fseek", "ftell", "fflush", "fwrite", "fputs", "mkdir",\n
"rename", "copy", "tempnam", "tmpfile", "file", "file_get_contents",\n
"file_put_contents", "stream_select", "stream_context_create",\n
"stream_context_set_params", "stream_context_set_option",\n
"stream_context_get_options", "stream_context_get_default",\n
"stream_filter_prepend", "stream_filter_append", "stream_filter_remove",\n
"stream_socket_client", "stream_socket_server", "stream_socket_accept",\n
"stream_socket_get_name", "stream_socket_recvfrom", "stream_socket_sendto",\n
"stream_socket_enable_crypto", "stream_socket_shutdown",\n
"stream_copy_to_stream", "stream_get_contents", "fgetcsv", "fputcsv", "flock",\n
"get_meta_tags", "stream_set_write_buffer", "set_file_buffer",\n
"set_socket_blocking", "stream_set_blocking", "socket_set_blocking",\n
"stream_get_meta_data", "stream_get_line", "stream_wrapper_register",\n
"stream_register_wrapper", "stream_wrapper_unregister",\n
"stream_wrapper_restore", "stream_get_wrappers", "stream_get_transports",\n
"get_headers", "stream_set_timeout", "socket_set_timeout", "socket_get_status",\n
"realpath", "fsockopen", "pfsockopen", "pack", "unpack", "get_browser",\n
"crypt", "opendir", "closedir", "chdir", "getcwd", "rewinddir", "readdir",\n
"dir", "scandir", "glob", "fileatime", "filectime", "filegroup", "fileinode",\n
"filemtime", "fileowner", "fileperms", "filesize", "filetype", "file_exists",\n
"is_writable", "is_writeable", "is_readable", "is_executable", "is_file",\n
"is_dir", "is_link", "stat", "lstat", "chown", "chgrp", "chmod", "touch",\n
"clearstatcache", "disk_total_space", "disk_free_space", "diskfreespace",\n
"mail", "ezmlm_hash", "openlog", "syslog", "closelog",\n
"define_syslog_variables", "lcg_value", "metaphone", "ob_start", "ob_flush",\n
"ob_clean", "ob_end_flush", "ob_end_clean", "ob_get_flush", "ob_get_clean",\n
"ob_get_length", "ob_get_level", "ob_get_status", "ob_get_contents",\n
"ob_implicit_flush", "ob_list_handlers", "ksort", "krsort", "natsort",\n
"natcasesort", "asort", "arsort", "sort", "rsort", "usort", "uasort", "uksort",\n
"shuffle", "array_walk", "array_walk_recursive", "count", "end", "prev",\n
"next", "reset", "current", "key", "min", "max", "in_array", "array_search",\n
"extract", "compact", "array_fill", "array_fill_keys", "range",\n
"array_multisort", "array_push", "array_pop", "array_shift", "array_unshift",\n
"array_splice", "array_slice", "array_merge", "array_merge_recursive",\n
"array_keys", "array_values", "array_count_values", "array_reverse",\n
"array_reduce", "array_pad", "array_flip", "array_change_key_case",\n
"array_rand", "array_unique", "array_intersect", "array_intersect_key",\n
"array_intersect_ukey", "array_uintersect", "array_intersect_assoc",\n
"array_uintersect_assoc", "array_intersect_uassoc", "array_uintersect_uassoc",\n
"array_diff", "array_diff_key", "array_diff_ukey", "array_udiff",\n
"array_diff_assoc", "array_udiff_assoc", "array_diff_uassoc",\n
"array_udiff_uassoc", "array_sum", "array_product", "array_filter",\n
"array_map", "array_chunk", "array_combine", "array_key_exists", "pos",\n
"sizeof", "key_exists", "assert", "assert_options", "version_compare",\n
"str_rot13", "stream_get_filters", "stream_filter_register",\n
"stream_bucket_make_writeable", "stream_bucket_prepend",\n
"stream_bucket_append", "stream_bucket_new", "output_add_rewrite_var",\n
"output_reset_rewrite_vars", "sys_get_temp_dir", "token_get_all", "token_name",\n
"readgzfile", "gzrewind", "gzclose", "gzeof", "gzgetc", "gzgets", "gzgetss",\n
"gzread", "gzopen", "gzpassthru", "gzseek", "gztell", "gzwrite", "gzputs",\n
"gzfile", "gzcompress", "gzuncompress", "gzdeflate", "gzinflate", "gzencode",\n
"ob_gzhandler", "zlib_get_coding_type", "libxml_set_streams_context",\n
"libxml_use_internal_errors", "libxml_get_last_error", "libxml_clear_errors",\n
"libxml_get_errors", "dom_import_simplexml", "simplexml_load_file",\n
"simplexml_load_string", "simplexml_import_dom", "wddx_serialize_value",\n
"wddx_serialize_vars", "wddx_packet_start", "wddx_packet_end", "wddx_add_vars",\n
"wddx_deserialize", "xml_parser_create", "xml_parser_create_ns",\n
"xml_set_object", "xml_set_element_handler", "xml_set_character_data_handler",\n
"xml_set_processing_instruction_handler", "xml_set_default_handler",\n
"xml_set_unparsed_entity_decl_handler", "xml_set_notation_decl_handler",\n
"xml_set_external_entity_ref_handler", "xml_set_start_namespace_decl_handler",\n
"xml_set_end_namespace_decl_handler", "xml_parse", "xml_parse_into_struct",\n
"xml_get_error_code", "xml_error_string", "xml_get_current_line_number",\n
"xml_get_current_column_number", "xml_get_current_byte_index",\n
"xml_parser_free", "xml_parser_set_option", "xml_parser_get_option",\n
"utf8_encode", "utf8_decode", "xmlwriter_open_uri", "xmlwriter_open_memory",\n
"xmlwriter_set_indent", "xmlwriter_set_indent_string",\n
"xmlwriter_start_comment", "xmlwriter_end_comment",\n
"xmlwriter_start_attribute", "xmlwriter_end_attribute",\n
"xmlwriter_write_attribute", "xmlwriter_start_attribute_ns",\n
"xmlwriter_write_attribute_ns", "xmlwriter_start_element",\n
"xmlwriter_end_element", "xmlwriter_full_end_element",\n
"xmlwriter_start_element_ns", "xmlwriter_write_element",\n
"xmlwriter_write_element_ns", "xmlwriter_start_pi", "xmlwriter_end_pi",\n
"xmlwriter_write_pi", "xmlwriter_start_cdata", "xmlwriter_end_cdata",\n
"xmlwriter_write_cdata", "xmlwriter_text", "xmlwriter_write_raw",\n
"xmlwriter_start_document", "xmlwriter_end_document",\n
"xmlwriter_write_comment", "xmlwriter_start_dtd", "xmlwriter_end_dtd",\n
"xmlwriter_write_dtd", "xmlwriter_start_dtd_element",\n
"xmlwriter_end_dtd_element", "xmlwriter_write_dtd_element",\n
"xmlwriter_start_dtd_attlist", "xmlwriter_end_dtd_attlist",\n
"xmlwriter_write_dtd_attlist", "xmlwriter_start_dtd_entity",\n
"xmlwriter_end_dtd_entity", "xmlwriter_write_dtd_entity",\n
"xmlwriter_output_memory", "xmlwriter_flush", "gd_info", "imagearc",\n
"imageellipse", "imagechar", "imagecharup", "imagecolorat",\n
"imagecolorallocate", "imagepalettecopy", "imagecreatefromstring",\n
"imagecolorclosest", "imagecolordeallocate", "imagecolorresolve",\n
"imagecolorexact", "imagecolorset", "imagecolortransparent",\n
"imagecolorstotal", "imagecolorsforindex", "imagecopy", "imagecopymerge",\n
"imagecopymergegray", "imagecopyresized", "imagecreate",\n
"imagecreatetruecolor", "imageistruecolor", "imagetruecolortopalette",\n
"imagesetthickness", "imagefilledarc", "imagefilledellipse",\n
"imagealphablending", "imagesavealpha", "imagecolorallocatealpha",\n
"imagecolorresolvealpha", "imagecolorclosestalpha", "imagecolorexactalpha",\n
"imagecopyresampled", "imagegrabwindow", "imagegrabscreen", "imagerotate",\n
"imageantialias", "imagesettile", "imagesetbrush", "imagesetstyle",\n
"imagecreatefrompng", "imagecreatefromgif", "imagecreatefromjpeg",\n
"imagecreatefromwbmp", "imagecreatefromxbm", "imagecreatefromgd",\n
"imagecreatefromgd2", "imagecreatefromgd2part", "imagepng", "imagegif",\n
"imagejpeg", "imagewbmp", "imagegd", "imagegd2", "imagedestroy",\n
"imagegammacorrect", "imagefill", "imagefilledpolygon", "imagefilledrectangle",\n
"imagefilltoborder", "imagefontwidth", "imagefontheight", "imageinterlace",\n
"imageline", "imageloadfont", "imagepolygon", "imagerectangle",\n
"imagesetpixel", "imagestring", "imagestringup", "imagesx", "imagesy",\n
"imagedashedline", "imagettfbbox", "imagettftext", "imageftbbox",\n
"imagefttext", "imagepsloadfont", "imagepsfreefont", "imagepsencodefont",\n
"imagepsextendfont", "imagepsslantfont", "imagepstext", "imagepsbbox",\n
"imagetypes", "jpeg2wbmp", "png2wbmp", "image2wbmp", "imagelayereffect",\n
"imagecolormatch", "imagexbm", "imagefilter", "imageconvolution",\n
"mb_convert_case", "mb_strtoupper", "mb_strtolower", "mb_language",\n
"mb_internal_encoding", "mb_http_input", "mb_http_output", "mb_detect_order",\n
"mb_substitute_character", "mb_parse_str", "mb_output_handler",\n
"mb_preferred_mime_name", "mb_strlen", "mb_strpos", "mb_strrpos", "mb_stripos",\n
"mb_strripos", "mb_strstr", "mb_strrchr", "mb_stristr", "mb_strrichr",\n
"mb_substr_count", "mb_substr", "mb_strcut", "mb_strwidth", "mb_strimwidth",\n
"mb_convert_encoding", "mb_detect_encoding", "mb_list_encodings",\n
"mb_convert_kana", "mb_encode_mimeheader", "mb_decode_mimeheader",\n
"mb_convert_variables", "mb_encode_numericentity", "mb_decode_numericentity",\n
"mb_send_mail", "mb_get_info", "mb_check_encoding", "mb_regex_encoding",\n
"mb_regex_set_options", "mb_ereg", "mb_eregi", "mb_ereg_replace",\n
"mb_eregi_replace", "mb_split", "mb_ereg_match", "mb_ereg_search",\n
"mb_ereg_search_pos", "mb_ereg_search_regs", "mb_ereg_search_init",\n
"mb_ereg_search_getregs", "mb_ereg_search_getpos", "mb_ereg_search_setpos",\n
"mbregex_encoding", "mbereg", "mberegi", "mbereg_replace", "mberegi_replace",\n
"mbsplit", "mbereg_match", "mbereg_search", "mbereg_search_pos",\n
"mbereg_search_regs", "mbereg_search_init", "mbereg_search_getregs",\n
"mbereg_search_getpos", "mbereg_search_setpos", "mysql_connect",\n
"mysql_pconnect", "mysql_close", "mysql_select_db", "mysql_query",\n
"mysql_unbuffered_query", "mysql_db_query", "mysql_list_dbs",\n
"mysql_list_tables", "mysql_list_fields", "mysql_list_processes",\n
"mysql_error", "mysql_errno", "mysql_affected_rows", "mysql_insert_id",\n
"mysql_result", "mysql_num_rows", "mysql_num_fields", "mysql_fetch_row",\n
"mysql_fetch_array", "mysql_fetch_assoc", "mysql_fetch_object",\n
"mysql_data_seek", "mysql_fetch_lengths", "mysql_fetch_field",\n
"mysql_field_seek", "mysql_free_result", "mysql_field_name",\n
"mysql_field_table", "mysql_field_len", "mysql_field_type",\n
"mysql_field_flags", "mysql_escape_string", "mysql_real_escape_string",\n
"mysql_stat", "mysql_thread_id", "mysql_client_encoding", "mysql_ping",\n
"mysql_get_client_info", "mysql_get_host_info", "mysql_get_proto_info",\n
"mysql_get_server_info", "mysql_info", "mysql_set_charset", "mysql",\n
"mysql_fieldname", "mysql_fieldtable", "mysql_fieldlen", "mysql_fieldtype",\n
"mysql_fieldflags", "mysql_selectdb", "mysql_freeresult", "mysql_numfields",\n
"mysql_numrows", "mysql_listdbs", "mysql_listtables", "mysql_listfields",\n
"mysql_db_name", "mysql_dbname", "mysql_tablename", "mysql_table_name",\n
"mysqli_affected_rows", "mysqli_autocommit", "mysqli_change_user",\n
"mysqli_character_set_name", "mysqli_close", "mysqli_commit", "mysqli_connect",\n
"mysqli_connect_errno", "mysqli_connect_error", "mysqli_data_seek",\n
"mysqli_debug", "mysqli_disable_reads_from_master", "mysqli_disable_rpl_parse",\n
"mysqli_dump_debug_info", "mysqli_enable_reads_from_master",\n
"mysqli_enable_rpl_parse", "mysqli_embedded_server_end",\n
"mysqli_embedded_server_start", "mysqli_errno", "mysqli_error",\n
"mysqli_stmt_execute", "mysqli_execute", "mysqli_fetch_field",\n
"mysqli_fetch_fields", "mysqli_fetch_field_direct", "mysqli_fetch_lengths",\n
"mysqli_fetch_array", "mysqli_fetch_assoc", "mysqli_fetch_object",\n
"mysqli_fetch_row", "mysqli_field_count", "mysqli_field_seek",\n
"mysqli_field_tell", "mysqli_free_result", "mysqli_get_charset",\n
"mysqli_get_client_info", "mysqli_get_client_version", "mysqli_get_host_info",\n
"mysqli_get_proto_info", "mysqli_get_server_info", "mysqli_get_server_version",\n
"mysqli_get_warnings", "mysqli_init", "mysqli_info", "mysqli_insert_id",\n
"mysqli_kill", "mysqli_set_local_infile_default",\n
"mysqli_set_local_infile_handler", "mysqli_master_query",\n
"mysqli_more_results", "mysqli_multi_query", "mysqli_next_result",\n
"mysqli_num_fields", "mysqli_num_rows", "mysqli_options", "mysqli_ping",\n
"mysqli_prepare", "mysqli_report", "mysqli_query", "mysqli_real_connect",\n
"mysqli_real_escape_string", "mysqli_real_query", "mysqli_rollback",\n
"mysqli_rpl_parse_enabled", "mysqli_rpl_probe", "mysqli_rpl_query_type",\n
"mysqli_select_db", "mysqli_set_charset", "mysqli_stmt_attr_get",\n
"mysqli_stmt_attr_set", "mysqli_stmt_field_count", "mysqli_stmt_init",\n
"mysqli_stmt_prepare", "mysqli_stmt_result_metadata",\n
"mysqli_stmt_send_long_data", "mysqli_stmt_bind_param",\n
"mysqli_stmt_bind_result", "mysqli_stmt_fetch", "mysqli_stmt_free_result",\n
"mysqli_stmt_get_warnings", "mysqli_stmt_insert_id", "mysqli_stmt_reset",\n
"mysqli_stmt_param_count", "mysqli_send_query", "mysqli_slave_query",\n
"mysqli_sqlstate", "mysqli_ssl_set", "mysqli_stat",\n
"mysqli_stmt_affected_rows", "mysqli_stmt_close", "mysqli_stmt_data_seek",\n
"mysqli_stmt_errno", "mysqli_stmt_error", "mysqli_stmt_num_rows",\n
"mysqli_stmt_sqlstate", "mysqli_store_result", "mysqli_stmt_store_result",\n
"mysqli_thread_id", "mysqli_thread_safe", "mysqli_use_result",\n
"mysqli_warning_count", "mysqli_bind_param", "mysqli_bind_result",\n
"mysqli_client_encoding", "mysqli_escape_string", "mysqli_fetch",\n
"mysqli_param_count", "mysqli_get_metadata", "mysqli_send_long_data",\n
"mysqli_set_opt", "pdo_drivers", "socket_select", "socket_create",\n
"socket_create_listen", "socket_accept", "socket_set_nonblock",\n
"socket_set_block", "socket_listen", "socket_close", "socket_write",\n
"socket_read", "socket_getsockname", "socket_getpeername", "socket_connect",\n
"socket_strerror", "socket_bind", "socket_recv", "socket_send",\n
"socket_recvfrom", "socket_sendto", "socket_get_option", "socket_set_option",\n
"socket_shutdown", "socket_last_error", "socket_clear_error", "socket_getopt",\n
"socket_setopt", "eaccelerator_put", "eaccelerator_get", "eaccelerator_rm",\n
"eaccelerator_gc", "eaccelerator_lock", "eaccelerator_unlock",\n
"eaccelerator_caching", "eaccelerator_optimizer", "eaccelerator_clear",\n
"eaccelerator_clean", "eaccelerator_info", "eaccelerator_purge",\n
"eaccelerator_cached_scripts", "eaccelerator_removed_scripts",\n
"eaccelerator_list_keys", "eaccelerator_encode", "eaccelerator_load",\n
"_eaccelerator_loader_file", "_eaccelerator_loader_line",\n
"eaccelerator_set_session_handlers", "_eaccelerator_output_handler",\n
"eaccelerator_cache_page", "eaccelerator_rm_page", "eaccelerator_cache_output",\n
"eaccelerator_cache_result", "xdebug_get_stack_depth",\n
"xdebug_get_function_stack", "xdebug_print_function_stack",\n
"xdebug_get_declared_vars", "xdebug_call_class", "xdebug_call_function",\n
"xdebug_call_file", "xdebug_call_line", "xdebug_var_dump", "xdebug_debug_zval",\n
"xdebug_debug_zval_stdout", "xdebug_enable", "xdebug_disable",\n
"xdebug_is_enabled", "xdebug_break", "xdebug_start_trace", "xdebug_stop_trace",\n
"xdebug_get_tracefile_name", "xdebug_get_profiler_filename",\n
"xdebug_dump_aggr_profiling_data", "xdebug_clear_aggr_profiling_data",\n
"xdebug_memory_usage", "xdebug_peak_memory_usage", "xdebug_time_index",\n
"xdebug_start_error_collection", "xdebug_stop_error_collection",\n
"xdebug_get_collected_errors", "xdebug_start_code_coverage",\n
"xdebug_stop_code_coverage", "xdebug_get_code_coverage",\n
"xdebug_get_function_count", "xdebug_dump_superglobals",\n
"_" // alias for gettext()\n
].forEach(function(element, index, array) {\n
result[element] = token("t_string", "php-predefined-function");\n
});\n
\n
// output of get_defined_constants(). Differs significantly from http://php.net/manual/en/reserved.constants.php\n
[ "E_ERROR", "E_RECOVERABLE_ERROR", "E_WARNING", "E_PARSE", "E_NOTICE",\n
"E_STRICT", "E_CORE_ERROR", "E_CORE_WARNING", "E_COMPILE_ERROR",\n
"E_COMPILE_WARNING", "E_USER_ERROR", "E_USER_WARNING", "E_USER_NOTICE",\n
"E_ALL", "TRUE", "FALSE", "NULL", "ZEND_THREAD_SAFE", "PHP_VERSION", "PHP_OS",\n
"PHP_SAPI", "DEFAULT_INCLUDE_PATH", "PEAR_INSTALL_DIR", "PEAR_EXTENSION_DIR",\n
"PHP_EXTENSION_DIR", "PHP_PREFIX", "PHP_BINDIR", "PHP_LIBDIR", "PHP_DATADIR",\n
"PHP_SYSCONFDIR", "PHP_LOCALSTATEDIR", "PHP_CONFIG_FILE_PATH",\n
"PHP_CONFIG_FILE_SCAN_DIR", "PHP_SHLIB_SUFFIX", "PHP_EOL", "PHP_EOL",\n
"PHP_INT_MAX", "PHP_INT_SIZE", "PHP_OUTPUT_HANDLER_START",\n
"PHP_OUTPUT_HANDLER_CONT", "PHP_OUTPUT_HANDLER_END", "UPLOAD_ERR_OK",\n
"UPLOAD_ERR_INI_SIZE", "UPLOAD_ERR_FORM_SIZE", "UPLOAD_ERR_PARTIAL",\n
"UPLOAD_ERR_NO_FILE", "UPLOAD_ERR_NO_TMP_DIR", "UPLOAD_ERR_CANT_WRITE",\n
"UPLOAD_ERR_EXTENSION", "CAL_GREGORIAN", "CAL_JULIAN", "CAL_JEWISH",\n
"CAL_FRENCH", "CAL_NUM_CALS", "CAL_DOW_DAYNO", "CAL_DOW_SHORT", "CAL_DOW_LONG",\n
"CAL_MONTH_GREGORIAN_SHORT", "CAL_MONTH_GREGORIAN_LONG",\n
"CAL_MONTH_JULIAN_SHORT", "CAL_MONTH_JULIAN_LONG", "CAL_MONTH_JEWISH",\n
"CAL_MONTH_FRENCH", "CAL_EASTER_DEFAULT", "CAL_EASTER_ROMAN",\n
"CAL_EASTER_ALWAYS_GREGORIAN", "CAL_EASTER_ALWAYS_JULIAN",\n
"CAL_JEWISH_ADD_ALAFIM_GERESH", "CAL_JEWISH_ADD_ALAFIM",\n
"CAL_JEWISH_ADD_GERESHAYIM", "CLSCTX_INPROC_SERVER", "CLSCTX_INPROC_HANDLER",\n
"CLSCTX_LOCAL_SERVER", "CLSCTX_REMOTE_SERVER", "CLSCTX_SERVER", "CLSCTX_ALL",\n
"VT_NULL", "VT_EMPTY", "VT_UI1", "VT_I1", "VT_UI2", "VT_I2", "VT_UI4", "VT_I4",\n
"VT_R4", "VT_R8", "VT_BOOL", "VT_ERROR", "VT_CY", "VT_DATE", "VT_BSTR",\n
"VT_DECIMAL", "VT_UNKNOWN", "VT_DISPATCH", "VT_VARIANT", "VT_INT", "VT_UINT",\n
"VT_ARRAY", "VT_BYREF", "CP_ACP", "CP_MACCP", "CP_OEMCP", "CP_UTF7", "CP_UTF8",\n
"CP_SYMBOL", "CP_THREAD_ACP", "VARCMP_LT", "VARCMP_EQ", "VARCMP_GT",\n
"VARCMP_NULL", "NORM_IGNORECASE", "NORM_IGNORENONSPACE", "NORM_IGNORESYMBOLS",\n
"NORM_IGNOREWIDTH", "NORM_IGNOREKANATYPE", "DISP_E_DIVBYZERO",\n
"DISP_E_OVERFLOW", "DISP_E_BADINDEX", "MK_E_UNAVAILABLE", "INPUT_POST",\n
"INPUT_GET", "INPUT_COOKIE", "INPUT_ENV", "INPUT_SERVER", "INPUT_SESSION",\n
"INPUT_REQUEST", "FILTER_FLAG_NONE", "FILTER_REQUIRE_SCALAR",\n
"FILTER_REQUIRE_ARRAY", "FILTER_FORCE_ARRAY", "FILTER_NULL_ON_FAILURE",\n
"FILTER_VALIDATE_INT", "FILTER_VALIDATE_BOOLEAN", "FILTER_VALIDATE_FLOAT",\n
"FILTER_VALIDATE_REGEXP", "FILTER_VALIDATE_URL", "FILTER_VALIDATE_EMAIL",\n
"FILTER_VALIDATE_IP", "FILTER_DEFAULT", "FILTER_UNSAFE_RAW",\n
"FILTER_SANITIZE_STRING", "FILTER_SANITIZE_STRIPPED",\n
"FILTER_SANITIZE_ENCODED", "FILTER_SANITIZE_SPECIAL_CHARS",\n
"FILTER_SANITIZE_EMAIL", "FILTER_SANITIZE_URL", "FILTER_SANITIZE_NUMBER_INT",\n
"FILTER_SANITIZE_NUMBER_FLOAT", "FILTER_SANITIZE_MAGIC_QUOTES",\n
"FILTER_CALLBACK", "FILTER_FLAG_ALLOW_OCTAL", "FILTER_FLAG_ALLOW_HEX",\n
"FILTER_FLAG_STRIP_LOW", "FILTER_FLAG_STRIP_HIGH", "FILTER_FLAG_ENCODE_LOW",\n
"FILTER_FLAG_ENCODE_HIGH", "FILTER_FLAG_ENCODE_AMP",\n
"FILTER_FLAG_NO_ENCODE_QUOTES", "FILTER_FLAG_EMPTY_STRING_NULL",\n
"FILTER_FLAG_ALLOW_FRACTION", "FILTER_FLAG_ALLOW_THOUSAND",\n
"FILTER_FLAG_ALLOW_SCIENTIFIC", "FILTER_FLAG_SCHEME_REQUIRED",\n
"FILTER_FLAG_HOST_REQUIRED", "FILTER_FLAG_PATH_REQUIRED",\n
"FILTER_FLAG_QUERY_REQUIRED", "FILTER_FLAG_IPV4", "FILTER_FLAG_IPV6",\n
"FILTER_FLAG_NO_RES_RANGE", "FILTER_FLAG_NO_PRIV_RANGE", "FTP_ASCII",\n
"FTP_TEXT", "FTP_BINARY", "FTP_IMAGE", "FTP_AUTORESUME", "FTP_TIMEOUT_SEC",\n
"FTP_AUTOSEEK", "FTP_FAILED", "FTP_FINISHED", "FTP_MOREDATA", "HASH_HMAC",\n
"ICONV_IMPL", "ICONV_VERSION", "ICONV_MIME_DECODE_STRICT",\n
"ICONV_MIME_DECODE_CONTINUE_ON_ERROR", "ODBC_TYPE", "ODBC_BINMODE_PASSTHRU",\n
"ODBC_BINMODE_RETURN", "ODBC_BINMODE_CONVERT", "SQL_ODBC_CURSORS",\n
"SQL_CUR_USE_DRIVER", "SQL_CUR_USE_IF_NEEDED", "SQL_CUR_USE_ODBC",\n
"SQL_CONCURRENCY", "SQL_CONCUR_READ_ONLY", "SQL_CONCUR_LOCK",\n
"SQL_CONCUR_ROWVER", "SQL_CONCUR_VALUES", "SQL_CURSOR_TYPE",\n
"SQL_CURSOR_FORWARD_ONLY", "SQL_CURSOR_KEYSET_DRIVEN", "SQL_CURSOR_DYNAMIC",\n
"SQL_CURSOR_STATIC", "SQL_KEYSET_SIZE", "SQL_FETCH_FIRST", "SQL_FETCH_NEXT",\n
"SQL_CHAR", "SQL_VARCHAR", "SQL_LONGVARCHAR", "SQL_DECIMAL", "SQL_NUMERIC",\n
"SQL_BIT", "SQL_TINYINT", "SQL_SMALLINT", "SQL_INTEGER", "SQL_BIGINT",\n
"SQL_REAL", "SQL_FLOAT", "SQL_DOUBLE", "SQL_BINARY", "SQL_VARBINARY",\n
"SQL_LONGVARBINARY", "SQL_DATE", "SQL_TIME", "SQL_TIMESTAMP",\n
"PREG_PATTERN_ORDER", "PREG_SET_ORDER", "PREG_OFFSET_CAPTURE",\n
"PREG_SPLIT_NO_EMPTY", "PREG_SPLIT_DELIM_CAPTURE", "PREG_SPLIT_OFFSET_CAPTURE",\n
"PREG_GREP_INVERT", "PREG_NO_ERROR", "PREG_INTERNAL_ERROR",\n
"PREG_BACKTRACK_LIMIT_ERROR", "PREG_RECURSION_LIMIT_ERROR",\n
"PREG_BAD_UTF8_ERROR", "DATE_ATOM", "DATE_COOKIE", "DATE_ISO8601",\n
"DATE_RFC822", "DATE_RFC850", "DATE_RFC1036", "DATE_RFC1123", "DATE_RFC2822",\n
"DATE_RFC3339", "DATE_RSS", "DATE_W3C", "SUNFUNCS_RET_TIMESTAMP",\n
"SUNFUNCS_RET_STRING", "SUNFUNCS_RET_DOUBLE", "LIBXML_VERSION",\n
"LIBXML_DOTTED_VERSION", "LIBXML_NOENT", "LIBXML_DTDLOAD", "LIBXML_DTDATTR",\n
"LIBXML_DTDVALID", "LIBXML_NOERROR", "LIBXML_NOWARNING", "LIBXML_NOBLANKS",\n
"LIBXML_XINCLUDE", "LIBXML_NSCLEAN", "LIBXML_NOCDATA", "LIBXML_NONET",\n
"LIBXML_COMPACT", "LIBXML_NOXMLDECL", "LIBXML_NOEMPTYTAG", "LIBXML_ERR_NONE",\n
"LIBXML_ERR_WARNING", "LIBXML_ERR_ERROR", "LIBXML_ERR_FATAL",\n
"CONNECTION_ABORTED", "CONNECTION_NORMAL", "CONNECTION_TIMEOUT", "INI_USER",\n
"INI_PERDIR", "INI_SYSTEM", "INI_ALL", "PHP_URL_SCHEME", "PHP_URL_HOST",\n
"PHP_URL_PORT", "PHP_URL_USER", "PHP_URL_PASS", "PHP_URL_PATH",\n
"PHP_URL_QUERY", "PHP_URL_FRAGMENT", "M_E", "M_LOG2E", "M_LOG10E", "M_LN2",\n
"M_LN10", "M_PI", "M_PI_2", "M_PI_4", "M_1_PI", "M_2_PI", "M_SQRTPI",\n
"M_2_SQRTPI", "M_LNPI", "M_EULER", "M_SQRT2", "M_SQRT1_2", "M_SQRT3", "INF",\n
"NAN", "INFO_GENERAL", "INFO_CREDITS", "INFO_CONFIGURATION", "INFO_MODULES",\n
"INFO_ENVIRONMENT", "INFO_VARIABLES", "INFO_LICENSE", "INFO_ALL",\n
"CREDITS_GROUP", "CREDITS_GENERAL", "CREDITS_SAPI", "CREDITS_MODULES",\n
"CREDITS_DOCS", "CREDITS_FULLPAGE", "CREDITS_QA", "CREDITS_ALL",\n
"HTML_SPECIALCHARS", "HTML_ENTITIES", "ENT_COMPAT", "ENT_QUOTES",\n
"ENT_NOQUOTES", "STR_PAD_LEFT", "STR_PAD_RIGHT", "STR_PAD_BOTH",\n
"PATHINFO_DIRNAME", "PATHINFO_BASENAME", "PATHINFO_EXTENSION",\n
"PATHINFO_FILENAME", "CHAR_MAX", "LC_CTYPE", "LC_NUMERIC", "LC_TIME",\n
"LC_COLLATE", "LC_MONETARY", "LC_ALL", "SEEK_SET", "SEEK_CUR", "SEEK_END",\n
"LOCK_SH", "LOCK_EX", "LOCK_UN", "LOCK_NB", "STREAM_NOTIFY_CONNECT",\n
"STREAM_NOTIFY_AUTH_REQUIRED", "STREAM_NOTIFY_AUTH_RESULT",\n
"STREAM_NOTIFY_MIME_TYPE_IS", "STREAM_NOTIFY_FILE_SIZE_IS",\n
"STREAM_NOTIFY_REDIRECTED", "STREAM_NOTIFY_PROGRESS", "STREAM_NOTIFY_FAILURE",\n
"STREAM_NOTIFY_COMPLETED", "STREAM_NOTIFY_RESOLVE",\n
"STREAM_NOTIFY_SEVERITY_INFO", "STREAM_NOTIFY_SEVERITY_WARN",\n
"STREAM_NOTIFY_SEVERITY_ERR", "STREAM_FILTER_READ", "STREAM_FILTER_WRITE",\n
"STREAM_FILTER_ALL", "STREAM_CLIENT_PERSISTENT", "STREAM_CLIENT_ASYNC_CONNECT",\n
"STREAM_CLIENT_CONNECT", "STREAM_CRYPTO_METHOD_SSLv2_CLIENT",\n
"STREAM_CRYPTO_METHOD_SSLv3_CLIENT", "STREAM_CRYPTO_METHOD_SSLv23_CLIENT",\n
"STREAM_CRYPTO_METHOD_TLS_CLIENT", "STREAM_CRYPTO_METHOD_SSLv2_SERVER",\n
"STREAM_CRYPTO_METHOD_SSLv3_SERVER", "STREAM_CRYPTO_METHOD_SSLv23_SERVER",\n
"STREAM_CRYPTO_METHOD_TLS_SERVER", "STREAM_SHUT_RD", "STREAM_SHUT_WR",\n
"STREAM_SHUT_RDWR", "STREAM_PF_INET", "STREAM_PF_INET6", "STREAM_PF_UNIX",\n
"STREAM_IPPROTO_IP", "STREAM_IPPROTO_TCP", "STREAM_IPPROTO_UDP",\n
"STREAM_IPPROTO_ICMP", "STREAM_IPPROTO_RAW", "STREAM_SOCK_STREAM",\n
"STREAM_SOCK_DGRAM", "STREAM_SOCK_RAW", "STREAM_SOCK_SEQPACKET",\n
"STREAM_SOCK_RDM", "STREAM_PEEK", "STREAM_OOB", "STREAM_SERVER_BIND",\n
"STREAM_SERVER_LISTEN", "FILE_USE_INCLUDE_PATH", "FILE_IGNORE_NEW_LINES",\n
"FILE_SKIP_EMPTY_LINES", "FILE_APPEND", "FILE_NO_DEFAULT_CONTEXT",\n
"PSFS_PASS_ON", "PSFS_FEED_ME", "PSFS_ERR_FATAL", "PSFS_FLAG_NORMAL",\n
"PSFS_FLAG_FLUSH_INC", "PSFS_FLAG_FLUSH_CLOSE", "CRYPT_SALT_LENGTH",\n
"CRYPT_STD_DES", "CRYPT_EXT_DES", "CRYPT_MD5", "CRYPT_BLOWFISH",\n
"DIRECTORY_SEPARATOR", "PATH_SEPARATOR", "GLOB_BRACE", "GLOB_MARK",\n
"GLOB_NOSORT", "GLOB_NOCHECK", "GLOB_NOESCAPE", "GLOB_ERR", "GLOB_ONLYDIR",\n
"LOG_EMERG", "LOG_ALERT", "LOG_CRIT", "LOG_ERR", "LOG_WARNING", "LOG_NOTICE",\n
"LOG_INFO", "LOG_DEBUG", "LOG_KERN", "LOG_USER", "LOG_MAIL", "LOG_DAEMON",\n
"LOG_AUTH", "LOG_SYSLOG", "LOG_LPR", "LOG_NEWS", "LOG_UUCP", "LOG_CRON",\n
"LOG_AUTHPRIV", "LOG_PID", "LOG_CONS", "LOG_ODELAY", "LOG_NDELAY",\n
"LOG_NOWAIT", "LOG_PERROR", "EXTR_OVERWRITE", "EXTR_SKIP", "EXTR_PREFIX_SAME",\n
"EXTR_PREFIX_ALL", "EXTR_PREFIX_INVALID", "EXTR_PREFIX_IF_EXISTS",\n
"EXTR_IF_EXISTS", "EXTR_REFS", "SORT_ASC", "SORT_DESC", "SORT_REGULAR",\n
"SORT_NUMERIC", "SORT_STRING", "SORT_LOCALE_STRING", "CASE_LOWER",\n
"CASE_UPPER", "COUNT_NORMAL", "COUNT_RECURSIVE", "ASSERT_ACTIVE",\n
"ASSERT_CALLBACK", "ASSERT_BAIL", "ASSERT_WARNING", "ASSERT_QUIET_EVAL",\n
"STREAM_USE_PATH", "STREAM_IGNORE_URL", "STREAM_ENFORCE_SAFE_MODE",\n
"STREAM_REPORT_ERRORS", "STREAM_MUST_SEEK", "STREAM_URL_STAT_LINK",\n
"STREAM_URL_STAT_QUIET", "STREAM_MKDIR_RECURSIVE", "IMAGETYPE_GIF",\n
"IMAGETYPE_JPEG", "IMAGETYPE_PNG", "IMAGETYPE_SWF", "IMAGETYPE_PSD",\n
"IMAGETYPE_BMP", "IMAGETYPE_TIFF_II", "IMAGETYPE_TIFF_MM", "IMAGETYPE_JPC",\n
"IMAGETYPE_JP2", "IMAGETYPE_JPX", "IMAGETYPE_JB2", "IMAGETYPE_SWC",\n
"IMAGETYPE_IFF", "IMAGETYPE_WBMP", "IMAGETYPE_JPEG2000", "IMAGETYPE_XBM",\n
"T_INCLUDE", "T_INCLUDE_ONCE", "T_EVAL", "T_REQUIRE", "T_REQUIRE_ONCE",\n
"T_LOGICAL_OR", "T_LOGICAL_XOR", "T_LOGICAL_AND", "T_PRINT", "T_PLUS_EQUAL",\n
"T_MINUS_EQUAL", "T_MUL_EQUAL", "T_DIV_EQUAL", "T_CONCAT_EQUAL", "T_MOD_EQUAL",\n
"T_AND_EQUAL", "T_OR_EQUAL", "T_XOR_EQUAL", "T_SL_EQUAL", "T_SR_EQUAL",\n
"T_BOOLEAN_OR", "T_BOOLEAN_AND", "T_IS_EQUAL", "T_IS_NOT_EQUAL",\n
"T_IS_IDENTICAL", "T_IS_NOT_IDENTICAL", "T_IS_SMALLER_OR_EQUAL",\n
"T_IS_GREATER_OR_EQUAL", "T_SL", "T_SR", "T_INC", "T_DEC", "T_INT_CAST",\n
"T_DOUBLE_CAST", "T_STRING_CAST", "T_ARRAY_CAST", "T_OBJECT_CAST",\n
"T_BOOL_CAST", "T_UNSET_CAST", "T_NEW", "T_EXIT", "T_IF", "T_ELSEIF", "T_ELSE",\n
"T_ENDIF", "T_LNUMBER", "T_DNUMBER", "T_STRING", "T_STRING_VARNAME",\n
"T_VARIABLE", "T_NUM_STRING", "T_INLINE_HTML", "T_CHARACTER",\n
"T_BAD_CHARACTER", "T_ENCAPSED_AND_WHITESPACE", "T_CONSTANT_ENCAPSED_STRING",\n
"T_ECHO", "T_DO", "T_WHILE", "T_ENDWHILE", "T_FOR", "T_ENDFOR", "T_FOREACH",\n
"T_ENDFOREACH", "T_DECLARE", "T_ENDDECLARE", "T_AS", "T_SWITCH", "T_ENDSWITCH",\n
"T_CASE", "T_DEFAULT", "T_BREAK", "T_CONTINUE", "T_FUNCTION", "T_CONST",\n
"T_RETURN", "T_USE", "T_GLOBAL", "T_STATIC", "T_VAR", "T_UNSET", "T_ISSET",\n
"T_EMPTY", "T_CLASS", "T_EXTENDS", "T_INTERFACE", "T_IMPLEMENTS",\n
"T_OBJECT_OPERATOR", "T_DOUBLE_ARROW", "T_LIST", "T_ARRAY", "T_CLASS_C",\n
"T_FUNC_C", "T_METHOD_C", "T_LINE", "T_FILE", "T_COMMENT", "T_DOC_COMMENT",\n
"T_OPEN_TAG", "T_OPEN_TAG_WITH_ECHO", "T_CLOSE_TAG", "T_WHITESPACE",\n
"T_START_HEREDOC", "T_END_HEREDOC", "T_DOLLAR_OPEN_CURLY_BRACES",\n
"T_CURLY_OPEN", "T_PAAMAYIM_NEKUDOTAYIM", "T_DOUBLE_COLON", "T_ABSTRACT",\n
"T_CATCH", "T_FINAL", "T_INSTANCEOF", "T_PRIVATE", "T_PROTECTED", "T_PUBLIC",\n
"T_THROW", "T_TRY", "T_CLONE", "T_HALT_COMPILER", "FORCE_GZIP",\n
"FORCE_DEFLATE", "XML_ELEMENT_NODE", "XML_ATTRIBUTE_NODE", "XML_TEXT_NODE",\n
"XML_CDATA_SECTION_NODE", "XML_ENTITY_REF_NODE", "XML_ENTITY_NODE",\n
"XML_PI_NODE", "XML_COMMENT_NODE", "XML_DOCUMENT_NODE",\n
"XML_DOCUMENT_TYPE_NODE", "XML_DOCUMENT_FRAG_NODE", "XML_NOTATION_NODE",\n
"XML_HTML_DOCUMENT_NODE", "XML_DTD_NODE", "XML_ELEMENT_DECL_NODE",\n
"XML_ATTRIBUTE_DECL_NODE", "XML_ENTITY_DECL_NODE", "XML_NAMESPACE_DECL_NODE",\n
"XML_LOCAL_NAMESPACE", "XML_ATTRIBUTE_CDATA", "XML_ATTRIBUTE_ID",\n
"XML_ATTRIBUTE_IDREF", "XML_ATTRIBUTE_IDREFS", "XML_ATTRIBUTE_ENTITY",\n
"XML_ATTRIBUTE_NMTOKEN", "XML_ATTRIBUTE_NMTOKENS", "XML_ATTRIBUTE_ENUMERATION",\n
"XML_ATTRIBUTE_NOTATION", "DOM_PHP_ERR", "DOM_INDEX_SIZE_ERR",\n
"DOMSTRING_SIZE_ERR", "DOM_HIERARCHY_REQUEST_ERR", "DOM_WRONG_DOCUMENT_ERR",\n
"DOM_INVALID_CHARACTER_ERR", "DOM_NO_DATA_ALLOWED_ERR",\n
"DOM_NO_MODIFICATION_ALLOWED_ERR", "DOM_NOT_FOUND_ERR",\n
"DOM_NOT_SUPPORTED_ERR", "DOM_INUSE_ATTRIBUTE_ERR", "DOM_INVALID_STATE_ERR",\n
"DOM_SYNTAX_ERR", "DOM_INVALID_MODIFICATION_ERR", "DOM_NAMESPACE_ERR",\n
"DOM_INVALID_ACCESS_ERR", "DOM_VALIDATION_ERR", "XML_ERROR_NONE",\n
"XML_ERROR_NO_MEMORY", "XML_ERROR_SYNTAX", "XML_ERROR_NO_ELEMENTS",\n
"XML_ERROR_INVALID_TOKEN", "XML_ERROR_UNCLOSED_TOKEN",\n
"XML_ERROR_PARTIAL_CHAR", "XML_ERROR_TAG_MISMATCH",\n
"XML_ERROR_DUPLICATE_ATTRIBUTE", "XML_ERROR_JUNK_AFTER_DOC_ELEMENT",\n
"XML_ERROR_PARAM_ENTITY_REF", "XML_ERROR_UNDEFINED_ENTITY",\n
"XML_ERROR_RECURSIVE_ENTITY_REF", "XML_ERROR_ASYNC_ENTITY",\n
"XML_ERROR_BAD_CHAR_REF", "XML_ERROR_BINARY_ENTITY_REF",\n
"XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF", "XML_ERROR_MISPLACED_XML_PI",\n
"XML_ERROR_UNKNOWN_ENCODING", "XML_ERROR_INCORRECT_ENCODING",\n
"XML_ERROR_UNCLOSED_CDATA_SECTION", "XML_ERROR_EXTERNAL_ENTITY_HANDLING",\n
"XML_OPTION_CASE_FOLDING", "XML_OPTION_TARGET_ENCODING",\n
"XML_OPTION_SKIP_TAGSTART", "XML_OPTION_SKIP_WHITE", "XML_SAX_IMPL", "IMG_GIF",\n
"IMG_JPG", "IMG_JPEG", "IMG_PNG", "IMG_WBMP", "IMG_XPM", "IMG_COLOR_TILED",\n
"IMG_COLOR_STYLED", "IMG_COLOR_BRUSHED", "IMG_COLOR_STYLEDBRUSHED",\n
"IMG_COLOR_TRANSPARENT", "IMG_ARC_ROUNDED", "IMG_ARC_PIE", "IMG_ARC_CHORD",\n
"IMG_ARC_NOFILL", "IMG_ARC_EDGED", "IMG_GD2_RAW", "IMG_GD2_COMPRESSED",\n
"IMG_EFFECT_REPLACE", "IMG_EFFECT_ALPHABLEND", "IMG_EFFECT_NORMAL",\n
"IMG_EFFECT_OVERLAY", "GD_BUNDLED", "IMG_FILTER_NEGATE",\n
"IMG_FILTER_GRAYSCALE", "IMG_FILTER_BRIGHTNESS", "IMG_FILTER_CONTRAST",\n
"IMG_FILTER_COLORIZE", "IMG_FILTER_EDGEDETECT", "IMG_FILTER_GAUSSIAN_BLUR",\n
"IMG_FILTER_SELECTIVE_BLUR", "IMG_FILTER_EMBOSS", "IMG_FILTER_MEAN_REMOVAL",\n
"IMG_FILTER_SMOOTH", "PNG_NO_FILTER", "PNG_FILTER_NONE", "PNG_FILTER_SUB",\n
"PNG_FILTER_UP", "PNG_FILTER_AVG", "PNG_FILTER_PAETH", "PNG_ALL_FILTERS",\n
"MB_OVERLOAD_MAIL", "MB_OVERLOAD_STRING", "MB_OVERLOAD_REGEX", "MB_CASE_UPPER",\n
"MB_CASE_LOWER", "MB_CASE_TITLE", "MYSQL_ASSOC", "MYSQL_NUM", "MYSQL_BOTH",\n
"MYSQL_CLIENT_COMPRESS", "MYSQL_CLIENT_SSL", "MYSQL_CLIENT_INTERACTIVE",\n
"MYSQL_CLIENT_IGNORE_SPACE", "MYSQLI_READ_DEFAULT_GROUP",\n
"MYSQLI_READ_DEFAULT_FILE", "MYSQLI_OPT_CONNECT_TIMEOUT",\n
"MYSQLI_OPT_LOCAL_INFILE", "MYSQLI_INIT_COMMAND", "MYSQLI_CLIENT_SSL",\n
"MYSQLI_CLIENT_COMPRESS", "MYSQLI_CLIENT_INTERACTIVE",\n
"MYSQLI_CLIENT_IGNORE_SPACE", "MYSQLI_CLIENT_NO_SCHEMA",\n
"MYSQLI_CLIENT_FOUND_ROWS", "MYSQLI_STORE_RESULT", "MYSQLI_USE_RESULT",\n
"MYSQLI_ASSOC", "MYSQLI_NUM", "MYSQLI_BOTH",\n
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH", "MYSQLI_STMT_ATTR_CURSOR_TYPE",\n
"MYSQLI_CURSOR_TYPE_NO_CURSOR", "MYSQLI_CURSOR_TYPE_READ_ONLY",\n
"MYSQLI_CURSOR_TYPE_FOR_UPDATE", "MYSQLI_CURSOR_TYPE_SCROLLABLE",\n
"MYSQLI_STMT_ATTR_PREFETCH_ROWS", "MYSQLI_NOT_NULL_FLAG",\n
"MYSQLI_PRI_KEY_FLAG", "MYSQLI_UNIQUE_KEY_FLAG", "MYSQLI_MULTIPLE_KEY_FLAG",\n
"MYSQLI_BLOB_FLAG", "MYSQLI_UNSIGNED_FLAG", "MYSQLI_ZEROFILL_FLAG",\n
"MYSQLI_AUTO_INCREMENT_FLAG", "MYSQLI_TIMESTAMP_FLAG", "MYSQLI_SET_FLAG",\n
"MYSQLI_NUM_FLAG", "MYSQLI_PART_KEY_FLAG", "MYSQLI_GROUP_FLAG",\n
"MYSQLI_TYPE_DECIMAL", "MYSQLI_TYPE_TINY", "MYSQLI_TYPE_SHORT",\n
"MYSQLI_TYPE_LONG", "MYSQLI_TYPE_FLOAT", "MYSQLI_TYPE_DOUBLE",\n
"MYSQLI_TYPE_NULL", "MYSQLI_TYPE_TIMESTAMP", "MYSQLI_TYPE_LONGLONG",\n
"MYSQLI_TYPE_INT24", "MYSQLI_TYPE_DATE", "MYSQLI_TYPE_TIME",\n
"MYSQLI_TYPE_DATETIME", "MYSQLI_TYPE_YEAR", "MYSQLI_TYPE_NEWDATE",\n
"MYSQLI_TYPE_ENUM", "MYSQLI_TYPE_SET", "MYSQLI_TYPE_TINY_BLOB",\n
"MYSQLI_TYPE_MEDIUM_BLOB", "MYSQLI_TYPE_LONG_BLOB", "MYSQLI_TYPE_BLOB",\n
"MYSQLI_TYPE_VAR_STRING", "MYSQLI_TYPE_STRING", "MYSQLI_TYPE_CHAR",\n
"MYSQLI_TYPE_INTERVAL", "MYSQLI_TYPE_GEOMETRY", "MYSQLI_TYPE_NEWDECIMAL",\n
"MYSQLI_TYPE_BIT", "MYSQLI_RPL_MASTER", "MYSQLI_RPL_SLAVE", "MYSQLI_RPL_ADMIN",\n
"MYSQLI_NO_DATA", "MYSQLI_DATA_TRUNCATED", "MYSQLI_REPORT_INDEX",\n
"MYSQLI_REPORT_ERROR", "MYSQLI_REPORT_STRICT", "MYSQLI_REPORT_ALL",\n
"MYSQLI_REPORT_OFF", "AF_UNIX", "AF_INET", "AF_INET6", "SOCK_STREAM",\n
"SOCK_DGRAM", "SOCK_RAW", "SOCK_SEQPACKET", "SOCK_RDM", "MSG_OOB",\n
"MSG_WAITALL", "MSG_PEEK", "MSG_DONTROUTE", "SO_DEBUG", "SO_REUSEADDR",\n
"SO_KEEPALIVE", "SO_DONTROUTE", "SO_LINGER", "SO_BROADCAST", "SO_OOBINLINE",\n
"SO_SNDBUF", "SO_RCVBUF", "SO_SNDLOWAT", "SO_RCVLOWAT", "SO_SNDTIMEO",\n
"SO_RCVTIMEO", "SO_TYPE", "SO_ERROR", "SOL_SOCKET", "SOMAXCONN",\n
"PHP_NORMAL_READ", "PHP_BINARY_READ", "SOCKET_EINTR", "SOCKET_EBADF",\n
"SOCKET_EACCES", "SOCKET_EFAULT", "SOCKET_EINVAL", "SOCKET_EMFILE",\n
"SOCKET_EWOULDBLOCK", "SOCKET_EINPROGRESS", "SOCKET_EALREADY",\n
"SOCKET_ENOTSOCK", "SOCKET_EDESTADDRREQ", "SOCKET_EMSGSIZE",\n
"SOCKET_EPROTOTYPE", "SOCKET_ENOPROTOOPT", "SOCKET_EPROTONOSUPPORT",\n
"SOCKET_ESOCKTNOSUPPORT", "SOCKET_EOPNOTSUPP", "SOCKET_EPFNOSUPPORT",\n
"SOCKET_EAFNOSUPPORT", "SOCKET_EADDRINUSE", "SOCKET_EADDRNOTAVAIL",\n
"SOCKET_ENETDOWN", "SOCKET_ENETUNREACH", "SOCKET_ENETRESET",\n
"SOCKET_ECONNABORTED", "SOCKET_ECONNRESET", "SOCKET_ENOBUFS", "SOCKET_EISCONN",\n
"SOCKET_ENOTCONN", "SOCKET_ESHUTDOWN", "SOCKET_ETOOMANYREFS",\n
"SOCKET_ETIMEDOUT", "SOCKET_ECONNREFUSED", "SOCKET_ELOOP",\n
"SOCKET_ENAMETOOLONG", "SOCKET_EHOSTDOWN", "SOCKET_EHOSTUNREACH",\n
"SOCKET_ENOTEMPTY", "SOCKET_EPROCLIM", "SOCKET_EUSERS", "SOCKET_EDQUOT",\n
"SOCKET_ESTALE", "SOCKET_EREMOTE", "SOCKET_EDISCON", "SOCKET_SYSNOTREADY",\n
"SOCKET_VERNOTSUPPORTED", "SOCKET_NOTINITIALISED", "SOCKET_HOST_NOT_FOUND",\n
"SOCKET_TRY_AGAIN", "SOCKET_NO_RECOVERY", "SOCKET_NO_DATA",\n
"SOCKET_NO_ADDRESS", "SOL_TCP", "SOL_UDP", "EACCELERATOR_VERSION",\n
"EACCELERATOR_SHM_AND_DISK", "EACCELERATOR_SHM", "EACCELERATOR_SHM_ONLY",\n
"EACCELERATOR_DISK_ONLY", "EACCELERATOR_NONE", "XDEBUG_TRACE_APPEND",\n
"XDEBUG_TRACE_COMPUTERIZED", "XDEBUG_TRACE_HTML", "XDEBUG_CC_UNUSED",\n
"XDEBUG_CC_DEAD_CODE", "STDIN", "STDOUT", "STDERR"\n
].forEach(function(element, index, array) {\n
result[element] = token("atom", "php-predefined-constant");\n
});\n
\n
// PHP declared classes - output of get_declared_classes(). Differs from http://php.net/manual/en/reserved.classes.php\n
[ "stdClass", "Exception", "ErrorException", "COMPersistHelper", "com_exception",\n
"com_safearray_proxy", "variant", "com", "dotnet", "ReflectionException",\n
"Reflection", "ReflectionFunctionAbstract", "ReflectionFunction",\n
"ReflectionParameter", "ReflectionMethod", "ReflectionClass",\n
"ReflectionObject", "ReflectionProperty", "ReflectionExtension", "DateTime",\n
"DateTimeZone", "LibXMLError", "__PHP_Incomplete_Class", "php_user_filter",\n
"Directory", "SimpleXMLElement", "DOMException", "DOMStringList",\n
"DOMNameList", "DOMImplementationList", "DOMImplementationSource",\n
"DOMImplementation", "DOMNode", "DOMNameSpaceNode", "DOMDocumentFragment",\n
"DOMDocument", "DOMNodeList", "DOMNamedNodeMap", "DOMCharacterData", "DOMAttr",\n
"DOMElement", "DOMText", "DOMComment", "DOMTypeinfo", "DOMUserDataHandler",\n
"DOMDomError", "DOMErrorHandler", "DOMLocator", "DOMConfiguration",\n
"DOMCdataSection", "DOMDocumentType", "DOMNotation", "DOMEntity",\n
"DOMEntityReference", "DOMProcessingInstruction", "DOMStringExtend",\n
"DOMXPath", "RecursiveIteratorIterator", "IteratorIterator", "FilterIterator",\n
"RecursiveFilterIterator", "ParentIterator", "LimitIterator",\n
"CachingIterator", "RecursiveCachingIterator", "NoRewindIterator",\n
"AppendIterator", "InfiniteIterator", "RegexIterator",\n
"RecursiveRegexIterator", "EmptyIterator", "ArrayObject", "ArrayIterator",\n
"RecursiveArrayIterator", "SplFileInfo", "DirectoryIterator",\n
"RecursiveDirectoryIterator", "SplFileObject", "SplTempFileObject",\n
"SimpleXMLIterator", "LogicException", "BadFunctionCallException",\n
"BadMethodCallException", "DomainException", "InvalidArgumentException",\n
"LengthException", "OutOfRangeException", "RuntimeException",\n
"OutOfBoundsException", "OverflowException", "RangeException",\n
"UnderflowException", "UnexpectedValueException", "SplObjectStorage",\n
"XMLReader", "XMLWriter", "mysqli_sql_exception", "mysqli_driver", "mysqli",\n
"mysqli_warning", "mysqli_result", "mysqli_stmt", "PDOException", "PDO",\n
"PDOStatement", "PDORow"\n
].forEach(function(element, index, array) {\n
result[element] = token("t_string", "php-predefined-class");\n
});\n
\n
return result;\n
\n
}();\n
\n
// Helper regexps\n
var isOperatorChar = /[+*&%\\/=<>!?.|-]/;\n
var isHexDigit = /[0-9A-Fa-f]/;\n
var isWordChar = /[\\w\\$_\\\\]/;\n
\n
// Wrapper around phpToken that helps maintain parser state (whether\n
// we are inside of a multi-line comment)\n
function phpTokenState(inside) {\n
return function(source, setState) {\n
var newInside = inside;\n
var type = phpToken(inside, source, function(c) {newInside = c;});\n
if (newInside != inside)\n
setState(phpTokenState(newInside));\n
return type;\n
};\n
}\n
\n
// The token reader, inteded to be used by the tokenizer from\n
// tokenize.js (through phpTokenState). Advances the source stream\n
// over a token, and returns an object containing the type and style\n
// of that token.\n
function phpToken(inside, source, setInside) {\n
function readHexNumber(){\n
source.next(); // skip the \'x\'\n
source.nextWhileMatches(isHexDigit);\n
return {type: "number", style: "php-atom"};\n
}\n
\n
function readNumber() {\n
source.nextWhileMatches(/[0-9]/);\n
if (source.equals(".")){\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
if (source.equals("e") || source.equals("E")){\n
source.next();\n
if (source.equals("-"))\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
return {type: "number", style: "php-atom"};\n
}\n
// Read a word and look it up in the keywords array. If found, it\'s a\n
// keyword of that type; otherwise it\'s a PHP T_STRING.\n
function readWord() {\n
source.nextWhileMatches(isWordChar);\n
var word = source.get();\n
var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];\n
// since we called get(), tokenize::take won\'t get() anything. Thus, we must set token.content\n
return known ? {type: known.type, style: known.style, content: word} :\n
{type: "t_string", style: "php-t_string", content: word};\n
}\n
function readVariable() {\n
source.nextWhileMatches(isWordChar);\n
var word = source.get();\n
// in PHP, \'$this\' is a reserved word, but \'this\' isn\'t. You can have function this() {...}\n
if (word == "$this")\n
return {type: "variable", style: "php-keyword", content: word};\n
else\n
return {type: "variable", style: "php-variable", content: word};\n
}\n
\n
// Advance the stream until the given character (not preceded by a\n
// backslash) is encountered, or the end of the line is reached.\n
function nextUntilUnescaped(source, end) {\n
var escaped = false;\n
while(!source.endOfLine()){\n
var next = source.next();\n
if (next == end && !escaped)\n
return false;\n
escaped = next == "\\\\" && !escaped;\n
}\n
return escaped;\n
}\n
\n
function readSingleLineComment() {\n
// read until the end of the line or until ?>, which terminates single-line comments\n
// `<?php echo 1; // comment ?> foo` will display "1 foo"\n
while(!source.lookAhead("?>") && !source.endOfLine())\n
source.next();\n
return {type: "comment", style: "php-comment"};\n
}\n
/* For multi-line comments, we want to return a comment token for\n
every line of the comment, but we also want to return the newlines\n
in them as regular newline tokens. We therefore need to save a\n
state variable ("inside") to indicate whether we are inside a\n
multi-line comment.\n
*/\n
\n
function readMultilineComment(start){\n
var newInside = "/*";\n
var maybeEnd = (start == "*");\n
while (true) {\n
if (source.endOfLine())\n
break;\n
var next = source.next();\n
if (next == "/" && maybeEnd){\n
newInside = null;\n
break;\n
}\n
maybeEnd = (next == "*");\n
}\n
setInside(newInside);\n
return {type: "comment", style: "php-comment"};\n
}\n
\n
// similar to readMultilineComment and nextUntilUnescaped\n
// unlike comments, strings are not stopped by ?>\n
function readMultilineString(start){\n
var newInside = start;\n
var escaped = false;\n
while (true) {\n
if (source.endOfLine())\n
break;\n
var next = source.next();\n
if (next == start && !escaped){\n
newInside = null; // we\'re outside of the string now\n
break;\n
}\n
escaped = (next == "\\\\" && !escaped);\n
}\n
setInside(newInside);\n
return {\n
type: newInside == null? "string" : "string_not_terminated",\n
style: (start == "\'"? "php-string-single-quoted" : "php-string-double-quoted")\n
};\n
}\n
\n
// http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc\n
// See also \'nowdoc\' on the page. Heredocs are not interrupted by the \'?>\' token.\n
function readHeredoc(identifier){\n
var token = {};\n
if (identifier == "<<<") {\n
// on our first invocation after reading the <<<, we must determine the closing identifier\n
if (source.equals("\'")) {\n
// nowdoc\n
source.nextWhileMatches(isWordChar);\n
identifier = "\'" + source.get() + "\'";\n
source.next(); // consume the closing "\'"\n
} else if (source.matches(/[A-Za-z_]/)) {\n
// heredoc\n
source.nextWhileMatches(isWordChar);\n
identifier = source.get();\n
} else {\n
// syntax error\n
setInside(null);\n
return { type: "error", style: "syntax-error" };\n
}\n
setInside(identifier);\n
token.type = "string_not_terminated";\n
token.style = identifier.charAt(0) == "\'"? "php-string-single-quoted" : "php-string-double-quoted";\n
token.content = identifier;\n
} else {\n
token.style = identifier.charAt(0) == "\'"? "php-string-single-quoted" : "php-string-double-quoted";\n
// consume a line of heredoc and check if it equals the closing identifier plus an optional semicolon\n
if (source.lookAhead(identifier, true) && (source.lookAhead(";\\n") || source.endOfLine())) {\n
// the closing identifier can only appear at the beginning of the line\n
// note that even whitespace after the ";" is forbidden by the PHP heredoc syntax\n
token.type = "string";\n
token.content = source.get(); // don\'t get the ";" if there is one\n
setInside(null);\n
} else {\n
token.type = "string_not_terminated";\n
source.nextWhileMatches(/[^\\n]/);\n
token.content = source.get();\n
}\n
}\n
return token;\n
}\n
\n
function readOperator() {\n
source.nextWhileMatches(isOperatorChar);\n
return {type: "operator", style: "php-operator"};\n
}\n
function readStringSingleQuoted() {\n
var endBackSlash = nextUntilUnescaped(source, "\'", false);\n
setInside(endBackSlash ? "\'" : null);\n
return {type: "string", style: "php-string-single-quoted"};\n
}\n
function readStringDoubleQuoted() {\n
var endBackSlash = nextUntilUnescaped(source, "\\"", false);\n
setInside(endBackSlash ? "\\"": null);\n
return {type: "string", style: "php-string-double-quoted"};\n
}\n
\n
// Fetch the next token. Dispatches on first character in the\n
// stream, or first two characters when the first is a slash.\n
switch (inside) {\n
case null:\n
case false: break;\n
case "\'":\n
case "\\"": return readMultilineString(inside);\n
case "/*": return readMultilineComment(source.next());\n
default: return readHeredoc(inside);\n
}\n
var ch = source.next();\n
if (ch == "\'" || ch == "\\"")\n
return readMultilineString(ch);\n
else if (ch == "#")\n
return readSingleLineComment();\n
else if (ch == "$")\n
return readVariable();\n
else if (ch == ":" && source.equals(":")) {\n
source.next();\n
// the T_DOUBLE_COLON can only follow a T_STRING (class name)\n
return {type: "t_double_colon", style: "php-operator"}\n
}\n
// with punctuation, the type of the token is the symbol itself\n
else if (/[\\[\\]{}\\(\\),;:]/.test(ch)) {\n
return {type: ch, style: "php-punctuation"};\n
}\n
else if (ch == "0" && (source.equals("x") || source.equals("X")))\n
return readHexNumber();\n
else if (/[0-9]/.test(ch))\n
return readNumber();\n
else if (ch == "/") {\n
if (source.equals("*"))\n
{ source.next(); return readMultilineComment(ch); }\n
else if (source.equals("/"))\n
return readSingleLineComment();\n
else\n
return readOperator();\n
}\n
else if (ch == "<") {\n
if (source.lookAhead("<<", true)) {\n
setInside("<<<");\n
return {type: "<<<", style: "php-punctuation"};\n
}\n
else\n
return readOperator();\n
}\n
else if (isOperatorChar.test(ch))\n
return readOperator();\n
else\n
return readWord();\n
}\n
\n
// The external interface to the tokenizer.\n
return function(source, startState) {\n
return tokenizer(source, startState || phpTokenState(false, true));\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>61238</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>plsql</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.93</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>plsqlcolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.plsql-keyword {\n
color: blue;\n
}\n
\n
span.plsql-var {\n
color: red;\n
}\n
\n
span.plsql-comment {\n
color: #AA7700;\n
}\n
\n
span.plsql-literal {\n
color: green;\n
}\n
\n
span.plsql-operator {\n
color: blue;\n
}\n
\n
span.plsql-word {\n
color: black;\n
}\n
\n
span.plsql-function {\n
color: darkorange;\n
}\n
\n
span.plsql-type {\n
color: purple;\n
}\n
\n
span.plsql-separator {\n
color: #666666;\n
}\n
\n
span.plsql-number {\n
color: darkcyan;\n
}\n
\n
\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>563</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.93</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parseplsql.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
var PlsqlParser = Editor.Parser = (function() {\n
\n
function wordRegexp(words) {\n
return new RegExp("^(?:" + words.join("|") + ")$", "i");\n
}\n
\n
var functions = wordRegexp([\n
"abs","acos","add_months","ascii","asin","atan","atan2","average",\n
"bfilename",\n
"ceil","chartorowid","chr","concat","convert","cos","cosh","count",\n
"decode","deref","dual","dump","dup_val_on_index",\n
"empty","error","exp",\n
"false","floor","found",\n
"glb","greatest",\n
"hextoraw",\n
"initcap","instr","instrb","isopen",\n
"last_day","least","lenght","lenghtb","ln","lower","lpad","ltrim","lub",\n
"make_ref","max","min","mod","months_between",\n
"new_time","next_day","nextval","nls_charset_decl_len","nls_charset_id","nls_charset_name","nls_initcap","nls_lower",\n
"nls_sort","nls_upper","nlssort","no_data_found","notfound","null","nvl",\n
"others",\n
"power",\n
"rawtohex","reftohex","round","rowcount","rowidtochar","rpad","rtrim",\n
"sign","sin","sinh","soundex","sqlcode","sqlerrm","sqrt","stddev","substr","substrb","sum","sysdate",\n
"tan","tanh","to_char","to_date","to_label","to_multi_byte","to_number","to_single_byte","translate","true","trunc",\n
"uid","upper","user","userenv",\n
"variance","vsize"\n
\n
]);\n
\n
var keywords = wordRegexp([\n
"abort","accept","access","add","all","alter","and","any","array","arraylen","as","asc","assert","assign","at","attributes","audit",\n
"authorization","avg",\n
"base_table","begin","between","binary_integer","body","boolean","by",\n
"case","cast","char","char_base","check","close","cluster","clusters","colauth","column","comment","commit","compress","connect",\n
"connected","constant","constraint","crash","create","current","currval","cursor",\n
"data_base","database","date","dba","deallocate","debugoff","debugon","decimal","declare","default","definition","delay","delete",\n
"desc","digits","dispose","distinct","do","drop",\n
"else","elsif","enable","end","entry","escape","exception","exception_init","exchange","exclusive","exists","exit","external",\n
"fast","fetch","file","for","force","form","from","function",\n
"generic","goto","grant","group",\n
"having",\n
"identified","if","immediate","in","increment","index","indexes","indicator","initial","initrans","insert","interface","intersect",\n
"into","is",\n
"key",\n
"level","library","like","limited","local","lock","log","logging","long","loop",\n
"master","maxextents","maxtrans","member","minextents","minus","mislabel","mode","modify","multiset",\n
"new","next","no","noaudit","nocompress","nologging","noparallel","not","nowait","number_base",\n
"object","of","off","offline","on","online","only","open","option","or","order","out",\n
"package","parallel","partition","pctfree","pctincrease","pctused","pls_integer","positive","positiven","pragma","primary","prior",\n
"private","privileges","procedure","public",\n
"raise","range","raw","read","rebuild","record","ref","references","refresh","release","rename","replace","resource","restrict","return",\n
"returning","reverse","revoke","rollback","row","rowid","rowlabel","rownum","rows","run",\n
"savepoint","schema","segment","select","separate","session","set","share","snapshot","some","space","split","sql","start","statement",\n
"storage","subtype","successful","synonym",\n
"tabauth","table","tables","tablespace","task","terminate","then","to","trigger","truncate","type",\n
"union","unique","unlimited","unrecoverable","unusable","update","use","using",\n
"validate","value","values","variable","view","views",\n
"when","whenever","where","while","with","work"\n
]);\n
\n
var types = wordRegexp([\n
"bfile","blob",\n
"character","clob",\n
"dec",\n
"float",\n
"int","integer",\n
"mlslabel",\n
"natural","naturaln","nchar","nclob","number","numeric","nvarchar2",\n
"real","rowtype",\n
"signtype","smallint","string",\n
"varchar","varchar2"\n
]);\n
\n
var operators = wordRegexp([\n
":=", "<", "<=", "==", "!=", "<>", ">", ">=", "like", "rlike", "in", "xor", "between"\n
]);\n
\n
var operatorChars = /[*+\\-<>=&|:\\/]/;\n
\n
var tokenizeSql = (function() {\n
function normal(source, setState) {\n
var ch = source.next();\n
if (ch == "@" || ch == "$") {\n
source.nextWhileMatches(/[\\w\\d]/);\n
return "plsql-var";\n
}\n
else if (ch == "\\"" || ch == "\'" || ch == "`") {\n
setState(inLiteral(ch));\n
return null;\n
}\n
else if (ch == "," || ch == ";") {\n
return "plsql-separator"\n
}\n
else if (ch == \'-\') {\n
if (source.peek() == "-") {\n
while (!source.endOfLine()) source.next();\n
return "plsql-comment";\n
}\n
else if (/\\d/.test(source.peek())) {\n
source.nextWhileMatches(/\\d/);\n
if (source.peek() == \'.\') {\n
source.next();\n
source.nextWhileMatches(/\\d/);\n
}\n
return "plsql-number";\n
}\n
else\n
return "plsql-operator";\n
}\n
else if (operatorChars.test(ch)) {\n
source.nextWhileMatches(operatorChars);\n
return "plsql-operator";\n
}\n
else if (/\\d/.test(ch)) {\n
source.nextWhileMatches(/\\d/);\n
if (source.peek() == \'.\') {\n
source.next();\n
source.nextWhileMatches(/\\d/);\n
}\n
return "plsql-number";\n
}\n
else if (/[()]/.test(ch)) {\n
return "plsql-punctuation";\n
}\n
else {\n
source.nextWhileMatches(/[_\\w\\d]/);\n
var word = source.get(), type;\n
if (operators.test(word))\n
type = "plsql-operator";\n
else if (keywords.test(word))\n
type = "plsql-keyword";\n
else if (functions.test(word))\n
type = "plsql-function";\n
else if (types.test(word))\n
type = "plsql-type";\n
else\n
type = "plsql-word";\n
return {style: type, content: word};\n
}\n
}\n
\n
function inLiteral(quote) {\n
return function(source, setState) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (ch == quote && !escaped) {\n
setState(normal);\n
break;\n
}\n
escaped = !escaped && ch == "\\\\";\n
}\n
return quote == "`" ? "plsql-word" : "plsql-literal";\n
};\n
}\n
\n
return function(source, startState) {\n
return tokenizer(source, startState || normal);\n
};\n
})();\n
\n
function indentSql(context) {\n
return function(nextChars) {\n
var firstChar = nextChars && nextChars.charAt(0);\n
var closing = context && firstChar == context.type;\n
if (!context)\n
return 0;\n
else if (context.align)\n
return context.col - (closing ? context.width : 0);\n
else\n
return context.indent + (closing ? 0 : indentUnit);\n
}\n
}\n
\n
function parseSql(source) {\n
var tokens = tokenizeSql(source);\n
var context = null, indent = 0, col = 0;\n
function pushContext(type, width, align) {\n
context = {prev: context, indent: indent, col: col, type: type, width: width, align: align};\n
}\n
function popContext() {\n
context = context.prev;\n
}\n
\n
var iter = {\n
next: function() {\n
var token = tokens.next();\n
var type = token.style, content = token.content, width = token.value.length;\n
\n
if (content == "\\n") {\n
token.indentation = indentSql(context);\n
indent = col = 0;\n
if (context && context.align == null) context.align = false;\n
}\n
else if (type == "whitespace" && col == 0) {\n
indent = width;\n
}\n
else if (!context && type != "plsql-comment") {\n
pushContext(";", 0, false);\n
}\n
\n
if (content != "\\n") col += width;\n
\n
if (type == "plsql-punctuation") {\n
if (content == "(")\n
pushContext(")", width);\n
else if (content == ")")\n
popContext();\n
}\n
else if (type == "plsql-separator" && content == ";" && context && !context.prev) {\n
popContext();\n
}\n
\n
return token;\n
},\n
\n
copy: function() {\n
var _context = context, _indent = indent, _col = col, _tokenState = tokens.state;\n
return function(source) {\n
tokens = tokenizeSql(source, _tokenState);\n
context = _context;\n
indent = _indent;\n
col = _col;\n
return iter;\n
};\n
}\n
};\n
return iter;\n
}\n
\n
return {make: parseSql, electricChars: ")"};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>8244</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>python</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.93</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>pythoncolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
padding: .4em;\n
margin: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
line-height: 1.1em;\n
color: black;\n
}\n
\n
pre.code, .editbox {\n
color: #666666;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.py-delimiter, span.py-special {\n
color: #666666;\n
}\n
\n
span.py-operator {\n
color: #666666;\n
}\n
\n
span.py-error {\n
background-color: #660000;\n
color: #FFFFFF;\n
}\n
\n
span.py-keyword {\n
color: #770088;\n
font-weight: bold;\n
}\n
\n
span.py-literal {\n
color: #228811;\n
}\n
\n
span.py-identifier, span.py-func {\n
color: black;\n
}\n
\n
span.py-type, span.py-decorator {\n
color: #0000FF;\n
}\n
\n
span.py-comment {\n
color: #AA7700;\n
}\n
\n
span.py-string, span.py-bytes, span.py-raw, span.py-unicode {\n
color: #AA2222;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>718</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.93</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsepython.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
var PythonParser = Editor.Parser = (function() {\n
function wordRegexp(words) {\n
return new RegExp("^(?:" + words.join("|") + ")$");\n
}\n
var DELIMITERCLASS = \'py-delimiter\';\n
var LITERALCLASS = \'py-literal\';\n
var ERRORCLASS = \'py-error\';\n
var OPERATORCLASS = \'py-operator\';\n
var IDENTIFIERCLASS = \'py-identifier\';\n
var STRINGCLASS = \'py-string\';\n
var BYTESCLASS = \'py-bytes\';\n
var UNICODECLASS = \'py-unicode\';\n
var RAWCLASS = \'py-raw\';\n
var NORMALCONTEXT = \'normal\';\n
var STRINGCONTEXT = \'string\';\n
var singleOperators = \'+-*/%&|^~<>\';\n
var doubleOperators = wordRegexp([\'==\', \'!=\', \'\\\\<=\', \'\\\\>=\', \'\\\\<\\\\>\',\n
\'\\\\<\\\\<\', \'\\\\>\\\\>\', \'\\\\/\\\\/\', \'\\\\*\\\\*\']);\n
var singleDelimiters = \'()[]{}@,:`=;\';\n
var doubleDelimiters = [\'\\\\+=\', \'\\\\-=\', \'\\\\*=\', \'/=\', \'%=\', \'&=\', \'\\\\|=\',\n
\'\\\\^=\'];\n
var tripleDelimiters = wordRegexp([\'//=\',\'\\\\>\\\\>=\',\'\\\\<\\\\<=\',\'\\\\*\\\\*=\']);\n
var singleStarters = singleOperators + singleDelimiters + \'=!\';\n
var doubleStarters = \'=<>*/\';\n
var identifierStarters = /[_A-Za-z]/;\n
\n
var wordOperators = wordRegexp([\'and\', \'or\', \'not\', \'is\', \'in\']);\n
var commonkeywords = [\'as\', \'assert\', \'break\', \'class\', \'continue\',\n
\'def\', \'del\', \'elif\', \'else\', \'except\', \'finally\',\n
\'for\', \'from\', \'global\', \'if\', \'import\',\n
\'lambda\', \'pass\', \'raise\', \'return\',\n
\'try\', \'while\', \'with\', \'yield\'];\n
var commontypes = [\'bool\', \'classmethod\', \'complex\', \'dict\', \'enumerate\',\n
\'float\', \'frozenset\', \'int\', \'list\', \'object\',\n
\'property\', \'reversed\', \'set\', \'slice\', \'staticmethod\',\n
\'str\', \'super\', \'tuple\', \'type\'];\n
var py2 = {\'types\': [\'basestring\', \'buffer\', \'file\', \'long\', \'unicode\',\n
\'xrange\'],\n
\'keywords\': [\'exec\', \'print\'],\n
\'version\': 2 };\n
var py3 = {\'types\': [\'bytearray\', \'bytes\', \'filter\', \'map\', \'memoryview\',\n
\'open\', \'range\', \'zip\'],\n
\'keywords\': [\'nonlocal\'],\n
\'version\': 3};\n
\n
var py, keywords, types, stringStarters, stringTypes, config;\n
\n
function configure(conf) {\n
if (!conf.hasOwnProperty(\'pythonVersion\')) {\n
conf.pythonVersion = 2;\n
}\n
if (!conf.hasOwnProperty(\'strictErrors\')) {\n
conf.strictErrors = true;\n
}\n
if (conf.pythonVersion != 2 && conf.pythonVersion != 3) {\n
alert(\'CodeMirror: Unknown Python Version "\' +\n
conf.pythonVersion +\n
\'", defaulting to Python 2.x.\');\n
conf.pythonVersion = 2;\n
}\n
if (conf.pythonVersion == 3) {\n
py = py3;\n
stringStarters = /[\\\'\\"rbRB]/;\n
stringTypes = /[rb]/;\n
doubleDelimiters.push(\'\\\\-\\\\>\');\n
} else {\n
py = py2;\n
stringStarters = /[\\\'\\"RUru]/;\n
stringTypes = /[ru]/;\n
}\n
config = conf;\n
keywords = wordRegexp(commonkeywords.concat(py.keywords));\n
types = wordRegexp(commontypes.concat(py.types));\n
doubleDelimiters = wordRegexp(doubleDelimiters);\n
}\n
\n
var tokenizePython = (function() {\n
function normal(source, setState) {\n
var stringDelim, threeStr, temp, type, word, possible = {};\n
var ch = source.next();\n
\n
function filterPossible(token, styleIfPossible) {\n
if (!possible.style && !possible.content) {\n
return token;\n
} else if (typeof(token) == STRINGCONTEXT) {\n
token = {content: source.get(), style: token};\n
}\n
if (possible.style || styleIfPossible) {\n
token.style = styleIfPossible ? styleIfPossible : possible.style;\n
}\n
if (possible.content) {\n
token.content = possible.content + token.content;\n
}\n
possible = {};\n
return token;\n
}\n
\n
// Handle comments\n
if (ch == \'#\') {\n
while (!source.endOfLine()) {\n
source.next();\n
}\n
return \'py-comment\';\n
}\n
// Handle special chars\n
if (ch == \'\\\\\') {\n
if (!source.endOfLine()) {\n
var whitespace = true;\n
while (!source.endOfLine()) {\n
if(!(/[\\s\\u00a0]/.test(source.next()))) {\n
whitespace = false;\n
}\n
}\n
if (!whitespace) {\n
return ERRORCLASS;\n
}\n
}\n
return \'py-special\';\n
}\n
// Handle operators and delimiters\n
if (singleStarters.indexOf(ch) != -1 || (ch == "." && !source.matches(/\\d/))) {\n
if (doubleStarters.indexOf(source.peek()) != -1) {\n
temp = ch + source.peek();\n
// It must be a double delimiter or operator or triple delimiter\n
if (doubleOperators.test(temp)) {\n
source.next();\n
var nextChar = source.peek();\n
if (nextChar && tripleDelimiters.test(temp + nextChar)) {\n
source.next();\n
return DELIMITERCLASS;\n
} else {\n
return OPERATORCLASS;\n
}\n
} else if (doubleDelimiters.test(temp)) {\n
source.next();\n
return DELIMITERCLASS;\n
}\n
}\n
// It must be a single delimiter or operator\n
if (singleOperators.indexOf(ch) != -1 || ch == ".") {\n
return OPERATORCLASS;\n
} else if (singleDelimiters.indexOf(ch) != -1) {\n
if (ch == \'@\' && source.matches(/\\w/)) {\n
source.nextWhileMatches(/[\\w\\d_]/);\n
return {style:\'py-decorator\',\n
content: source.get()};\n
} else {\n
return DELIMITERCLASS;\n
}\n
} else {\n
return ERRORCLASS;\n
}\n
}\n
// Handle number literals\n
if (/\\d/.test(ch) || (ch == "." && source.matches(/\\d/))) {\n
if (ch === \'0\' && !source.endOfLine()) {\n
switch (source.peek()) {\n
case \'o\':\n
case \'O\':\n
source.next();\n
source.nextWhileMatches(/[0-7]/);\n
return filterPossible(LITERALCLASS, ERRORCLASS);\n
case \'x\':\n
case \'X\':\n
source.next();\n
source.nextWhileMatches(/[0-9A-Fa-f]/);\n
return filterPossible(LITERALCLASS, ERRORCLASS);\n
case \'b\':\n
case \'B\':\n
source.next();\n
source.nextWhileMatches(/[01]/);\n
return filterPossible(LITERALCLASS, ERRORCLASS);\n
}\n
}\n
source.nextWhileMatches(/\\d/);\n
if (ch != \'.\' && source.peek() == \'.\') {\n
source.next();\n
source.nextWhileMatches(/\\d/);\n
}\n
// Grab an exponent\n
if (source.matches(/e/i)) {\n
source.next();\n
if (source.peek() == \'+\' || source.peek() == \'-\') {\n
source.next();\n
}\n
if (source.matches(/\\d/)) {\n
source.nextWhileMatches(/\\d/);\n
} else {\n
return filterPossible(ERRORCLASS);\n
}\n
}\n
// Grab a complex number\n
if (source.matches(/j/i)) {\n
source.next();\n
}\n
\n
return filterPossible(LITERALCLASS);\n
}\n
// Handle strings\n
if (stringStarters.test(ch)) {\n
var peek = source.peek();\n
var stringType = STRINGCLASS;\n
if ((stringTypes.test(ch)) && (peek == \'"\' || peek == "\'")) {\n
switch (ch.toLowerCase()) {\n
case \'b\':\n
stringType = BYTESCLASS;\n
break;\n
case \'r\':\n
stringType = RAWCLASS;\n
break;\n
case \'u\':\n
stringType = UNICODECLASS;\n
break;\n
}\n
ch = source.next();\n
stringDelim = ch;\n
if (source.peek() != stringDelim) {\n
setState(inString(stringType, stringDelim));\n
return null;\n
} else {\n
source.next();\n
if (source.peek() == stringDelim) {\n
source.next();\n
threeStr = stringDelim + stringDelim + stringDelim;\n
setState(inString(stringType, threeStr));\n
return null;\n
} else {\n
return stringType;\n
}\n
}\n
} else if (ch == "\'" || ch == \'"\') {\n
stringDelim = ch;\n
if (source.peek() != stringDelim) {\n
setState(inString(stringType, stringDelim));\n
return null;\n
} else {\n
source.next();\n
if (source.peek() == stringDelim) {\n
source.next();\n
threeStr = stringDelim + stringDelim + stringDelim;\n
setState(inString(stringType, threeStr));\n
return null;\n
} else {\n
return stringType;\n
}\n
}\n
}\n
}\n
// Handle Identifier\n
if (identifierStarters.test(ch)) {\n
source.nextWhileMatches(/[\\w\\d_]/);\n
word = source.get();\n
if (wordOperators.test(word)) {\n
type = OPERATORCLASS;\n
} else if (keywords.test(word)) {\n
type = \'py-keyword\';\n
} else if (types.test(word)) {\n
type = \'py-type\';\n
} else {\n
type = IDENTIFIERCLASS;\n
while (source.peek() == \'.\') {\n
source.next();\n
if (source.matches(identifierStarters)) {\n
source.nextWhileMatches(/[\\w\\d]/);\n
} else {\n
type = ERRORCLASS;\n
break;\n
}\n
}\n
word = word + source.get();\n
}\n
return filterPossible({style: type, content: word});\n
}\n
\n
// Register Dollar sign and Question mark as errors. Always!\n
if (/\\$\\?/.test(ch)) {\n
return filterPossible(ERRORCLASS);\n
}\n
\n
return filterPossible(ERRORCLASS);\n
}\n
\n
function inString(style, terminator) {\n
return function(source, setState) {\n
var matches = [];\n
var found = false;\n
while (!found && !source.endOfLine()) {\n
var ch = source.next(), newMatches = [];\n
// Skip escaped characters\n
if (ch == \'\\\\\') {\n
if (source.peek() == \'\\n\') {\n
break;\n
}\n
ch = source.next();\n
ch = source.next();\n
}\n
if (ch == terminator.charAt(0)) {\n
matches.push(terminator);\n
}\n
for (var i = 0; i < matches.length; i++) {\n
var match = matches[i];\n
if (match.charAt(0) == ch) {\n
if (match.length == 1) {\n
setState(normal);\n
found = true;\n
break;\n
} else {\n
newMatches.push(match.slice(1));\n
}\n
}\n
}\n
matches = newMatches;\n
}\n
return style;\n
};\n
}\n
\n
return function(source, startState) {\n
return tokenizer(source, startState || normal);\n
};\n
})();\n
\n
function parsePython(source, basecolumn) {\n
if (!keywords) {\n
configure({});\n
}\n
basecolumn = basecolumn || 0;\n
\n
var tokens = tokenizePython(source);\n
var lastToken = null;\n
var column = basecolumn;\n
var context = {prev: null,\n
endOfScope: false,\n
startNewScope: false,\n
level: basecolumn,\n
next: null,\n
type: NORMALCONTEXT\n
};\n
\n
function pushContext(level, type) {\n
type = type ? type : NORMALCONTEXT;\n
context = {prev: context,\n
endOfScope: false,\n
startNewScope: false,\n
level: level,\n
next: null,\n
type: type\n
};\n
}\n
\n
function popContext(remove) {\n
remove = remove ? remove : false;\n
if (context.prev) {\n
if (remove) {\n
context = context.prev;\n
context.next = null;\n
} else {\n
context.prev.next = context;\n
context = context.prev;\n
}\n
}\n
}\n
\n
function indentPython(context) {\n
var temp;\n
return function(nextChars, currentLevel, direction) {\n
if (direction === null || direction === undefined) {\n
if (nextChars) {\n
while (context.next) {\n
context = context.next;\n
}\n
}\n
return context.level;\n
}\n
else if (direction === true) {\n
if (currentLevel == context.level) {\n
if (context.next) {\n
return context.next.level;\n
} else {\n
return context.level;\n
}\n
} else {\n
temp = context;\n
while (temp.prev && temp.prev.level > currentLevel) {\n
temp = temp.prev;\n
}\n
return temp.level;\n
}\n
} else if (direction === false) {\n
if (currentLevel > context.level) {\n
return context.level;\n
} else if (context.prev) {\n
temp = context;\n
while (temp.prev && temp.prev.level >= currentLevel) {\n
temp = temp.prev;\n
}\n
if (temp.prev) {\n
return temp.prev.level;\n
} else {\n
return temp.level;\n
}\n
}\n
}\n
return context.level;\n
};\n
}\n
\n
var iter = {\n
next: function() {\n
var token = tokens.next();\n
var type = token.style;\n
var content = token.content;\n
\n
if (lastToken) {\n
if (lastToken.content == \'def\' && type == IDENTIFIERCLASS) {\n
token.style = \'py-func\';\n
}\n
if (lastToken.content == \'\\n\') {\n
var tempCtx = context;\n
// Check for a different scope\n
if (type == \'whitespace\' && context.type == NORMALCONTEXT) {\n
if (token.value.length < context.level) {\n
while (token.value.length < context.level) {\n
popContext();\n
}\n
\n
if (token.value.length != context.level) {\n
context = tempCtx;\n
if (config.strictErrors) {\n
token.style = ERRORCLASS;\n
}\n
} else {\n
context.next = null;\n
}\n
}\n
} else if (context.level !== basecolumn &&\n
context.type == NORMALCONTEXT) {\n
while (basecolumn !== context.level) {\n
popContext();\n
}\n
\n
if (context.level !== basecolumn) {\n
context = tempCtx;\n
if (config.strictErrors) {\n
token.style = ERRORCLASS;\n
}\n
}\n
}\n
}\n
}\n
\n
// Handle Scope Changes\n
switch(type) {\n
case STRINGCLASS:\n
case BYTESCLASS:\n
case RAWCLASS:\n
case UNICODECLASS:\n
if (context.type !== STRINGCONTEXT) {\n
pushContext(context.level + 1, STRINGCONTEXT);\n
}\n
break;\n
default:\n
if (context.type === STRINGCONTEXT) {\n
popContext(true);\n
}\n
break;\n
}\n
switch(content) {\n
case \'.\':\n
case \'@\':\n
// These delimiters don\'t appear by themselves\n
if (content !== token.value) {\n
token.style = ERRORCLASS;\n
}\n
break;\n
case \':\':\n
// Colons only delimit scope inside a normal scope\n
if (context.type === NORMALCONTEXT) {\n
context.startNewScope = context.level+indentUnit;\n
}\n
break;\n
case \'(\':\n
case \'[\':\n
case \'{\':\n
// These start a sequence scope\n
pushContext(column + content.length, \'sequence\');\n
break;\n
case \')\':\n
case \']\':\n
case \'}\':\n
// These end a sequence scope\n
popContext(true);\n
break;\n
case \'pass\':\n
case \'return\':\n
// These end a normal scope\n
if (context.type === NORMALCONTEXT) {\n
context.endOfScope = true;\n
}\n
break;\n
case \'\\n\':\n
// Reset our column\n
column = basecolumn;\n
// Make any scope changes\n
if (context.endOfScope) {\n
context.endOfScope = false;\n
popContext();\n
} else if (context.startNewScope !== false) {\n
var temp = context.startNewScope;\n
context.startNewScope = false;\n
pushContext(temp, NORMALCONTEXT);\n
}\n
// Newlines require an indentation function wrapped in a closure for proper context.\n
token.indentation = indentPython(context);\n
break;\n
}\n
\n
// Keep track of current column for certain scopes.\n
if (content != \'\\n\') {\n
column += token.value.length;\n
}\n
\n
lastToken = token;\n
return token;\n
},\n
\n
copy: function() {\n
var _context = context, _tokenState = tokens.state;\n
return function(source) {\n
tokens = tokenizePython(source, _tokenState);\n
context = _context;\n
return iter;\n
};\n
}\n
};\n
return iter;\n
}\n
\n
return {make: parsePython,\n
electricChars: "",\n
configure: configure};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>21868</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>scheme</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.93</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>schemecolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
width: 100%;\n
height: 100%;\n
background-color: white;\n
}\n
\n
.editbox {\n
width: 100%;\n
height: 100%;\n
margin: 0pt;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
\n
\n
pre.code, .editbox {\n
color: #666666;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.scheme-string\t{color: green;}\n
span.scheme-number\t{color: blue;}\n
span.scheme-boolean {color: darkred;}\n
span.scheme-character\t{color: orange;}\n
span.scheme-symbol\t{color: steelblue;}\n
span.scheme-punctuation {color: black;}\n
span.scheme-lparen {color: black;}\n
span.scheme-rparen {color: black;}\n
span.scheme-comment { color: orange; }\n
\n
span.good-matching-paren { \n
font-weight: bold;\n
color: #3399FF; \n
}\n
span.bad-matching-paren {\n
font-weight: bold;\n
color: red;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>787</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.93</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsescheme.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
var SchemeParser = Editor.Parser = (function() {\n
\n
\n
// isLparen: char -> boolean\n
var isLparen = function(ch) {\n
\treturn ch === \'(\' || ch === \'[\' || ch === \'{\';\n
};\n
\n
// isRparen: char -> boolean\n
var isRparen = function(ch) {\n
\treturn ch === \')\' || ch === \']\' || ch === \'}\';\n
};\n
\n
// isMatchingParens: char char -> boolean\n
var isMatchingParens = function(lparen, rparen) {\n
\treturn ((lparen === \'(\' && rparen === \')\') ||\n
\t\t(lparen === \'[\' && rparen === \']\') ||\n
\t\t(lparen === \'{\' && rparen === \'}\'));\n
};\n
\n
\n
// Compute the indentation context enclosing the end of the token\n
// sequence tokens.\n
// The context is the token sequence of the enclosing s-expression,\n
// augmented with column information.\n
var getIndentationContext = function(tokenStack) {\n
\tvar EMPTY_CONTEXT = [];\n
\n
\tvar pendingParens = [], i = 0, j, line, column, context;\n
\tvar tokens = [];\n
\n
\t// Scan for the start of the indentation context, accumulating tokens.\n
\twhile (! isEmptyPair(tokenStack)) {\n
\t i++;\n
\t tokens.push(pairFirst(tokenStack));\n
\t if (isLparen(pairFirst(tokenStack).type)) {\n
\t\tif (pendingParens.length === 0) {\n
\t\t break;\n
\t\t} else {\n
\t\t if (isMatchingParens(pairFirst(tokenStack).value,\n
\t\t\t\t\t pendingParens[pendingParens.length - 1])) {\n
\t\t\tpendingParens.pop();\n
\t\t } else {\n
\t\t\t// Error condition: we see mismatching parens,\n
\t\t\t// so we exit with no known indentation context.\n
\t\t\treturn EMPTY_CONTEXT;\n
\t\t }\n
\t\t}\n
\t } else if (isRparen(pairFirst(tokenStack).type)) {\n
\t\tpendingParens.push(pairFirst(tokenStack).type);\n
\t }\n
\t tokenStack = pairRest(tokenStack);\n
\t}\n
\n
\t// If we scanned backward too far, we couldn\'t find a context. Just\n
\t// return the empty context.\n
\tif (isEmptyPair(tokenStack)) { \n
\t return EMPTY_CONTEXT; \n
\t}\n
\n
\t// Position tokenStack to the next token beyond.\n
\ttokenStack = pairRest(tokenStack);\n
\n
\t// We now scan backwards to closest newline to figure out the column\n
\t// number:\n
\twhile (! isEmptyPair(tokenStack)) {\n
\t if(pairFirst(tokenStack).type === \'whitespace\' && \n
\t pairFirst(tokenStack).value === \'\\n\') {\n
\t\tbreak;\n
\t }\n
\t tokens.push(pairFirst(tokenStack));\n
\t tokenStack = pairRest(tokenStack);\n
\t}\n
\n
\tline = 0;\n
\tcolumn = 0;\n
\tcontext = [];\n
\t// Start generating the context, walking forward.\n
\tfor (j = tokens.length-1; j >= 0; j--) {\n
\t if (j < i) {\n
\t\tcontext.push({ type: tokens[j].type,\n
\t\t\t value: tokens[j].value,\n
\t\t\t line: line,\n
\t\t\t column: column });\n
\t }\n
\n
\t if (tokens[j].type === \'whitespace\' && \n
\t\ttokens[j].value === \'\\n\') {\n
\t\tcolumn = 0;\n
\t\tline++;\n
\t } else {\n
\t\tcolumn += tokens[j].value.length;\n
\t }\n
\t}\n
\treturn context;\n
\n
\n
};\n
\n
\n
\n
\n
\n
// calculateIndentationFromContext: indentation-context number -> number\n
var calculateIndentationFromContext = function(context, currentIndentation) {\n
\tif (context.length === 0) {\n
\t return 0;\n
\t}\n
\tif (isBeginLikeContext(context)) {\n
\t return beginLikeIndentation(context);\n
\t}\n
\tif (isDefineLikeContext(context)) {\n
\t return defineLikeIndentation(context);\n
\t}\n
\tif (isLambdaLikeContext(context)) {\n
\t return lambdaLikeIndentation(context);\n
\t}\n
\treturn beginLikeIndentation(context, 0);\n
};\n
\n
\n
\n
// findContextElement: indentation-context number -> index or -1\n
var findContextElement = function(context, index) {\n
\tvar depth = 0;\n
\tfor(var i = 0; i < context.length; i++) {\n
\t if (context[i].type !== \'whitespace\' && depth === 1) {\n
\t\tif (index === 0)\n
\t\t return i;\n
\t\telse\n
\t\t index--;\n
\t }\n
\n
\t if (isLparen(context[i].type)) {\n
\t\tdepth++;\n
\t }\n
\t if (isRparen(context[i].type)) {\n
\t\tdepth = Math.max(depth - 1, 0);\n
\t }\n
\t}\n
\treturn -1;\n
};\n
\n
// contextElement: context -> (arrayof index)\n
var contextElements = function(context) {\n
\tvar i = 0, index, results = [];\n
\t\n
\twhile ((index = findContextElement(context, i++)) != -1) {\n
\t results.push(index);\n
\t}\n
\treturn results;\n
};\n
\n
\n
\n
//////////////////////////////////////////////////////////////////////\n
\n
var BEGIN_LIKE_KEYWORDS = ["case-lambda", \n
\t\t\t "compound-unit",\n
\t\t\t "compound-unit/sig",\n
\t\t\t "cond",\n
\t\t\t "delay",\n
\t\t\t "inherit",\n
\t\t\t "match-lambda",\n
\t\t\t "match-lambda*",\n
\t\t\t "override",\n
\t\t\t "private",\n
\t\t\t "public",\n
\t\t\t "sequence",\n
\t\t\t "unit"];\n
\n
var isBeginLikeContext = function(context) {\n
\tvar j = findContextElement(context, 0);\n
\tif (j === -1) { return false; }\n
\treturn (/^begin/.test(context[j].value) ||\n
\t\tisMember(context[j].value, BEGIN_LIKE_KEYWORDS));\n
};\n
\n
\n
// Begin: if there\'s no elements within the begin context,\n
// the indentation is that of the begin keyword\'s column + offset.\n
// Otherwise, find the leading element on the last line.\n
// Also used for default indentation.\n
var beginLikeIndentation = function(context, offset) {\n
\tif (typeof(offset) === \'undefined\') { offset = 1; }\n
\n
\tvar indices = contextElements(context), j;\n
\tif (indices.length === 0) {\n
\t return context[0].column + 1;\n
\t} else if (indices.length === 1) {\n
\t // if we only see the begin keyword, indentation is based\n
\t // off the keyword.\n
\t return context[indices[0]].column + offset;\n
\t} else {\n
\t // Otherwise, we scan for the contextElement of the last line\n
\t for (j = indices.length -1; j > 1; j--) {\n
\t\tif (context[indices[j]].line !==\n
\t\t context[indices[j-1]].line) {\n
\t\t return context[indices[j]].column;\n
\t\t}\n
\t }\n
\t return context[indices[j]].column;\n
\t}\n
};\n
\n
\n
\n
//////////////////////////////////////////////////////////////////////\n
\n
\n
var DEFINE_LIKE_KEYWORDS = ["local"];\n
\n
var isDefineLikeContext = function(context) {\n
\tvar j = findContextElement(context, 0);\n
\tif (j === -1) { return false; }\n
\treturn (/^def/.test(context[j].value) ||\n
\t\tisMember(context[j].value, DEFINE_LIKE_KEYWORDS));\n
};\n
\n
\n
var defineLikeIndentation = function(context) {\n
\tvar i = findContextElement(context, 0);\n
\tif (i === -1) { return 0; }\n
\treturn context[i].column +1; \n
};\n
\n
//////////////////////////////////////////////////////////////////////\n
\n
var LAMBDA_LIKE_KEYWORDS = ["cases",\n
\t\t\t\t"instantiate",\n
\t\t\t\t"super-instantiate",\n
\t\t\t\t"syntax/loc",\n
\t\t\t\t"quasisyntax/loc",\n
\t\t\t\t"lambda",\n
\t\t\t\t"let",\n
\t\t\t\t"let*",\n
\t\t\t\t"letrec",\n
\t\t\t\t"recur",\n
\t\t\t\t"lambda/kw",\n
\t\t\t\t"letrec-values",\n
\t\t\t\t"with-syntax",\n
\t\t\t\t"with-continuation-mark",\n
\t\t\t\t"module",\n
\t\t\t\t"match",\n
\t\t\t\t"match-let",\n
\t\t\t\t"match-let*",\n
\t\t\t\t"match-letrec",\n
\t\t\t\t"let/cc",\n
\t\t\t\t"let/ec",\n
\t\t\t\t"letcc",\n
\t\t\t\t"catch",\n
\t\t\t\t"let-syntax",\n
\t\t\t\t"letrec-syntax",\n
\t\t\t\t"fluid-let-syntax",\n
\t\t\t\t"letrec-syntaxes+values",\n
\t\t\t\t"for",\n
\t\t\t\t"for/list",\n
\t\t\t\t"for/hash",\n
\t\t\t\t"for/hasheq",\n
\t\t\t\t"for/and",\n
\t\t\t\t"for/or",\n
\t\t\t\t"for/lists",\n
\t\t\t\t"for/first",\n
\t\t\t\t"for/last",\n
\t\t\t\t"for/fold",\n
\t\t\t\t"for*",\n
\t\t\t\t"for*/list",\n
\t\t\t\t"for*/hash",\n
\t\t\t\t"for*/hasheq",\n
\t\t\t\t"for*/and",\n
\t\t\t\t"for*/or",\n
\t\t\t\t"for*/lists",\n
\t\t\t\t"for*/first",\n
\t\t\t\t"for*/last",\n
\t\t\t\t"for*/fold",\n
\t\t\t\t"kernel-syntax-case",\n
\t\t\t\t"syntax-case",\n
\t\t\t\t"syntax-case*",\n
\t\t\t\t"syntax-rules",\n
\t\t\t\t"syntax-id-rules",\n
\t\t\t\t"let-signature",\n
\t\t\t\t"fluid-let",\n
\t\t\t\t"let-struct",\n
\t\t\t\t"let-macro",\n
\t\t\t\t"let-values",\n
\t\t\t\t"let*-values",\n
\t\t\t\t"case",\n
\t\t\t\t"when",\n
\t\t\t\t"unless",\n
\t\t\t\t"let-enumerate",\n
\t\t\t\t"class",\n
\t\t\t\t"class*",\n
\t\t\t\t"class-asi",\n
\t\t\t\t"class-asi*",\n
\t\t\t\t"class*/names",\n
\t\t\t\t"class100",\n
\t\t\t\t"class100*",\n
\t\t\t\t"class100-asi",\n
\t\t\t\t"class100-asi*",\n
\t\t\t\t"class100*/names",\n
\t\t\t\t"rec",\n
\t\t\t\t"make-object",\n
\t\t\t\t"mixin",\n
\t\t\t\t"define-some",\n
\t\t\t\t"do",\n
\t\t\t\t"opt-lambda",\n
\t\t\t\t"send*",\n
\t\t\t\t"with-method",\n
\t\t\t\t"define-record",\n
\t\t\t\t"catch",\n
\t\t\t\t"shared",\n
\t\t\t\t"unit/sig",\n
\t\t\t\t"unit/lang",\n
\t\t\t\t"with-handlers",\n
\t\t\t\t"interface",\n
\t\t\t\t"parameterize",\n
\t\t\t\t"call-with-input-file",\n
\t\t\t\t"call-with-input-file*",\n
\t\t\t\t"with-input-from-file",\n
\t\t\t\t"with-input-from-port",\n
\t\t\t\t"call-with-output-file",\n
\t\t\t\t"with-output-to-file",\n
\t\t\t\t"with-output-to-port",\n
\t\t\t\t"for-all"];\n
\n
\n
var isLambdaLikeContext = function(context) {\n
\tvar j = findContextElement(context, 0);\n
\tif (j === -1) { return false; }\n
\treturn (isMember(context[j].value, LAMBDA_LIKE_KEYWORDS));\n
};\n
\n
\n
var lambdaLikeIndentation = function(context) {\n
\tvar i = findContextElement(context, 0);\n
\tif (i === -1) { return 0; }\n
\tvar j = findContextElement(context, 1);\n
\tif (j === -1) { \n
\t return context[i].column + 4; \n
\t} else {\n
\t return context[i].column + 1;\n
\t}\n
};\n
\n
\n
\n
\n
//////////////////////////////////////////////////////////////////////\n
// Helpers\n
var isMember = function(x, l) {\n
\tfor (var i = 0; i < l.length; i++) {\n
\t if (x === l[i]) { return true; }\n
\t}\n
\treturn false;\n
};\n
\n
\n
\n
//////////////////////////////////////////////////////////////////////\n
\n
var pair = function(x, y) {\n
\treturn [x,y];\n
};\n
var EMPTY_PAIR = [];\n
var pairFirst = function(p) { return p[0]; }\n
var pairRest = function(p) { return p[1]; }\n
var isEmptyPair = function(p) { return p === EMPTY_PAIR; }\n
var pairLength = function(p) {\n
\tvar l = 0;\n
\twhile (! isEmptyPair(p)) {\n
\t p = pairRest(p);\n
\t}\n
\treturn l;\n
};\n
\n
//////////////////////////////////////////////////////////////////////\n
\n
\n
\n
\n
var indentTo = function(tokenStack) {\n
\treturn function(tokenText, currentIndentation, direction) {\n
\n
\t // If we\'re in the middle of an unclosed token,\n
\t // do not change indentation.\n
\t if ((! isEmptyPair(tokenStack)) &&\n
\t\t(! isEmptyPair(pairRest(tokenStack))) &&\n
\t\t(pairFirst(pairRest(tokenStack)).isUnclosed)) {\n
\t\treturn currentIndentation;\n
\t }\n
\n
\t var indentationContext = \n
\t\tgetIndentationContext(tokenStack);\n
\t return calculateIndentationFromContext(indentationContext,\n
\t\t\t\t\t\t currentIndentation);\t\t\n
\t};\n
};\n
\n
\n
var startParse = function(source) {\n
\tsource = tokenizeScheme(source);\t\n
\tvar tokenStack = EMPTY_PAIR;\n
\tvar iter = {\n
\t next: function() {\n
\t\tvar tok = source.next();\n
\t\ttokenStack = pair(tok, tokenStack);\n
\t\tif (tok.type === "whitespace") {\n
\t\t if (tok.value === "\\n") {\n
\t\t\ttok.indentation = indentTo(tokenStack);\n
\t\t }\n
\t\t}\n
\t\treturn tok;\n
\t },\n
\n
\t copy: function() {\n
\t\tvar _tokenStack = tokenStack;\n
\t\tvar _tokenState = source.state;\n
\t\treturn function(_source) {\n
\t\t tokenStack = _tokenStack;\n
\t\t source = tokenizeScheme(_source, _tokenState);\n
\t\t return iter;\n
\t\t};\n
\t }\n
\t};\n
\treturn iter;\n
};\n
return { make: startParse };\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>10188</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>tokenizescheme.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Tokenizer for Scheme code */\n
\n
\n
\n
\n
/**\n
TODO: follow the definitions in:\n
\n
http://docs.racket-lang.org/reference/reader.html\n
\n
to the letter; at the moment, we\'ve just done something quick-and-dirty.\n
\n
*/\n
\n
\n
var tokenizeScheme = (function() {\n
var isWhiteSpace = function(ch) {\n
\t// The messy regexp is because IE\'s regexp matcher is of the\n
\t// opinion that non-breaking spaces are no whitespace.\n
\treturn ch != "\\n" && /^[\\s\\u00a0]*$/.test(ch);\n
};\n
\n
\n
// scanUntilUnescaped: string-stream char -> boolean\n
// Advances the stream until the given character (not preceded by a\n
// backslash) is encountered.\n
// Returns true if we hit end of line without closing.\n
// Returns false otherwise.\n
var scanUntilUnescaped = function(source, end) {\n
\tvar escaped = false;\n
\twhile (true) {\n
\t if (source.endOfLine()) {\n
\t\treturn true;\n
\t }\n
\t var next = source.next();\n
\t if (next == end && !escaped)\n
\t\treturn false;\n
\t escaped = !escaped && next == "\\\\";\n
\t}\n
\treturn false;\n
}\n
\n
\n
// Advance the stream until endline.\n
var scanUntilEndline = function(source, end) {\n
\twhile (!source.endOfLine()) {\n
\t source.next();\n
\t}\n
}\n
\n
\n
// Some helper regexps\n
var isHexDigit = /[0-9A-Fa-f]/;\n
\n
\n
var whitespaceChar = new RegExp("[\\\\s\\\\u00a0]");\n
\n
var isDelimiterChar = \n
\tnew RegExp("[\\\\s\\\\\\(\\\\\\)\\\\\\[\\\\\\]\\\\\\{\\\\\\}\\\\\\"\\\\\\,\\\\\\\'\\\\\\`\\\\\\;]");\n
\n
var isNotDelimiterChar = \n
\tnew RegExp("[^\\\\s\\\\\\(\\\\\\)\\\\\\[\\\\\\]\\\\\\{\\\\\\}\\\\\\"\\\\\\,\\\\\\\'\\\\\\`\\\\\\;]");\n
\n
\n
var numberHeader = ("(?:(?:\\\\d+\\\\/\\\\d+)|"+\n
\t\t\t( "(?:(?:\\\\d+\\\\.\\\\d+|\\\\d+\\\\.|\\\\.\\\\d+)(?:[eE][+\\\\-]?\\\\d+)?)|")+\n
\t\t\t( "(?:\\\\d+(?:[eE][+\\\\-]?\\\\d+)?))"));\n
var numberPatterns = [\n
\t// complex numbers\n
\tnew RegExp("^((?:(?:\\\\#[ei])?[+\\\\-]?" + numberHeader +")?"\n
\t\t + "(?:[+\\\\-]" + numberHeader + ")i$)"),\n
\t /^((?:\\#[ei])?[+-]inf.0)$/,\n
\t /^((?:\\#[ei])?[+-]nan.0)$/,\n
\tnew RegExp("^((?:\\\\#[ei])?[+\\\\-]?" + numberHeader + "$)"),\n
\tnew RegExp("^0[xX][0-9A-Fa-f]+$")];\n
\n
\n
// looksLikeNumber: string -> boolean\n
// Returns true if string s looks like a number.\n
var looksLikeNumber = function(s) {\n
\tfor (var i = 0; i < numberPatterns.length; i++) {\n
\t if (numberPatterns[i].test(s)) {\n
\t\treturn true;\n
\t }\n
\t}\n
\treturn false;\n
};\n
\n
\n
\n
var UNCLOSED_STRING = function(source, setState) {\n
\tvar readNewline = function() {\n
\t var content = source.get();\n
\t return { type:\'whitespace\', style:\'whitespace\', content: content };\n
\t};\n
\n
\tvar ch = source.peek();\n
\tif (ch === \'\\n\') {\n
\t source.next();\n
\t return readNewline();\n
\t} else {\n
\t var isUnclosedString = scanUntilUnescaped(source, \'"\');\n
\t if (isUnclosedString) {\n
\t\tsetState(UNCLOSED_STRING);\n
\t } else {\n
\t\tsetState(START);\n
\t }\n
\t var content = source.get();\n
\t return {type: "string", style: "scheme-string", content: content,\n
\t\t isUnclosed: isUnclosedString};\n
\t}\n
};\n
\n
\n
\n
var START = function(source, setState) {\n
\tvar readHexNumber = function(){\n
\t source.next(); // skip the \'x\'\n
\t source.nextWhileMatches(isHexDigit);\n
\t return {type: "number", style: "scheme-number"};\n
\t};\n
\n
\n
\tvar readNumber = function() {\n
\t scanSimpleNumber();\n
\t if (source.equals("-") || source.equals("+")) {\n
\t\tsource.next();\n
\t }\n
\t scanSimpleNumber();\n
\t if (source.equals("i")) {\n
\t\tsource.next();\n
\t }\n
\t return {type: "number", style: "scheme-number"};\n
\t};\n
\n
\n
\t// Read a word, look it up in keywords. If not found, it is a\n
\t// variable, otherwise it is a keyword of the type found.\n
\tvar readWordOrNumber = function() {\n
\t source.nextWhileMatches(isNotDelimiterChar);\n
\t var word = source.get();\n
\t if (looksLikeNumber(word)) {\n
\t\treturn {type: "number", style: "scheme-number", content: word};\n
\t } else {\n
\t\treturn {type: "variable", style: "scheme-symbol", content: word};\n
\t }\n
\t};\n
\n
\n
\tvar readString = function(quote) {\n
\t var isUnclosedString = scanUntilUnescaped(source, quote);\n
\t if (isUnclosedString) {\n
\t\tsetState(UNCLOSED_STRING);\n
\t }\n
\t var word = source.get();\n
\t return {type: "string", style: "scheme-string", content: word,\n
\t\t isUnclosed: isUnclosedString};\n
\t};\n
\n
\n
\tvar readPound = function() {\n
\t var text;\n
\t // FIXME: handle special things here\n
\t if (source.equals(";")) {\n
\t\tsource.next();\n
\t\ttext = source.get();\n
\t\treturn {type: text, \n
\t\t\tstyle:"scheme-symbol",\n
\t\t\tcontent: text};\n
\t } else {\n
\t\ttext = source.get();\n
\n
\t\treturn {type : "symbol",\n
\t\t\tstyle: "scheme-symbol",\n
\t\t\tcontent: text};\n
\t }\n
\n
\t};\n
\t\n
\tvar readLineComment = function() {\n
\t scanUntilEndline(source);\n
\t var text = source.get();\n
\t return { type: "comment", style: "scheme-comment", content: text};\t\n
\t};\n
\n
\n
\tvar readWhitespace = function() {\n
\t source.nextWhile(isWhiteSpace);\n
\t var content = source.get();\n
\t return { type: \'whitespace\', style:\'whitespace\', content: content };\n
\t};\n
\n
\tvar readNewline = function() {\n
\t var content = source.get();\n
\t return { type:\'whitespace\', style:\'whitespace\', content: content };\n
\t};\n
\n
\n
\t// Fetch the next token. Dispatches on first character in the\n
\t// stream, or first two characters when the first is a slash.\n
\tvar ch = source.next();\n
\tif (ch === \'\\n\') {\n
\t return readNewline();\n
\t} else if (whitespaceChar.test(ch)) {\n
\t return readWhitespace();\n
\t} else if (ch === "#") {\n
\t return readPound();\n
\t} else if (ch ===\';\') {\n
\t return readLineComment();\n
\t} else if (ch === "\\"") {\n
\t return readString(ch);\n
\t} else if (isDelimiterChar.test(ch)) {\n
\t return {type: ch, style: "scheme-punctuation"};\n
\t} else {\n
\t return readWordOrNumber();\n
\t}\n
}\n
\n
\n
\n
\n
\n
\n
\n
var makeTokenizer = function(source, state) {\n
\t// Newlines are always a separate token.\n
\n
\tvar tokenizer = {\n
\t state: state,\n
\n
\t take: function(type) {\n
\t\tif (typeof(type) == "string")\n
\t\t type = {style: type, type: type};\n
\n
\t\ttype.content = (type.content || "") + source.get();\n
\t\ttype.value = type.content;\n
\t\treturn type;\n
\t },\n
\n
\t next: function () {\n
\t\tif (!source.more()) throw StopIteration;\n
\n
\t\tvar type;\n
\t\twhile (!type) {\n
\t\t type = tokenizer.state(source, function(s) {\n
\t\t\ttokenizer.state = s;\n
\t\t });\n
\t\t}\n
\t\tvar result = this.take(type);\n
\t\treturn result;\t\t \n
\t }\n
\t};\n
\treturn tokenizer;\n
};\n
\n
\n
// The external interface to the tokenizer.\n
return function(source, startState) {\n
\treturn makeTokenizer(source, startState || START);\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>6295</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>sql</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>sqlcolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.sql-keyword {\n
color: blue;\n
}\n
\n
span.sql-var {\n
color: red;\n
}\n
\n
span.sql-comment {\n
color: #AA7700;\n
}\n
\n
span.sql-literal {\n
color: green;\n
}\n
\n
span.sql-operator {\n
color: blue;\n
}\n
\n
span.sql-word {\n
color: black;\n
}\n
\n
span.sql-function {\n
color: darkorange;\n
}\n
\n
span.sql-type {\n
color: purple;\n
}\n
\n
span.sql-separator {\n
color: #666666;\n
}\n
\n
span.sql-number {\n
color: darkcyan;\n
}\n
\n
\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>543</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsesql.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
var SqlParser = Editor.Parser = (function() {\n
\n
function wordRegexp(words) {\n
return new RegExp("^(?:" + words.join("|") + ")$", "i");\n
}\n
\n
var functions = wordRegexp([\n
"abs", "acos", "adddate", "aes_encrypt", "aes_decrypt", "ascii",\n
"asin", "atan", "atan2", "avg", "benchmark", "bin", "bit_and",\n
"bit_count", "bit_length", "bit_or", "cast", "ceil", "ceiling",\n
"char_length", "character_length", "coalesce", "concat", "concat_ws",\n
"connection_id", "conv", "convert", "cos", "cot", "count", "curdate",\n
"current_date", "current_time", "current_timestamp", "current_user",\n
"curtime", "database", "date_add", "date_format", "date_sub",\n
"dayname", "dayofmonth", "dayofweek", "dayofyear", "decode", "degrees",\n
"des_encrypt", "des_decrypt", "elt", "encode", "encrypt", "exp",\n
"export_set", "extract", "field", "find_in_set", "floor", "format",\n
"found_rows", "from_days", "from_unixtime", "get_lock", "greatest",\n
"group_unique_users", "hex", "ifnull", "inet_aton", "inet_ntoa", "instr",\n
"interval", "is_free_lock", "isnull", "last_insert_id", "lcase", "least",\n
"left", "length", "ln", "load_file", "locate", "log", "log2", "log10",\n
"lower", "lpad", "ltrim", "make_set", "master_pos_wait", "max", "md5",\n
"mid", "min", "mod", "monthname", "now", "nullif", "oct", "octet_length",\n
"ord", "password", "period_add", "period_diff", "pi", "position",\n
"pow", "power", "quarter", "quote", "radians", "rand", "release_lock",\n
"repeat", "reverse", "right", "round", "rpad", "rtrim", "sec_to_time",\n
"session_user", "sha", "sha1", "sign", "sin", "soundex", "space", "sqrt",\n
"std", "stddev", "strcmp", "subdate", "substring", "substring_index",\n
"sum", "sysdate", "system_user", "tan", "time_format", "time_to_sec",\n
"to_days", "trim", "ucase", "unique_users", "unix_timestamp", "upper",\n
"user", "version", "week", "weekday", "yearweek"\n
]);\n
\n
var keywords = wordRegexp([\n
"alter", "grant", "revoke", "primary", "key", "table", "start", "top",\n
"transaction", "select", "update", "insert", "delete", "create", "describe",\n
"from", "into", "values", "where", "join", "inner", "left", "natural", "and",\n
"or", "in", "not", "xor", "like", "using", "on", "order", "group", "by",\n
"asc", "desc", "limit", "offset", "union", "all", "as", "distinct", "set",\n
"commit", "rollback", "replace", "view", "database", "separator", "if",\n
"exists", "null", "truncate", "status", "show", "lock", "unique", "having"\n
]);\n
\n
var types = wordRegexp([\n
"bigint", "binary", "bit", "blob", "bool", "char", "character", "date",\n
"datetime", "dec", "decimal", "double", "enum", "float", "float4", "float8",\n
"int", "int1", "int2", "int3", "int4", "int8", "integer", "long", "longblob",\n
"longtext", "mediumblob", "mediumint", "mediumtext", "middleint", "nchar",\n
"numeric", "real", "set", "smallint", "text", "time", "timestamp", "tinyblob",\n
"tinyint", "tinytext", "varbinary", "varchar", "year"\n
]);\n
\n
var operators = wordRegexp([\n
":=", "<", "<=", "==", "<>", ">", ">=", "like", "rlike", "in", "xor", "between"\n
]);\n
\n
var operatorChars = /[*+\\-<>=&|:\\/]/;\n
\n
var tokenizeSql = (function() {\n
function normal(source, setState) {\n
var ch = source.next();\n
if (ch == "@" || ch == "$") {\n
source.nextWhileMatches(/[\\w\\d]/);\n
return "sql-var";\n
}\n
else if (ch == "["){\n
\t setState(inAlias(ch))\n
\t \treturn null;\n
}\n
else if (ch == "\\"" || ch == "\'" || ch == "`") {\n
setState(inLiteral(ch));\n
return null;\n
}\n
else if (ch == "," || ch == ";") {\n
return "sql-separator"\n
}\n
else if (ch == \'-\') {\n
if (source.peek() == "-") {\n
while (!source.endOfLine()) source.next();\n
return "sql-comment";\n
}\n
else if (/\\d/.test(source.peek())) {\n
source.nextWhileMatches(/\\d/);\n
if (source.peek() == \'.\') {\n
source.next();\n
source.nextWhileMatches(/\\d/);\n
}\n
return "sql-number";\n
}\n
else\n
return "sql-operator";\n
}\n
else if (operatorChars.test(ch)) {\n
source.nextWhileMatches(operatorChars);\n
return "sql-operator";\n
}\n
else if (/\\d/.test(ch)) {\n
source.nextWhileMatches(/\\d/);\n
if (source.peek() == \'.\') {\n
source.next();\n
source.nextWhileMatches(/\\d/);\n
}\n
return "sql-number";\n
}\n
else if (/[()]/.test(ch)) {\n
return "sql-punctuation";\n
}\n
else {\n
source.nextWhileMatches(/[_\\w\\d]/);\n
var word = source.get(), type;\n
if (operators.test(word))\n
type = "sql-operator";\n
else if (keywords.test(word))\n
type = "sql-keyword";\n
else if (functions.test(word))\n
type = "sql-function";\n
else if (types.test(word))\n
type = "sql-type";\n
else\n
type = "sql-word";\n
return {style: type, content: word};\n
}\n
}\n
\n
function inAlias(quote) {\n
\t return function(source, setState) {\n
\t while (!source.endOfLine()) {\n
\t\t var ch = source.next();\n
\t\t if (ch == \']\') {\n
\t\t setState(normal);\n
\t\t break;\n
\t\t }\n
\t }\n
\t return "sql-word";\n
\t }\n
}\n
\n
function inLiteral(quote) {\n
return function(source, setState) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (ch == quote && !escaped) {\n
setState(normal);\n
break;\n
}\n
escaped = !escaped && ch == "\\\\";\n
}\n
return quote == "`" ? "sql-word" : "sql-literal";\n
};\n
}\n
\n
return function(source, startState) {\n
return tokenizer(source, startState || normal);\n
};\n
})();\n
\n
function indentSql(context) {\n
return function(nextChars) {\n
var firstChar = nextChars && nextChars.charAt(0);\n
var closing = context && firstChar == context.type;\n
if (!context)\n
return 0;\n
else if (context.align)\n
return context.col - (closing ? context.width : 0);\n
else\n
return context.indent + (closing ? 0 : indentUnit);\n
}\n
}\n
\n
function parseSql(source) {\n
var tokens = tokenizeSql(source);\n
var context = null, indent = 0, col = 0;\n
function pushContext(type, width, align) {\n
context = {prev: context, indent: indent, col: col, type: type, width: width, align: align};\n
}\n
function popContext() {\n
context = context.prev;\n
}\n
\n
var iter = {\n
next: function() {\n
var token = tokens.next();\n
var type = token.style, content = token.content, width = token.value.length;\n
\n
if (content == "\\n") {\n
token.indentation = indentSql(context);\n
indent = col = 0;\n
if (context && context.align == null) context.align = false;\n
}\n
else if (type == "whitespace" && col == 0) {\n
indent = width;\n
}\n
else if (!context && type != "sql-comment") {\n
pushContext(";", 0, false);\n
}\n
\n
if (content != "\\n") col += width;\n
\n
if (type == "sql-punctuation") {\n
if (content == "(")\n
pushContext(")", width);\n
else if (content == ")")\n
popContext();\n
}\n
else if (type == "sql-separator" && content == ";" && context && !context.prev) {\n
popContext();\n
}\n
\n
return token;\n
},\n
\n
copy: function() {\n
var _context = context, _indent = indent, _col = col, _tokenState = tokens.state;\n
return function(source) {\n
tokens = tokenizeSql(source, _tokenState);\n
context = _context;\n
indent = _indent;\n
col = _col;\n
return iter;\n
};\n
}\n
};\n
return iter;\n
}\n
\n
return {make: parseSql, electricChars: ")"};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>7816</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>xquery</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>xqcolors-dark.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: white;\n
background-color: black;\n
line-height: 16px;\n
}\n
\n
span.word {\n
color:white;\n
}\n
\n
span.xqueryKeyword {\n
color: #ffbd40; \n
/* font-weight: bold; */\n
}\n
\n
span.xqueryComment {\n
color: #CDCDCD;\n
font-style:italic;\n
}\n
\n
span.xqueryModifier {\n
color:#6c8cd5;\n
font-weight: bold;\n
}\n
\n
span.xqueryType {\n
color:#6c8cd5;\n
font-weight: bold;\n
}\n
\n
span.xqueryAtom {\n
color:#6c8cd5;\n
font-weight: bold; \n
}\n
\n
span.xqueryString {\n
color: #9fee00;\n
}\n
\n
span.xqueryRegexp {\n
color: rgb(128,0,64);\n
}\n
\n
span.xqueryNumber {\n
color: rgb(255,0,0); \n
}\n
\n
span.xqueryVariable {\n
\n
}\n
\n
span.xqueryFunction {\n
color:#FFF700;\n
}\n
\n
span.xqueryLocalvariable {\n
color: white;\n
}\n
\n
span.xqueryProperty\n
{\n
color: white;\n
}\n
\n
span.xqueryOperator {\n
color: orange;\n
}\n
\n
span.xqueryPunctuation {\n
color: white;\n
}\n
\n
span.xquery-doc-directive {\n
color: white; \n
}\n
\n
span.xml-tagname {\n
color: #ffbd40; ;\n
}\n
\n
span.xml-attribute {\n
color: #FFF700;\n
}\n
\n
span.xml-attribute-value {\n
color: #FFF700;\n
font-style:italic;\n
}</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1091</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>xqcolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>/*\n
Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort)\n
\n
Licensed under the Apache License, Version 2.0 (the "License");\n
you may not use this file except in compliance with the License.\n
You may obtain a copy of the License at\n
\n
http://www.apache.org/licenses/LICENSE-2.0\n
\n
Unless required by applicable law or agreed to in writing, software\n
distributed under the License is distributed on an "AS IS" BASIS,\n
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n
See the License for the specific language governing permissions and\n
limitations under the License.\n
\n
This is an indirect collective derivative of the other parses in this package\n
\n
*/\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
background-color: white;\n
line-height: 16px;\n
}\n
\n
span.word {\n
}\n
\n
span.xqueryKeyword {\n
color: red; /* #1240AB; */\n
/* font-weight: bold; */\n
}\n
\n
span.xqueryComment {\n
color: gray;\n
font-style: italic;\n
}\n
\n
span.xqueryModifier {\n
color: rgb(0,102,153);\n
font-weight: bold;\n
}\n
\n
span.xqueryType {\n
color: purple;\n
font-weight: bold;\n
}\n
\n
span.xqueryAtom {\n
color: rgb(0,102,153);\n
font-weight: bold; \n
}\n
\n
span.xqueryString {\n
color: green;\n
}\n
\n
span.xqueryRegexp {\n
color: rgb(128,0,64);\n
}\n
\n
span.xqueryNumber {\n
color: #1240AB;\n
}\n
\n
span.xqueryVariable {\n
/* color: red; */\n
}\n
\n
span.xqueryFunction {\n
color: #1240AB; \n
/* font-weight:bold; */ \n
}\n
\n
\n
span.xqueryOperator {\n
color: red;\n
}\n
\n
span.xqueryPunctuation {\n
color: DIMGray;\n
}\n
\n
span.xml-tagname {\n
color: purple;\n
}\n
\n
span.xml-attribute {\n
color: purple;\n
font-style:italic;\n
}\n
\n
span.xml-attribute-value {\n
color: purple;\n
font-style:italic;\n
}</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1714</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>xqcolors2.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>/*\n
Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort)\n
\n
Licensed under the Apache License, Version 2.0 (the "License");\n
you may not use this file except in compliance with the License.\n
You may obtain a copy of the License at\n
\n
http://www.apache.org/licenses/LICENSE-2.0\n
\n
Unless required by applicable law or agreed to in writing, software\n
distributed under the License is distributed on an "AS IS" BASIS,\n
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n
See the License for the specific language governing permissions and\n
limitations under the License.\n
\n
This is an indirect collective derivative of the other parses in this package\n
\n
*/\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
background-color: white;\n
line-height: 16px;\n
}\n
\n
span.word {\n
}\n
\n
span.xqueryKeyword {\n
color: blue; \n
/* font-weight: bold; */\n
}\n
\n
span.xqueryComment {\n
color: gray;\n
}\n
\n
span.xqueryModifier {\n
color: rgb(0,102,153);\n
font-weight: bold;\n
}\n
\n
span.xqueryType {\n
color: rgb(0,135,255);\n
font-weight: bold;\n
}\n
\n
span.xqueryAtom {\n
color: rgb(0,102,153);\n
font-weight: bold; \n
}\n
\n
span.xqueryString {\n
color: green;\n
}\n
\n
span.xqueryRegexp {\n
color: rgb(128,0,64);\n
}\n
\n
span.xqueryNumber {\n
color: rgb(255,0,0); \n
}\n
\n
span.xqueryVariable {\n
color: red;\n
}\n
\n
span.xqueryFunction {\n
text-decoration:underline\n
}\n
\n
\n
span.xqueryOperator {\n
color: DimGray;\n
}\n
\n
span.xqueryPunctuation {\n
}\n
\n
span.xml-tagname {\n
color: purple;\n
}\n
\n
span.xml-attribute {\n
color: purple;\n
font-style:italic;\n
}\n
\n
span.xml-attribute-value {\n
color: purple;\n
font-style:italic;\n
}</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1647</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsexquery.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort)\n
\n
Licensed under the Apache License, Version 2.0 (the "License");\n
you may not use this file except in compliance with the License.\n
You may obtain a copy of the License at\n
\n
http://www.apache.org/licenses/LICENSE-2.0\n
\n
Unless required by applicable law or agreed to in writing, software\n
distributed under the License is distributed on an "AS IS" BASIS,\n
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n
See the License for the specific language governing permissions and\n
limitations under the License.\n
\n
This is an indirect collective derivative of the other parses in this package\n
\n
*/\n
\n
// The XQuery parser uses the xquery tokenizer in tokenizexquery.js. Given the\n
// stream of tokens, it makes decisions to override the tokens styles by evaluating\n
// it\'s context with respect to the other tokens. \n
\n
var XqueryParser = Editor.Parser = (function() {\n
function xqueryLexical(startColumn, currentToken, align, previousToken, encloseLevel) {\n
this.startColumn = startColumn;\n
this.currentToken = currentToken;\n
if (align != null)\n
this.align = align;\n
this.previousToken = previousToken;\n
this.encloseLevel = encloseLevel;\n
}\n
\n
// Xquery indentation rules.\n
function indentXquery(lexical) {\n
return function(firstChars, curIndent, direction) {\n
// test if this is next row after the open brace\n
if (lexical.encloseLevel !== 0 && firstChars === "}") {\n
return lexical.startColumn - indentUnit;\n
}\n
\n
return lexical.startColumn;\n
};\n
}\n
\n
function parseXquery(source) {\n
var tokens = tokenizeXquery(source);\n
\n
var column = 0;\n
// tells the first non-whitespace symbol from the\n
// start of row.\n
var previousToken = null;\n
var previousTokens = [];\n
//mb\n
var align = false;\n
// tells if the text after the open brace\n
var encloseLevel = 0;\n
// tells curent opened braces quantity\n
var cc = [statements];\n
var consume,\n
marked;\n
\n
var iter = {\n
next: function() {\n
var token = tokens.next();\n
\n
// since attribute and elements can be named the same, assume the\n
// following word of each is a variable\n
if (previousToken && (previousToken.content == "attribute" || previousToken.content == "element") && previousToken.type == "xqueryKeywordC") {\n
token.type = "variable";\n
token.style = "xqueryVariable";\n
}\n
\n
else if (previousToken && previousToken.content == "xquery" && token.content == "version") {\n
//token.type="variable";\n
token.style = "xqueryModifier";\n
}\n
\n
else if (token.type == "word" && (getPrevious(3).style == "xml-attribute" || previousToken.type == "xml-tag-open") &&\n
previousToken.content.substring(previousToken.content.length - 1) != ">") {\n
token.style = "xml-attribute";\n
}\n
else if (previousToken && previousToken.content == "=" && previousTokens.length > 2\n
&& getPrevious(2).style == "xml-attribute") {\n
token.style = "xml-attribute-value";\n
}\n
else if(token.type == "string" && previousToken.type == "}") {\n
// looking for expressions within a string and detecting if the expression is within an attribute\n
var i=0;\n
while(i++ < previousTokens.length-1) {\n
if(getPrevious(i).style == "xml-attribute-value" ) {\n
token.style = "xml-attribute-value";\n
break;\n
} \n
else if(getPrevious(i).type == "string") {\n
break;\n
} \n
}\n
} \n
else if(token.type == "string") {\n
// brute force check for strings inside XML TODO... something else\n
var i=0;\n
var closeCount = 0;\n
while(i++ < previousTokens.length-1) {\n
var prev = getPrevious(i); \n
if(prev.type == "xml-tag-open") {\n
if(closeCount == 0) {\n
token.style = "word";\n
break;\n
} else {\n
closeCount--;\n
}\n
} \n
else if(prev.type == "xml-tag-close") {\n
closeCount++;\n
}\n
else if(prev.content == ":=" || prev.content == "return" || prev.content == "{")\n
break;\n
}\n
}\n
else if(getPrevious(2).content == "module" && getPrevious(1).content == "namespace") \n
token.style="xqueryFunction";\n
else if(token.content == "=" && getPrevious(1).style == "xml-attribute")\n
token.style="xml-attribute"\n
\n
if (token.type == "whitespace") {\n
if (token.value == "\\n") {\n
// test if this is end of line\n
if (previousToken !== null) {\n
if (previousToken.type === "{") {\n
// test if there is open brace at the end of line\n
align = true;\n
column += indentUnit;\n
encloseLevel++;\n
}\n
else\n
if (previousToken.type === "}") {\n
// test if there is close brace at the end of line\n
align = false;\n
if (encloseLevel > 0) {\n
encloseLevel--;\n
}\n
else {\n
encloseLevel = 0;\n
}\n
}\n
var lexical = new xqueryLexical(column, token, align, previousToken, encloseLevel);\n
token.indentation = indentXquery(lexical);\n
}\n
}\n
else\n
column = token.value.length;\n
}\n
\n
// maintain the previous tokens array so that it doesn\'t continue to leak\n
// keep only the last 5000\n
if(previousTokens.length > 5000) previousTokens.shift();\n
\n
while (true) {\n
consume = marked = false;\n
// Take and execute the topmost action.\n
cc.pop()(token.type, token.content);\n
if (consume) {\n
// Marked is used to change the style of the current token.\n
if (marked)\n
token.style = marked;\n
// Here we differentiate between local and global variables.\n
previousToken = token;\n
previousTokens[previousTokens.length] = token;\n
return token;\n
}\n
}\n
\n
},\n
\n
copy: function() {\n
var _cc = cc.concat([]),\n
_tokenState = tokens.state,\n
_column = column;\n
\n
return function copyParser(_source) {\n
cc = _cc.concat([]);\n
column = indented = _column;\n
tokens = tokenizeXquery(_source, _tokenState);\n
return iter;\n
};\n
\n
},\n
\n
};\n
\n
function statements(type) {\n
return pass(statement, statements);\n
}\n
\n
function statement(type) {\n
cont();\n
}\n
\n
function push(fs) {\n
for (var i = fs.length - 1; i >= 0; i--)\n
cc.push(fs[i]);\n
}\n
\n
function cont() {\n
push(arguments);\n
consume = true;\n
}\n
\n
function pass() {\n
push(arguments);\n
consume = false;\n
}\n
\n
\n
function getPrevious(numberFromCurrent) {\n
var l = previousTokens.length;\n
if (l - numberFromCurrent >= 0)\n
return previousTokens[l - numberFromCurrent];\n
else\n
return {\n
type: "",\n
style: "",\n
content: ""\n
};\n
}\n
\n
return iter;\n
\n
\n
}\n
return {\n
make: parseXquery\n
};\n
})();
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>9006</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>tokenizexquery.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort)\n
\n
Licensed under the Apache License, Version 2.0 (the "License");\n
you may not use this file except in compliance with the License.\n
You may obtain a copy of the License at\n
\n
http://www.apache.org/licenses/LICENSE-2.0\n
\n
Unless required by applicable law or agreed to in writing, software\n
distributed under the License is distributed on an "AS IS" BASIS,\n
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n
See the License for the specific language governing permissions and\n
limitations under the License.\n
\n
This is an indirect collective derivative of the other parses in this package\n
\n
*/\n
\n
// A tokenizer for xQuery, looks at the source stream and tokenizes, applying\n
// metadata to be able to apply the proper CSS classes in the parser.\n
\n
var tokenizeXquery = (function() {\n
// Advance the stream until the given character (not preceded by a\n
// backslash) is encountered, or the end of the line is reached.\n
function nextUntilUnescaped(source, end) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var next = source.next();\n
if (next == end && !escaped)\n
return false;\n
escaped = !escaped && next == "\\\\";\n
console.debug(escaped);\n
}\n
return escaped;\n
}\n
\n
// A map of Xquery\'s keywords. The a/b/c keyword distinction is\n
// very rough, but it gives the parser enough information to parse\n
// correct code correctly (we don\'t care that much how we parse\n
// incorrect code). The style information included in these objects\n
// is used by the highlighter to pick the correct CSS style for a\n
// token.\n
var keywords = function() {\n
function result(type, style) {\n
return {\n
type: type,\n
style: style\n
};\n
}\n
\n
var allKeywords = {};\n
var keywordsList = {};\n
\n
// an array of all of the keywords that will be used by default, otherwise keywords will be more specifically specified and overridden below\n
var allKeywordsArray = new Array(\'after\',\'ancestor\',\'ancestor-or-self\',\'and\',\'as\',\'ascending\',\'assert\',\'attribute\',\'before\',\'by\',\'case\',\'cast\',\'child\',\'comment\',\'comment\',\'declare\',\'default\',\'define\',\'descendant\',\'descendant-or-self\',\'descending\',\'document-node\',\'element\',\'element\',\'else\',\'eq\',\'every\',\'except\',\'external\',\'following\',\'following-sibling\',\'follows\',\'for\',\'function\',\'if\',\'import\',\'in\',\'instance\',\'intersect\',\'item\',\'let\',\'module\',\'namespace\',\'node\',\'node\',\'of\',\'only\',\'or\',\'order\',\'parent\',\'precedes\',\'preceding\',\'preceding-sibling\',\'processing-instruction\',\'ref\',\'return\',\'returns\',\'satisfies\',\'schema\',\'schema-element\',\'self\',\'some\',\'sortby\',\'stable\',\'text\',\'then\',\'to\',\'treat\',\'typeswitch\',\'union\',\'variable\',\'version\',\'where\',\'xquery\');\n
\n
for(var i in allKeywordsArray) {\n
allKeywords[allKeywordsArray[i]] = result("keyword", "xqueryKeyword");\n
}\n
\n
/* This next bit is broken down this was for future indentation support */\n
// keywords that take a parenthised expression, and then a statement (if)\n
keywordsList[\'xqueryKeywordA\'] = new Array(\'if\', \'switch\', \'while\', \'for\');\n
\n
// keywords that take just a statement (else)\n
keywordsList[\'xqueryKeywordB\'] = new Array(\'else\', \'then\', \'try\', \'finally\');\n
\n
// keywords that optionally take an expression, and form a statement (return)\n
keywordsList[\'xqueryKeywordC\'] = new Array(\'element\', \'attribute\', \'let\', \'implements\', \'import\', \'module\', \'namespace\', \'return\', \'super\', \'this\', \'throws\', \'where\');\n
\n
keywordsList[\'xqueryOperator\'] = new Array(\'eq\', \'ne\', \'lt\', \'le\', \'gt\', \'ge\');\n
\n
for (var keywordType in keywordsList) {\n
for (var i = 0; i < keywordsList[keywordType].length; i++) {\n
allKeywords[keywordsList[keywordType][i]] = result(keywordType, "xqueryKeyword");\n
}\n
}\n
\n
keywordsList = {};\n
\n
keywordsList[\'xqueryAtom\'] = new Array(\'null\', \'fn:false()\', \'fn:true()\');\n
for (var keywordType in keywordsList) {\n
for (var i = 0; i < keywordsList[keywordType].length; i++) {\n
allKeywords[keywordsList[keywordType][i]] = result(keywordType, keywordType);\n
}\n
}\n
\n
keywordsList = {};\n
keywordsList[\'xqueryModifier\'] = new Array(\'xquery\', \'ascending\', \'descending\');\n
keywordsList[\'xqueryType\'] = new Array(\'xs:string\', \'xs:float\', \'xs:decimal\', \'xs:double\', \'xs:integer\', \'xs:boolean\', \'xs:date\', \'xs:dateTime\', \'xs:time\', \'xs:duration\', \'xs:dayTimeDuration\', \'xs:time\', \'xs:yearMonthDuration\', \'numeric\', \'xs:hexBinary\', \'xs:base64Binary\', \'xs:anyURI\', \'xs:QName\', \'xs:byte\',\'xs:boolean\',\'xs:anyURI\',\'xf:yearMonthDuration\');\n
for (var keywordType in keywordsList) {\n
for (var i = 0; i < keywordsList[keywordType].length; i++) {\n
allKeywords[keywordsList[keywordType][i]] = result(\'function\', keywordType);\n
}\n
}\n
\n
allKeywords = objectConcat(allKeywords, {\n
"catch": result("catch", "xqueryKeyword"),\n
"for": result("for", "xqueryKeyword"),\n
"case": result("case", "xqueryKeyword"),\n
"default": result("default", "xqueryKeyword"),\n
"instanceof": result("operator", "xqueryKeyword")\n
});\n
\n
// ------------------- xquery keywords\n
var keywordsList = {};\n
\n
// keywords that optionally take an expression, and form a statement (return)\n
keywordsList[\'xqueryKeywordC\'] = new Array(\'assert\', \'property\');\n
for (var i = 0; i < keywordsList[\'xqueryKeywordC\'].length; i++) {\n
allKeywords[keywordsList[\'xqueryKeywordC\'][i]] = result("xqueryKeywordC", "xqueryKeyword");\n
}\n
\n
// other xquery keywords\n
allKeywords = objectConcat(allKeywords, {\n
"as": result("operator", "xqueryKeyword"),\n
"in": result("operator", "xqueryKeyword"),\n
"at": result("operator", "xqueryKeyword"),\n
"declare": result("function", "xqueryKeyword"),\n
"function": result("function", "xqueryKeyword")\n
});\n
return allKeywords;\n
} ();\n
\n
// there are some special cases where ordinarily text like xs:string() would\n
// look like a function call when it is really a type, etc.\n
function specialCases(source, word) {\n
if (word in {\n
"fn:true": "",\n
"fn:false": ""\n
} && source.lookAhead("()", false)) {\n
source.next();\n
source.next();\n
source.get();\n
return {\n
type: "function",\n
style: "xqueryAtom",\n
content: word + "()"\n
};\n
}\n
else if (word in {\n
"node": "",\n
"item": "",\n
"text": ""\n
} && source.lookAhead("()", false)) {\n
source.next();\n
source.next();\n
source.get();\n
return {\n
type: "function",\n
style: "xqueryType",\n
content: word + "()"\n
};\n
}\n
else if (source.lookAhead("(")) {\n
return {\n
type: "function",\n
style: "xqueryFunction",\n
content: word\n
};\n
}\n
else return null;\n
}\n
\n
// Some helper regexp matchers.\n
var isOperatorChar = /[=+\\-*&%!?@\\/]/; \n
var isDigit = /[0-9]/;\n
var isHexDigit = /^[0-9A-Fa-f]$/;\n
var isWordChar = /[\\w\\:\\-\\$_]/;\n
var isVariableChar = /[\\w\\$_-]/;\n
var isXqueryVariableChar = /[\\w\\.()\\[\\]{}]/;\n
var isPunctuation = /[\\[\\]{}\\(\\),;\\.]/;\n
var isStringDelimeter = /^[\\/\'"]$/;\n
var isRegexpDelimeter = /^[\\/\'$]/;\n
var tagnameChar = /[<\\w\\:\\-\\/_]/;\n
\n
// Wrapper around xqueryToken that helps maintain parser state (whether\n
// we are inside of a multi-line comment and whether the next token\n
// could be a regular expression).\n
function xqueryTokenState(inside, regexp) {\n
return function(source, setState) {\n
var newInside = inside;\n
var type = xqueryToken(inside, regexp, source,\n
function(c) {\n
newInside = c;\n
});\n
var newRegexp = type.type == "operator" || type.type == "xqueryKeywordC" || type.type == "xqueryKeywordC" || type.type.match(/^[\\[{}\\(,;:]$/);\n
if (newRegexp != regexp || newInside != inside)\n
setState(xqueryTokenState(newInside, newRegexp));\n
return type;\n
};\n
}\n
\n
// The token reader, inteded to be used by the tokenizer from\n
// tokenize.js (through xqueryTokenState). Advances the source stream\n
// over a token, and returns an object containing the type and style\n
// of that token.\n
function xqueryToken(inside, regexp, source, setInside) {\n
function readHexNumber() {\n
setInside(null);\n
source.next();\n
// skip the \'x\'\n
source.nextWhileMatches(isHexDigit);\n
return {\n
type: "number",\n
style: "xqueryNumber"\n
};\n
}\n
\n
function readNumber() {\n
setInside(null);\n
source.nextWhileMatches(isDigit);\n
if (source.equals(".")) {\n
source.next();\n
\n
// read ranges\n
if (source.equals("."))\n
source.next();\n
\n
source.nextWhileMatches(isDigit);\n
}\n
if (source.equals("e") || source.equals("E")) {\n
source.next();\n
if (source.equals("-"))\n
source.next();\n
source.nextWhileMatches(isDigit);\n
}\n
return {\n
type: "number",\n
style: "xqueryNumber"\n
};\n
}\n
// Read a word, look it up in keywords. If not found, it is a\n
// variable, otherwise it is a keyword of the type found.\n
function readWord() {\n
//setInside(null);\n
source.nextWhileMatches(isWordChar);\n
var word = source.get();\n
var specialCase = specialCases(source, word);\n
if (specialCase) return specialCase;\n
var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];\n
if (known) return {\n
type: known.type,\n
style: known.style,\n
content: word\n
}\n
return {\n
type: "word",\n
style: "word",\n
content: word\n
};\n
}\n
\n
\n
// read regexp like /\\w{1}:\\\\.+\\\\.+/\n
function readRegexp() {\n
// go to the end / not \\/\n
nextUntilUnescaped(source, "/");\n
\n
return {\n
type: "regexp",\n
style: "xqueryRegexp"\n
};\n
}\n
\n
// Mutli-line comments are tricky. We want to return the newlines\n
// embedded in them as regular newline tokens, and then continue\n
// returning a comment token for every line of the comment. So\n
// some state has to be saved (inside) to indicate whether we are\n
// inside a (: :) sequence.\n
function readMultilineComment(start) {\n
var newInside = "(:";\n
var maybeEnd = (start == ":");\n
while (true) {\n
if (source.endOfLine())\n
break;\n
var next = source.next();\n
if (next == ")" && maybeEnd) {\n
newInside = null;\n
break;\n
}\n
maybeEnd = (next == ":");\n
}\n
setInside(newInside);\n
return {\n
type: "comment",\n
style: "xqueryComment"\n
};\n
}\n
\n
function readOperator() {\n
if (ch == "=")\n
setInside("=")\n
else if (ch == "~")\n
setInside("~")\n
else if (ch == ":" && source.equals("=")) {\n
setInside(null);\n
source.nextWhileMatches(/[:=]/);\n
var word = source.get();\n
return {\n
type: "operator",\n
style: "xqueryOperator",\n
content: word\n
};\n
}\n
else setInside(null);\n
\n
return {\n
type: "operator",\n
style: "xqueryOperator"\n
};\n
}\n
\n
// read a string, but look for embedded expressions wrapped in curly\n
// brackets. \n
function readString(quote) {\n
var newInside = quote;\n
var previous = "";\n
while (true) {\n
if (source.endOfLine())\n
break;\n
if(source.lookAhead("{", false)) {\n
newInside = quote + "{";\n
break;\n
} \n
var next = source.next();\n
if (next == quote && previous != "\\\\") {\n
newInside = null;\n
break;\n
}\n
previous = next;\n
}\n
setInside(newInside);\n
return {\n
type: "string",\n
style: "xqueryString"\n
};\n
}\n
\n
// Given an expression end by a closing curly bracket, mark the } as\n
// punctuation an resume the string processing by setting "inside" to\n
// the type of string it\'s embedded in. \n
// This is known because the readString() function sets inside to the \n
// quote type then an open curly bracket like "{ or \'{\n
function readExpressionEndInString(inside) {\n
var quote = inside.substr(0,1);\n
setInside(quote);\n
return { type: ch, style: "xqueryPunctuation"}; \n
}\n
\n
function readVariable() {\n
//setInside(null);\n
source.nextWhileMatches(isVariableChar);\n
var word = source.get();\n
return {\n
type: "variable",\n
style: "xqueryVariable",\n
content: word\n
};\n
}\n
\n
// read an XML Tagname, both closing and opening\n
function readTagname(lt) {\n
var tagtype = (source.lookAhead("/", false)) ? "xml-tag-close": "xml-tag-open";\n
source.nextWhileMatches(tagnameChar);\n
var word = source.get();\n
if (source.lookAhead(">", false)) {\n
source.next();\n
}\n
return {\n
type: tagtype,\n
style: "xml-tagname",\n
content: word\n
};\n
}\n
\n
// Fetch the next token. Dispatches on first character in the stream\n
// what follows is a big if statement that makes decisions based on the \n
// character, the following character and the inside variable\n
\n
if (inside == "\\"" || inside == "\'")\n
return readString(inside);\n
\n
var ch = source.next();\n
if (inside && inside.indexOf("{") == 1 && ch == "}") {\n
return readExpressionEndInString(inside);\n
} \n
if (inside == "(:")\n
return readMultilineComment(ch);\n
else if (ch == "\\"" || ch == "\'")\n
return readString(ch);\n
\n
\n
// test if this is range\n
else if (ch == "." && source.equals(".")) {\n
source.next();\n
return {\n
type: "..",\n
style: "xqueryOperator"\n
};\n
}\n
\n
else if (ch == "(" && source.equals(":")) {\n
source.next();\n
return readMultilineComment(ch);\n
}\n
else if (ch == "$")\n
return readVariable();\n
else if (ch == ":" && source.equals("="))\n
return readOperator();\n
\n
// with punctuation, the type of the token is the symbol itself\n
else if (isPunctuation.test(ch))\n
return {\n
type: ch,\n
style: "xqueryPunctuation"\n
};\n
else if (ch == "0" && (source.equals("x") || source.equals("X")))\n
return readHexNumber();\n
else if (isDigit.test(ch))\n
return readNumber();\n
\n
else if (ch == "~") {\n
setInside("~");\n
// prepare to read slashy string like ~ /\\w{1}:\\\\.+\\\\.+/\n
return readOperator(ch);\n
}\n
else if (isOperatorChar.test(ch)) {\n
return readOperator(ch); \n
}\n
// some xml handling stuff\n
else if (ch == "<")\n
return readTagname(ch);\n
else if (ch == ">")\n
return {\n
type: "xml-tag",\n
style: "xml-tagname"\n
};\n
else\n
return readWord();\n
}\n
\n
// returns new object = object1 + object2\n
function objectConcat(object1, object2) {\n
for (var name in object2) {\n
if (!object2.hasOwnProperty(name)) continue;\n
if (object1.hasOwnProperty(name)) continue;\n
object1[name] = object2[name];\n
}\n
return object1;\n
}\n
\n
// The external interface to the tokenizer.\n
return function(source, startState) {\n
return tokenizer(source, startState || xqueryTokenState(false, true));\n
};\n
})();
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>17333</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>csscolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
pre.code, .editbox {\n
color: #666;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.css-at {\n
color: #708;\n
}\n
\n
span.css-unit {\n
color: #281;\n
}\n
\n
span.css-value {\n
color: #708;\n
}\n
\n
span.css-identifier {\n
color: black;\n
}\n
\n
span.css-selector {\n
color: #11B;\n
}\n
\n
span.css-important {\n
color: #00F;\n
}\n
\n
span.css-colorcode {\n
color: #299;\n
}\n
\n
span.css-comment {\n
color: #A70;\n
}\n
\n
span.css-string {\n
color: #A22;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>529</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>docs.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>body {\n
font-family: Droid Sans, Arial, sans-serif;\n
line-height: 1.5;\n
max-width: 64.3em;\n
margin: 3em auto;\n
padding: 0 1em;\n
}\n
\n
h1 {\n
letter-spacing: -3px;\n
font-size: 3.23em;\n
font-weight: bold;\n
margin: 0;\n
}\n
\n
h2 {\n
font-size: 1.23em;\n
font-weight: bold;\n
margin: .5em 0;\n
letter-spacing: -1px;\n
}\n
\n
h3 {\n
font-size: 1em;\n
font-weight: bold;\n
margin: .4em 0;\n
}\n
\n
pre {\n
font-family: Droid Sans Mono, Courier New, monospaced;\n
background-color: #eee;\n
-moz-border-radius: 6px;\n
-webkit-border-radius: 6px;\n
border-radius: 6px;\n
padding: 1em;\n
}\n
\n
pre.code {\n
margin: 0 1em;\n
}\n
\n
.grey {\n
font-size: 2em;\n
padding: .5em 1em;\n
line-height: 1.2em;\n
margin-top: .5em;\n
}\n
\n
a:link, a:visited, .quasilink {\n
color: #df0019;\n
cursor: pointer;\n
text-decoration: none;\n
}\n
\n
a:hover {\n
color: #800004;\n
}\n
\n
ul {\n
margin: 0;\n
padding-left: 1.2em;\n
}\n
\n
a.download {\n
color: white;\n
background-color: #df0019;\n
width: 100%;\n
display: block;\n
text-align: center;\n
font-size: 1.23em;\n
font-weight: bold;\n
text-decoration: none;\n
-moz-border-radius: 6px;\n
-webkit-border-radius: 6px;\n
border-radius: 6px;\n
padding: .5em 0;\n
margin-bottom: 1em;\n
}\n
\n
a.download:hover {\n
background-color: #bb0010;\n
}\n
\n
.rel {\n
margin-bottom: 0;\n
}\n
\n
.rel-note {\n
color: #777;\n
font-size: .9em;\n
margin-top: .1em;\n
}\n
\n
.logo-braces {\n
color: #df0019;\n
position: relative;\n
top: -4px;\n
}\n
\n
.blk {\n
float: left;\n
}\n
\n
.left {\n
width: 37em;\n
padding-right: 6.53em;\n
padding-bottom: 1em;\n
}\n
\n
.left1 {\n
width: 15.24em;\n
padding-right: 6.45em;\n
}\n
\n
.left2 {\n
width: 15.24em;\n
}\n
\n
.right {\n
width: 20.68em;\n
}\n
\n
.leftbig {\n
width: 42.44em;\n
padding-right: 6.53em;\n
}\n
\n
.rightsmall {\n
width: 15.24em;\n
}\n
\n
.clear:after {\n
visibility: hidden;\n
display: block;\n
font-size: 0;\n
content: " ";\n
clear: both;\n
height: 0;\n
}\n
.clear { display: inline-block; }\n
/* start commented backslash hack \\*/\n
* html .clear { height: 1%; }\n
.clear { display: block; }\n
/* close commented backslash hack */\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1974</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>jscolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
pre.code, .editbox {\n
color: #666666;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.js-punctuation {\n
color: #666666;\n
}\n
\n
span.js-operator {\n
color: #666666;\n
}\n
\n
span.js-keyword {\n
color: #770088;\n
}\n
\n
span.js-atom {\n
color: #228811;\n
}\n
\n
span.js-variable {\n
color: black;\n
}\n
\n
span.js-variabledef {\n
color: #0000FF;\n
}\n
\n
span.js-localvariable {\n
color: #004499;\n
}\n
\n
span.js-property {\n
color: black;\n
}\n
\n
span.js-comment {\n
color: #AA7700;\n
}\n
\n
span.js-string {\n
color: #AA2222;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>600</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>sparqlcolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.sp-keyword {\n
color: #708;\n
}\n
\n
span.sp-prefixed {\n
color: #5d1;\n
}\n
\n
span.sp-var {\n
color: #00c;\n
}\n
\n
span.sp-comment {\n
color: #a70;\n
}\n
\n
span.sp-literal {\n
color: #a22;\n
}\n
\n
span.sp-uri {\n
color: #292;\n
}\n
\n
span.sp-operator {\n
color: #088;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>405</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>xmlcolors.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>html {\n
cursor: text;\n
}\n
\n
.editbox {\n
margin: .4em;\n
padding: 0;\n
font-family: monospace;\n
font-size: 10pt;\n
color: black;\n
}\n
\n
.editbox p {\n
margin: 0;\n
}\n
\n
span.xml-tagname {\n
color: #A0B;\n
}\n
\n
span.xml-attribute {\n
color: #281;\n
}\n
\n
span.xml-punctuation {\n
color: black;\n
}\n
\n
span.xml-attname {\n
color: #00F;\n
}\n
\n
span.xml-comment {\n
color: #A70;\n
}\n
\n
span.xml-cdata {\n
color: #48A;\n
}\n
\n
span.xml-processing {\n
color: #999;\n
}\n
\n
span.xml-entity {\n
color: #A22;\n
}\n
\n
span.xml-error {\n
color: #F00 !important;\n
}\n
\n
span.xml-text {\n
color: black;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>542</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>codemirror.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* CodeMirror main module (http://codemirror.net/)\n
*\n
* Implements the CodeMirror constructor and prototype, which take care\n
* of initializing the editor frame, and providing the outside interface.\n
*/\n
\n
// The CodeMirrorConfig object is used to specify a default\n
// configuration. If you specify such an object before loading this\n
// file, the values you put into it will override the defaults given\n
// below. You can also assign to it after loading.\n
var CodeMirrorConfig = window.CodeMirrorConfig || {};\n
\n
var CodeMirror = (function(){\n
function setDefaults(object, defaults) {\n
for (var option in defaults) {\n
if (!object.hasOwnProperty(option))\n
object[option] = defaults[option];\n
}\n
}\n
function forEach(array, action) {\n
for (var i = 0; i < array.length; i++)\n
action(array[i]);\n
}\n
\n
// These default options can be overridden by passing a set of\n
// options to a specific CodeMirror constructor. See manual.html for\n
// their meaning.\n
setDefaults(CodeMirrorConfig, {\n
stylesheet: [],\n
path: "",\n
parserfile: [],\n
basefiles: ["util.js", "stringstream.js", "select.js", "undo.js", "editor.js", "tokenize.js"],\n
iframeClass: null,\n
passDelay: 200,\n
passTime: 50,\n
lineNumberDelay: 200,\n
lineNumberTime: 50,\n
continuousScanning: false,\n
saveFunction: null,\n
onChange: null,\n
undoDepth: 50,\n
undoDelay: 800,\n
disableSpellcheck: true,\n
textWrapping: true,\n
readOnly: false,\n
width: "",\n
height: "300px",\n
minHeight: 100,\n
autoMatchParens: false,\n
parserConfig: null,\n
tabMode: "indent", // or "spaces", "default", "shift"\n
enterMode: "indent", // or "keep", "flat"\n
electricChars: true,\n
reindentOnLoad: false,\n
activeTokens: null,\n
cursorActivity: null,\n
lineNumbers: false,\n
firstLineNumber: 1,\n
indentUnit: 2,\n
domain: null\n
});\n
\n
function addLineNumberDiv(container, firstNum) {\n
var nums = document.createElement("DIV"),\n
scroller = document.createElement("DIV");\n
nums.style.position = "absolute";\n
nums.style.height = "100%";\n
if (nums.style.setExpression) {\n
try {nums.style.setExpression("height", "this.previousSibling.offsetHeight + \'px\'");}\n
catch(e) {} // Seems to throw \'Not Implemented\' on some IE8 versions\n
}\n
nums.style.top = "0px";\n
nums.style.left = "0px";\n
nums.style.overflow = "hidden";\n
container.appendChild(nums);\n
scroller.className = "CodeMirror-line-numbers";\n
nums.appendChild(scroller);\n
scroller.innerHTML = "<div>" + firstNum + "</div>";\n
return nums;\n
}\n
\n
function frameHTML(options) {\n
if (typeof options.parserfile == "string")\n
options.parserfile = [options.parserfile];\n
if (typeof options.basefiles == "string")\n
options.basefiles = [options.basefiles];\n
if (typeof options.stylesheet == "string")\n
options.stylesheet = [options.stylesheet];\n
\n
var html = ["<!DOCTYPE HTML PUBLIC \\"-//W3C//DTD HTML 4.0 Transitional//EN\\" \\"http://www.w3.org/TR/html4/loose.dtd\\"><html><head>"];\n
// Hack to work around a bunch of IE8-specific problems.\n
html.push("<meta http-equiv=\\"X-UA-Compatible\\" content=\\"IE=EmulateIE7\\"/>");\n
forEach(options.stylesheet, function(file) {\n
html.push("<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"" + file + "\\"/>");\n
});\n
forEach(options.basefiles.concat(options.parserfile), function(file) {\n
if (!/^https?:/.test(file)) file = options.path + file;\n
html.push("<script type=\\"text/javascript\\" src=\\"" + file + "\\"><" + "/script>");\n
});\n
html.push("</head><body style=\\"border-width: 0;\\" class=\\"editbox\\" spellcheck=\\"" +\n
(options.disableSpellcheck ? "false" : "true") + "\\"></body></html>");\n
return html.join("");\n
}\n
\n
var internetExplorer = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent);\n
\n
function CodeMirror(place, options) {\n
// Use passed options, if any, to override defaults.\n
this.options = options = options || {};\n
setDefaults(options, CodeMirrorConfig);\n
\n
// Backward compatibility for deprecated options.\n
if (options.dumbTabs) options.tabMode = "spaces";\n
else if (options.normalTab) options.tabMode = "default";\n
\n
var frame = this.frame = document.createElement("IFRAME");\n
if (options.iframeClass) frame.className = options.iframeClass;\n
frame.frameBorder = 0;\n
frame.style.border = "0";\n
frame.style.width = \'100%\';\n
frame.style.height = \'100%\';\n
// display: block occasionally suppresses some Firefox bugs, so we\n
// always add it, redundant as it sounds.\n
frame.style.display = "block";\n
\n
var div = this.wrapping = document.createElement("DIV");\n
div.style.position = "relative";\n
div.className = "CodeMirror-wrapping";\n
div.style.width = options.width;\n
div.style.height = (options.height == "dynamic") ? options.minHeight + "px" : options.height;\n
// This is used by Editor.reroutePasteEvent\n
var teHack = this.textareaHack = document.createElement("TEXTAREA");\n
div.appendChild(teHack);\n
teHack.style.position = "absolute";\n
teHack.style.left = "-10000px";\n
teHack.style.width = "10px";\n
\n
// Link back to this object, so that the editor can fetch options\n
// and add a reference to itself.\n
frame.CodeMirror = this;\n
if (options.domain && internetExplorer) {\n
this.html = frameHTML(options);\n
frame.src = "javascript:(function(){document.open();" +\n
(options.domain ? "document.domain=\\"" + options.domain + "\\";" : "") +\n
"document.write(window.frameElement.CodeMirror.html);document.close();})()";\n
}\n
else {\n
frame.src = "javascript:;";\n
}\n
\n
if (place.appendChild) place.appendChild(div);\n
else place(div);\n
div.appendChild(frame);\n
if (options.lineNumbers) this.lineNumbers = addLineNumberDiv(div, options.firstLineNumber);\n
\n
this.win = frame.contentWindow;\n
if (!options.domain || !internetExplorer) {\n
this.win.document.open();\n
this.win.document.write(frameHTML(options));\n
this.win.document.close();\n
}\n
}\n
\n
CodeMirror.prototype = {\n
init: function() {\n
if (this.options.initCallback) this.options.initCallback(this);\n
if (this.options.lineNumbers) this.activateLineNumbers();\n
if (this.options.reindentOnLoad) this.reindent();\n
if (this.options.height == "dynamic") this.setDynamicHeight();\n
},\n
\n
getCode: function() {return this.editor.getCode();},\n
setCode: function(code) {this.editor.importCode(code);},\n
selection: function() {this.focusIfIE(); return this.editor.selectedText();},\n
reindent: function() {this.editor.reindent();},\n
reindentSelection: function() {this.focusIfIE(); this.editor.reindentSelection(null);},\n
\n
focusIfIE: function() {\n
// in IE, a lot of selection-related functionality only works when the frame is focused\n
if (this.win.select.ie_selection) this.focus();\n
},\n
focus: function() {\n
this.win.focus();\n
if (this.editor.selectionSnapshot) // IE hack\n
this.win.select.setBookmark(this.win.document.body, this.editor.selectionSnapshot);\n
},\n
replaceSelection: function(text) {\n
this.focus();\n
this.editor.replaceSelection(text);\n
return true;\n
},\n
replaceChars: function(text, start, end) {\n
this.editor.replaceChars(text, start, end);\n
},\n
getSearchCursor: function(string, fromCursor, caseFold) {\n
return this.editor.getSearchCursor(string, fromCursor, caseFold);\n
},\n
\n
undo: function() {this.editor.history.undo();},\n
redo: function() {this.editor.history.redo();},\n
historySize: function() {return this.editor.history.historySize();},\n
clearHistory: function() {this.editor.history.clear();},\n
\n
grabKeys: function(callback, filter) {this.editor.grabKeys(callback, filter);},\n
ungrabKeys: function() {this.editor.ungrabKeys();},\n
\n
setParser: function(name, parserConfig) {this.editor.setParser(name, parserConfig);},\n
setSpellcheck: function(on) {this.win.document.body.spellcheck = on;},\n
setStylesheet: function(names) {\n
if (typeof names === "string") names = [names];\n
var activeStylesheets = {};\n
var matchedNames = {};\n
var links = this.win.document.getElementsByTagName("link");\n
// Create hashes of active stylesheets and matched names.\n
// This is O(n^2) but n is expected to be very small.\n
for (var x = 0, link; link = links[x]; x++) {\n
if (link.rel.indexOf("stylesheet") !== -1) {\n
for (var y = 0; y < names.length; y++) {\n
var name = names[y];\n
if (link.href.substring(link.href.length - name.length) === name) {\n
activeStylesheets[link.href] = true;\n
matchedNames[name] = true;\n
}\n
}\n
}\n
}\n
// Activate the selected stylesheets and disable the rest.\n
for (var x = 0, link; link = links[x]; x++) {\n
if (link.rel.indexOf("stylesheet") !== -1) {\n
link.disabled = !(link.href in activeStylesheets);\n
}\n
}\n
// Create any new stylesheets.\n
for (var y = 0; y < names.length; y++) {\n
var name = names[y];\n
if (!(name in matchedNames)) {\n
var link = this.win.document.createElement("link");\n
link.rel = "stylesheet";\n
link.type = "text/css";\n
link.href = name;\n
this.win.document.getElementsByTagName(\'head\')[0].appendChild(link);\n
}\n
}\n
},\n
setTextWrapping: function(on) {\n
if (on == this.options.textWrapping) return;\n
this.win.document.body.style.whiteSpace = on ? "" : "nowrap";\n
this.options.textWrapping = on;\n
if (this.lineNumbers) {\n
this.setLineNumbers(false);\n
this.setLineNumbers(true);\n
}\n
},\n
setIndentUnit: function(unit) {this.win.indentUnit = unit;},\n
setUndoDepth: function(depth) {this.editor.history.maxDepth = depth;},\n
setTabMode: function(mode) {this.options.tabMode = mode;},\n
setEnterMode: function(mode) {this.options.enterMode = mode;},\n
setLineNumbers: function(on) {\n
if (on && !this.lineNumbers) {\n
this.lineNumbers = addLineNumberDiv(this.wrapping);\n
this.activateLineNumbers();\n
}\n
else if (!on && this.lineNumbers) {\n
this.wrapping.removeChild(this.lineNumbers);\n
this.wrapping.style.marginLeft = "";\n
this.lineNumbers = null;\n
}\n
},\n
\n
cursorPosition: function(start) {this.focusIfIE(); return this.editor.cursorPosition(start);},\n
firstLine: function() {return this.editor.firstLine();},\n
lastLine: function() {return this.editor.lastLine();},\n
nextLine: function(line) {return this.editor.nextLine(line);},\n
prevLine: function(line) {return this.editor.prevLine(line);},\n
lineContent: function(line) {return this.editor.lineContent(line);},\n
setLineContent: function(line, content) {this.editor.setLineContent(line, content);},\n
removeLine: function(line){this.editor.removeLine(line);},\n
insertIntoLine: function(line, position, content) {this.editor.insertIntoLine(line, position, content);},\n
selectLines: function(startLine, startOffset, endLine, endOffset) {\n
this.win.focus();\n
this.editor.selectLines(startLine, startOffset, endLine, endOffset);\n
},\n
nthLine: function(n) {\n
var line = this.firstLine();\n
for (; n > 1 && line !== false; n--)\n
line = this.nextLine(line);\n
return line;\n
},\n
lineNumber: function(line) {\n
var num = 0;\n
while (line !== false) {\n
num++;\n
line = this.prevLine(line);\n
}\n
return num;\n
},\n
jumpToLine: function(line) {\n
if (typeof line == "number") line = this.nthLine(line);\n
this.selectLines(line, 0);\n
this.win.focus();\n
},\n
currentLine: function() { // Deprecated, but still there for backward compatibility\n
return this.lineNumber(this.cursorLine());\n
},\n
cursorLine: function() {\n
return this.cursorPosition().line;\n
},\n
cursorCoords: function(start) {return this.editor.cursorCoords(start);},\n
\n
activateLineNumbers: function() {\n
var frame = this.frame, win = frame.contentWindow, doc = win.document, body = doc.body,\n
nums = this.lineNumbers, scroller = nums.firstChild, self = this;\n
var barWidth = null;\n
\n
function sizeBar() {\n
if (frame.offsetWidth == 0) return;\n
for (var root = frame; root.parentNode; root = root.parentNode){}\n
if (!nums.parentNode || root != document || !win.Editor) {\n
// Clear event handlers (their nodes might already be collected, so try/catch)\n
try{clear();}catch(e){}\n
clearInterval(sizeInterval);\n
return;\n
}\n
\n
if (nums.offsetWidth != barWidth) {\n
barWidth = nums.offsetWidth;\n
frame.parentNode.style.paddingLeft = barWidth + "px";\n
}\n
}\n
function doScroll() {\n
nums.scrollTop = body.scrollTop || doc.documentElement.scrollTop || 0;\n
}\n
// Cleanup function, registered by nonWrapping and wrapping.\n
var clear = function(){};\n
sizeBar();\n
var sizeInterval = setInterval(sizeBar, 500);\n
\n
function ensureEnoughLineNumbers(fill) {\n
var lineHeight = scroller.firstChild.offsetHeight;\n
if (lineHeight == 0) return;\n
var targetHeight = 50 + Math.max(body.offsetHeight, Math.max(frame.offsetHeight, body.scrollHeight || 0)),\n
lastNumber = Math.ceil(targetHeight / lineHeight);\n
for (var i = scroller.childNodes.length; i <= lastNumber; i++) {\n
var div = document.createElement("DIV");\n
div.appendChild(document.createTextNode(fill ? String(i + self.options.firstLineNumber) : "\\u00a0"));\n
scroller.appendChild(div);\n
}\n
}\n
\n
function nonWrapping() {\n
function update() {\n
ensureEnoughLineNumbers(true);\n
doScroll();\n
}\n
self.updateNumbers = update;\n
var onScroll = win.addEventHandler(win, "scroll", doScroll, true),\n
onResize = win.addEventHandler(win, "resize", update, true);\n
clear = function(){\n
onScroll(); onResize();\n
if (self.updateNumbers == update) self.updateNumbers = null;\n
};\n
update();\n
}\n
\n
function wrapping() {\n
var node, lineNum, next, pos, changes = [], styleNums = self.options.styleNumbers;\n
\n
function setNum(n, node) {\n
// Does not typically happen (but can, if you mess with the\n
// document during the numbering)\n
if (!lineNum) lineNum = scroller.appendChild(document.createElement("DIV"));\n
if (styleNums) styleNums(lineNum, node, n);\n
// Changes are accumulated, so that the document layout\n
// doesn\'t have to be recomputed during the pass\n
changes.push(lineNum); changes.push(n);\n
pos = lineNum.offsetHeight + lineNum.offsetTop;\n
lineNum = lineNum.nextSibling;\n
}\n
function commitChanges() {\n
for (var i = 0; i < changes.length; i += 2)\n
changes[i].innerHTML = changes[i + 1];\n
changes = [];\n
}\n
function work() {\n
if (!scroller.parentNode || scroller.parentNode != self.lineNumbers) return;\n
\n
var endTime = new Date().getTime() + self.options.lineNumberTime;\n
while (node) {\n
setNum(next++, node.previousSibling);\n
for (; node && !win.isBR(node); node = node.nextSibling) {\n
var bott = node.offsetTop + node.offsetHeight;\n
while (scroller.offsetHeight && bott - 3 > pos) setNum("&nbsp;");\n
}\n
if (node) node = node.nextSibling;\n
if (new Date().getTime() > endTime) {\n
commitChanges();\n
pending = setTimeout(work, self.options.lineNumberDelay);\n
return;\n
}\n
}\n
while (lineNum) setNum(next++);\n
commitChanges();\n
doScroll();\n
}\n
function start(firstTime) {\n
doScroll();\n
ensureEnoughLineNumbers(firstTime);\n
node = body.firstChild;\n
lineNum = scroller.firstChild;\n
pos = 0;\n
next = self.options.firstLineNumber;\n
work();\n
}\n
\n
start(true);\n
var pending = null;\n
function update() {\n
if (pending) clearTimeout(pending);\n
if (self.editor.allClean()) start();\n
else pending = setTimeout(update, 200);\n
}\n
self.updateNumbers = update;\n
var onScroll = win.addEventHandler(win, "scroll", doScroll, true),\n
onResize = win.addEventHandler(win, "resize", update, true);\n
clear = function(){\n
if (pending) clearTimeout(pending);\n
if (self.updateNumbers == update) self.updateNumbers = null;\n
onScroll();\n
onResize();\n
};\n
}\n
(this.options.textWrapping || this.options.styleNumbers ? wrapping : nonWrapping)();\n
},\n
\n
setDynamicHeight: function() {\n
var self = this, activity = self.options.cursorActivity, win = self.win, body = win.document.body,\n
lineHeight = null, timeout = null, vmargin = 2 * self.frame.offsetTop;\n
body.style.overflowY = "hidden";\n
win.document.documentElement.style.overflowY = "hidden";\n
this.frame.scrolling = "no";\n
\n
function updateHeight() {\n
var trailingLines = 0, node = body.lastChild, computedHeight;\n
while (node && win.isBR(node)) {\n
if (!node.hackBR) trailingLines++;\n
node = node.previousSibling;\n
}\n
if (node) {\n
lineHeight = node.offsetHeight;\n
computedHeight = node.offsetTop + (1 + trailingLines) * lineHeight;\n
}\n
else if (lineHeight) {\n
computedHeight = trailingLines * lineHeight;\n
}\n
if (computedHeight)\n
self.wrapping.style.height = Math.max(vmargin + computedHeight, self.options.minHeight) + "px";\n
}\n
setTimeout(updateHeight, 300);\n
self.options.cursorActivity = function(x) {\n
if (activity) activity(x);\n
clearTimeout(timeout);\n
timeout = setTimeout(updateHeight, 100);\n
};\n
}\n
};\n
\n
CodeMirror.InvalidLineHandle = {toString: function(){return "CodeMirror.InvalidLineHandle";}};\n
\n
CodeMirror.replace = function(element) {\n
if (typeof element == "string")\n
element = document.getElementById(element);\n
return function(newElement) {\n
element.parentNode.replaceChild(newElement, element);\n
};\n
};\n
\n
CodeMirror.fromTextArea = function(area, options) {\n
if (typeof area == "string")\n
area = document.getElementById(area);\n
\n
options = options || {};\n
if (area.style.width && options.width == null)\n
options.width = area.style.width;\n
if (area.style.height && options.height == null)\n
options.height = area.style.height;\n
if (options.content == null) options.content = area.value;\n
\n
if (area.form) {\n
function updateField() {\n
area.value = mirror.getCode();\n
}\n
if (typeof area.form.addEventListener == "function")\n
area.form.addEventListener("submit", updateField, false);\n
else\n
area.form.attachEvent("onsubmit", updateField);\n
var realSubmit = area.form.submit;\n
function wrapSubmit() {\n
updateField();\n
// Can\'t use realSubmit.apply because IE6 is too stupid\n
area.form.submit = realSubmit;\n
area.form.submit();\n
area.form.submit = wrapSubmit;\n
}\n
area.form.submit = wrapSubmit;\n
}\n
\n
function insert(frame) {\n
if (area.nextSibling)\n
area.parentNode.insertBefore(frame, area.nextSibling);\n
else\n
area.parentNode.appendChild(frame);\n
}\n
\n
area.style.display = "none";\n
var mirror = new CodeMirror(insert, options);\n
mirror.toTextArea = function() {\n
area.parentNode.removeChild(mirror.wrapping);\n
area.style.display = "";\n
if (area.form) {\n
area.form.submit = realSubmit;\n
if (typeof area.form.removeEventListener == "function")\n
area.form.removeEventListener("submit", updateField, false);\n
else\n
area.form.detachEvent("onsubmit", updateField);\n
}\n
};\n
\n
return mirror;\n
};\n
\n
CodeMirror.isProbablySupported = function() {\n
// This is rather awful, but can be useful.\n
var match;\n
if (window.opera)\n
return Number(window.opera.version()) >= 9.52;\n
else if (/Apple Computers, Inc/.test(navigator.vendor) && (match = navigator.userAgent.match(/Version\\/(\\d+(?:\\.\\d+)?)\\./)))\n
return Number(match[1]) >= 3;\n
else if (document.selection && window.ActiveXObject && (match = navigator.userAgent.match(/MSIE (\\d+(?:\\.\\d*)?)\\b/)))\n
return Number(match[1]) >= 6;\n
else if (match = navigator.userAgent.match(/gecko\\/(\\d{8})/i))\n
return Number(match[1]) >= 20050901;\n
else if (match = navigator.userAgent.match(/AppleWebKit\\/(\\d+)/))\n
return Number(match[1]) >= 525;\n
else\n
return null;\n
};\n
\n
return CodeMirror;\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>20994</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>editor.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* The Editor object manages the content of the editable frame. It\n
* catches events, colours nodes, and indents lines. This file also\n
* holds some functions for transforming arbitrary DOM structures into\n
* plain sequences of <span> and <br> elements\n
*/\n
\n
var internetExplorer = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent);\n
var webkit = /AppleWebKit/.test(navigator.userAgent);\n
var safari = /Apple Computers, Inc/.test(navigator.vendor);\n
var gecko = /gecko\\/(\\d{8})/i.test(navigator.userAgent);\n
var mac = /Mac/.test(navigator.platform);\n
\n
// TODO this is related to the backspace-at-end-of-line bug. Remove\n
// this if Opera gets their act together, make the version check more\n
// broad if they don\'t.\n
var brokenOpera = window.opera && /Version\\/10.[56]/.test(navigator.userAgent);\n
// TODO remove this once WebKit 533 becomes less common.\n
var slowWebkit = /AppleWebKit\\/533/.test(navigator.userAgent);\n
\n
// Make sure a string does not contain two consecutive \'collapseable\'\n
// whitespace characters.\n
function makeWhiteSpace(n) {\n
var buffer = [], nb = true;\n
for (; n > 0; n--) {\n
buffer.push((nb || n == 1) ? nbsp : " ");\n
nb ^= true;\n
}\n
return buffer.join("");\n
}\n
\n
// Create a set of white-space characters that will not be collapsed\n
// by the browser, but will not break text-wrapping either.\n
function fixSpaces(string) {\n
if (string.charAt(0) == " ") string = nbsp + string.slice(1);\n
return string.replace(/\\t/g, function() {return makeWhiteSpace(indentUnit);})\n
.replace(/[ \\u00a0]{2,}/g, function(s) {return makeWhiteSpace(s.length);});\n
}\n
\n
function cleanText(text) {\n
return text.replace(/\\u00a0/g, " ");\n
}\n
\n
// Create a SPAN node with the expected properties for document part\n
// spans.\n
function makePartSpan(value) {\n
var text = value;\n
if (value.nodeType == 3) text = value.nodeValue;\n
else value = document.createTextNode(text);\n
\n
var span = document.createElement("SPAN");\n
span.isPart = true;\n
span.appendChild(value);\n
span.currentText = text;\n
return span;\n
}\n
\n
// On webkit, when the last BR of the document does not have text\n
// behind it, the cursor can not be put on the line after it. This\n
// makes pressing enter at the end of the document occasionally do\n
// nothing (or at least seem to do nothing). To work around it, this\n
// function makes sure the document ends with a span containing a\n
// zero-width space character. The traverseDOM iterator filters such\n
// character out again, so that the parsers won\'t see them. This\n
// function is called from a few strategic places to make sure the\n
// zwsp is restored after the highlighting process eats it.\n
var webkitLastLineHack = webkit ?\n
function(container) {\n
var last = container.lastChild;\n
if (!last || !last.hackBR) {\n
var br = document.createElement("BR");\n
br.hackBR = true;\n
container.appendChild(br);\n
}\n
} : function() {};\n
\n
var Editor = (function(){\n
// The HTML elements whose content should be suffixed by a newline\n
// when converting them to flat text.\n
var newlineElements = {"P": true, "DIV": true, "LI": true};\n
\n
function asEditorLines(string) {\n
var tab = makeWhiteSpace(indentUnit);\n
return map(string.replace(/\\t/g, tab).replace(/\\u00a0/g, " ").replace(/\\r\\n?/g, "\\n").split("\\n"), fixSpaces);\n
}\n
\n
// Helper function for traverseDOM. Flattens an arbitrary DOM node\n
// into an array of textnodes and <br> tags.\n
function simplifyDOM(root, atEnd) {\n
var result = [];\n
var leaving = true;\n
\n
function simplifyNode(node, top) {\n
if (node.nodeType == 3) {\n
var text = node.nodeValue = fixSpaces(node.nodeValue.replace(/\\r/g, "").replace(/\\n/g, " "));\n
if (text.length) leaving = false;\n
result.push(node);\n
}\n
else if (isBR(node) && node.childNodes.length == 0) {\n
leaving = true;\n
result.push(node);\n
}\n
else {\n
for (var n = node.firstChild; n; n = n.nextSibling) simplifyNode(n);\n
if (!leaving && newlineElements.hasOwnProperty(node.nodeName.toUpperCase())) {\n
leaving = true;\n
if (!atEnd || !top)\n
result.push(document.createElement("BR"));\n
}\n
}\n
}\n
\n
simplifyNode(root, true);\n
return result;\n
}\n
\n
// Creates a MochiKit-style iterator that goes over a series of DOM\n
// nodes. The values it yields are strings, the textual content of\n
// the nodes. It makes sure that all nodes up to and including the\n
// one whose text is being yielded have been \'normalized\' to be just\n
// <span> and <br> elements.\n
function traverseDOM(start){\n
var nodeQueue = [];\n
\n
// Create a function that can be used to insert nodes after the\n
// one given as argument.\n
function pointAt(node){\n
var parent = node.parentNode;\n
var next = node.nextSibling;\n
return function(newnode) {\n
parent.insertBefore(newnode, next);\n
};\n
}\n
var point = null;\n
\n
// This an Opera-specific hack -- always insert an empty span\n
// between two BRs, because Opera\'s cursor code gets terribly\n
// confused when the cursor is between two BRs.\n
var afterBR = true;\n
\n
// Insert a normalized node at the current point. If it is a text\n
// node, wrap it in a <span>, and give that span a currentText\n
// property -- this is used to cache the nodeValue, because\n
// directly accessing nodeValue is horribly slow on some browsers.\n
// The dirty property is used by the highlighter to determine\n
// which parts of the document have to be re-highlighted.\n
function insertPart(part){\n
var text = "\\n";\n
if (part.nodeType == 3) {\n
select.snapshotChanged();\n
part = makePartSpan(part);\n
text = part.currentText;\n
afterBR = false;\n
}\n
else {\n
if (afterBR && window.opera)\n
point(makePartSpan(""));\n
afterBR = true;\n
}\n
part.dirty = true;\n
nodeQueue.push(part);\n
point(part);\n
return text;\n
}\n
\n
// Extract the text and newlines from a DOM node, insert them into\n
// the document, and return the textual content. Used to replace\n
// non-normalized nodes.\n
function writeNode(node, end) {\n
var simplified = simplifyDOM(node, end);\n
for (var i = 0; i < simplified.length; i++)\n
simplified[i] = insertPart(simplified[i]);\n
return simplified.join("");\n
}\n
\n
// Check whether a node is a normalized <span> element.\n
function partNode(node){\n
if (node.isPart && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {\n
node.currentText = node.firstChild.nodeValue;\n
return !/[\\n\\t\\r]/.test(node.currentText);\n
}\n
return false;\n
}\n
\n
// Advance to next node, return string for current node.\n
function next() {\n
if (!start) throw StopIteration;\n
var node = start;\n
start = node.nextSibling;\n
\n
if (partNode(node)){\n
nodeQueue.push(node);\n
afterBR = false;\n
return node.currentText;\n
}\n
else if (isBR(node)) {\n
if (afterBR && window.opera)\n
node.parentNode.insertBefore(makePartSpan(""), node);\n
nodeQueue.push(node);\n
afterBR = true;\n
return "\\n";\n
}\n
else {\n
var end = !node.nextSibling;\n
point = pointAt(node);\n
removeElement(node);\n
return writeNode(node, end);\n
}\n
}\n
\n
// MochiKit iterators are objects with a next function that\n
// returns the next value or throws StopIteration when there are\n
// no more values.\n
return {next: next, nodes: nodeQueue};\n
}\n
\n
// Determine the text size of a processed node.\n
function nodeSize(node) {\n
return isBR(node) ? 1 : node.currentText.length;\n
}\n
\n
// Search backwards through the top-level nodes until the next BR or\n
// the start of the frame.\n
function startOfLine(node) {\n
while (node && !isBR(node)) node = node.previousSibling;\n
return node;\n
}\n
function endOfLine(node, container) {\n
if (!node) node = container.firstChild;\n
else if (isBR(node)) node = node.nextSibling;\n
\n
while (node && !isBR(node)) node = node.nextSibling;\n
return node;\n
}\n
\n
function time() {return new Date().getTime();}\n
\n
// Client interface for searching the content of the editor. Create\n
// these by calling CodeMirror.getSearchCursor. To use, call\n
// findNext on the resulting object -- this returns a boolean\n
// indicating whether anything was found, and can be called again to\n
// skip to the next find. Use the select and replace methods to\n
// actually do something with the found locations.\n
function SearchCursor(editor, string, from, caseFold) {\n
this.editor = editor;\n
this.history = editor.history;\n
this.history.commit();\n
this.valid = !!string;\n
this.atOccurrence = false;\n
if (caseFold == undefined) caseFold = string == string.toLowerCase();\n
\n
function getText(node){\n
var line = cleanText(editor.history.textAfter(node));\n
return (caseFold ? line.toLowerCase() : line);\n
}\n
\n
var topPos = {node: null, offset: 0};\n
if (from && typeof from == "object" && typeof from.character == "number") {\n
editor.checkLine(from.line);\n
var pos = {node: from.line, offset: from.character};\n
this.pos = {from: pos, to: pos};\n
}\n
else if (from) {\n
this.pos = {from: select.cursorPos(editor.container, true) || topPos,\n
to: select.cursorPos(editor.container, false) || topPos};\n
}\n
else {\n
this.pos = {from: topPos, to: topPos};\n
}\n
\n
if (caseFold) string = string.toLowerCase();\n
// Create a matcher function based on the kind of string we have.\n
var target = string.split("\\n");\n
this.matches = (target.length == 1) ?\n
// For one-line strings, searching can be done simply by calling\n
// indexOf or lastIndexOf on the current line.\n
function(reverse, node, offset) {\n
var line = getText(node), len = string.length, match;\n
if (reverse ? (offset >= len && (match = line.lastIndexOf(string, offset - len)) != -1)\n
: (match = line.indexOf(string, offset)) != -1)\n
return {from: {node: node, offset: match},\n
to: {node: node, offset: match + len}};\n
} :\n
// Multi-line strings require internal iteration over lines, and\n
// some clunky checks to make sure the first match ends at the\n
// end of the line and the last match starts at the start.\n
function(reverse, node, offset) {\n
var idx = (reverse ? target.length - 1 : 0), match = target[idx], line = getText(node);\n
var offsetA = (reverse ? line.indexOf(match) + match.length : line.lastIndexOf(match));\n
if (reverse ? offsetA >= offset || offsetA != match.length\n
: offsetA <= offset || offsetA != line.length - match.length)\n
return;\n
\n
var pos = node;\n
while (true) {\n
if (reverse && !pos) return;\n
pos = (reverse ? this.history.nodeBefore(pos) : this.history.nodeAfter(pos) );\n
if (!reverse && !pos) return;\n
\n
line = getText(pos);\n
match = target[reverse ? --idx : ++idx];\n
\n
if (idx > 0 && idx < target.length - 1) {\n
if (line != match) return;\n
else continue;\n
}\n
var offsetB = (reverse ? line.lastIndexOf(match) : line.indexOf(match) + match.length);\n
if (reverse ? offsetB != line.length - match.length : offsetB != match.length)\n
return;\n
return {from: {node: reverse ? pos : node, offset: reverse ? offsetB : offsetA},\n
to: {node: reverse ? node : pos, offset: reverse ? offsetA : offsetB}};\n
}\n
};\n
}\n
\n
SearchCursor.prototype = {\n
findNext: function() {return this.find(false);},\n
findPrevious: function() {return this.find(true);},\n
\n
find: function(reverse) {\n
if (!this.valid) return false;\n
\n
var self = this, pos = reverse ? this.pos.from : this.pos.to,\n
node = pos.node, offset = pos.offset;\n
// Reset the cursor if the current line is no longer in the DOM tree.\n
if (node && !node.parentNode) {\n
node = null; offset = 0;\n
}\n
function savePosAndFail() {\n
var pos = {node: node, offset: offset};\n
self.pos = {from: pos, to: pos};\n
self.atOccurrence = false;\n
return false;\n
}\n
\n
while (true) {\n
if (this.pos = this.matches(reverse, node, offset)) {\n
this.atOccurrence = true;\n
return true;\n
}\n
\n
if (reverse) {\n
if (!node) return savePosAndFail();\n
node = this.history.nodeBefore(node);\n
offset = this.history.textAfter(node).length;\n
}\n
else {\n
var next = this.history.nodeAfter(node);\n
if (!next) {\n
offset = this.history.textAfter(node).length;\n
return savePosAndFail();\n
}\n
node = next;\n
offset = 0;\n
} \n
}\n
},\n
\n
select: function() {\n
if (this.atOccurrence) {\n
select.setCursorPos(this.editor.container, this.pos.from, this.pos.to);\n
select.scrollToCursor(this.editor.container);\n
}\n
},\n
\n
replace: function(string) {\n
if (this.atOccurrence) {\n
var end = this.editor.replaceRange(this.pos.from, this.pos.to, string);\n
this.pos.to = end;\n
this.atOccurrence = false;\n
}\n
},\n
\n
position: function() {\n
if (this.atOccurrence)\n
return {line: this.pos.from.node, character: this.pos.from.offset};\n
}\n
};\n
\n
// The Editor object is the main inside-the-iframe interface.\n
function Editor(options) {\n
this.options = options;\n
window.indentUnit = options.indentUnit;\n
this.parent = parent;\n
var container = this.container = document.body;\n
this.history = new UndoHistory(container, options.undoDepth, options.undoDelay, this);\n
var self = this;\n
\n
if (!Editor.Parser)\n
throw "No parser loaded.";\n
if (options.parserConfig && Editor.Parser.configure)\n
Editor.Parser.configure(options.parserConfig);\n
\n
if (!options.readOnly)\n
select.setCursorPos(container, {node: null, offset: 0});\n
\n
this.dirty = [];\n
this.importCode(options.content || "");\n
this.history.onChange = options.onChange;\n
\n
if (!options.readOnly) {\n
if (options.continuousScanning !== false) {\n
this.scanner = this.documentScanner(options.passTime);\n
this.delayScanning();\n
}\n
\n
function setEditable() {\n
// Use contentEditable instead of designMode on IE, since designMode frames\n
// can not run any scripts. It would be nice if we could use contentEditable\n
// everywhere, but it is significantly flakier than designMode on every\n
// single non-IE browser.\n
if (document.body.contentEditable != undefined && internetExplorer)\n
document.body.contentEditable = "true";\n
else\n
document.designMode = "on";\n
\n
// Work around issue where you have to click on the actual\n
// body of the document to focus it in IE, making focusing\n
// hard when the document is small.\n
if (internetExplorer && options.height != "dynamic")\n
document.body.style.minHeight = (frameElement.clientHeight - 2 * document.body.offsetTop - 5) + "px";\n
\n
document.documentElement.style.borderWidth = "0";\n
if (!options.textWrapping)\n
container.style.whiteSpace = "nowrap";\n
}\n
\n
// If setting the frame editable fails, try again when the user\n
// focus it (happens when the frame is not visible on\n
// initialisation, in Firefox).\n
try {\n
setEditable();\n
}\n
catch(e) {\n
var focusEvent = addEventHandler(document, "focus", function() {\n
focusEvent();\n
setEditable();\n
}, true);\n
}\n
\n
addEventHandler(document, "keydown", method(this, "keyDown"));\n
addEventHandler(document, "keypress", method(this, "keyPress"));\n
addEventHandler(document, "keyup", method(this, "keyUp"));\n
\n
function cursorActivity() {self.cursorActivity(false);}\n
addEventHandler(document.body, "mouseup", cursorActivity);\n
addEventHandler(document.body, "cut", cursorActivity);\n
\n
// workaround for a gecko bug [?] where going forward and then\n
// back again breaks designmode (no more cursor)\n
if (gecko)\n
addEventHandler(window, "pagehide", function(){self.unloaded = true;});\n
\n
addEventHandler(document.body, "paste", function(event) {\n
cursorActivity();\n
var text = null;\n
try {\n
var clipboardData = event.clipboardData || window.clipboardData;\n
if (clipboardData) text = clipboardData.getData(\'Text\');\n
}\n
catch(e) {}\n
if (text !== null) {\n
event.stop();\n
self.replaceSelection(text);\n
select.scrollToCursor(self.container);\n
}\n
});\n
\n
if (this.options.autoMatchParens)\n
addEventHandler(document.body, "click", method(this, "scheduleParenHighlight"));\n
}\n
else if (!options.textWrapping) {\n
container.style.whiteSpace = "nowrap";\n
}\n
}\n
\n
function isSafeKey(code) {\n
return (code >= 16 && code <= 18) || // shift, control, alt\n
(code >= 33 && code <= 40); // arrows, home, end\n
}\n
\n
Editor.prototype = {\n
// Import a piece of code into the editor.\n
importCode: function(code) {\n
this.history.push(null, null, asEditorLines(code));\n
this.history.reset();\n
},\n
\n
// Extract the code from the editor.\n
getCode: function() {\n
if (!this.container.firstChild)\n
return "";\n
\n
var accum = [];\n
select.markSelection();\n
forEach(traverseDOM(this.container.firstChild), method(accum, "push"));\n
webkitLastLineHack(this.container);\n
select.selectMarked();\n
// On webkit, don\'t count last (empty) line if the webkitLastLineHack BR is present\n
if (webkit && this.container.lastChild.hackBR)\n
accum.pop();\n
return cleanText(accum.join(""));\n
},\n
\n
checkLine: function(node) {\n
if (node === false || !(node == null || node.parentNode == this.container))\n
throw parent.CodeMirror.InvalidLineHandle;\n
},\n
\n
cursorPosition: function(start) {\n
if (start == null) start = true;\n
var pos = select.cursorPos(this.container, start);\n
if (pos) return {line: pos.node, character: pos.offset};\n
else return {line: null, character: 0};\n
},\n
\n
firstLine: function() {\n
return null;\n
},\n
\n
lastLine: function() {\n
if (this.container.lastChild) return startOfLine(this.container.lastChild);\n
else return null;\n
},\n
\n
nextLine: function(line) {\n
this.checkLine(line);\n
var end = endOfLine(line, this.container);\n
return end || false;\n
},\n
\n
prevLine: function(line) {\n
this.checkLine(line);\n
if (line == null) return false;\n
return startOfLine(line.previousSibling);\n
},\n
\n
visibleLineCount: function() {\n
var line = this.container.firstChild;\n
while (line && isBR(line)) line = line.nextSibling; // BR heights are unreliable\n
if (!line) return false;\n
var innerHeight = (window.innerHeight\n
|| document.documentElement.clientHeight\n
|| document.body.clientHeight);\n
return Math.floor(innerHeight / line.offsetHeight);\n
},\n
\n
selectLines: function(startLine, startOffset, endLine, endOffset) {\n
this.checkLine(startLine);\n
var start = {node: startLine, offset: startOffset}, end = null;\n
if (endOffset !== undefined) {\n
this.checkLine(endLine);\n
end = {node: endLine, offset: endOffset};\n
}\n
select.setCursorPos(this.container, start, end);\n
select.scrollToCursor(this.container);\n
},\n
\n
lineContent: function(line) {\n
var accum = [];\n
for (line = line ? line.nextSibling : this.container.firstChild;\n
line && !isBR(line); line = line.nextSibling)\n
accum.push(nodeText(line));\n
return cleanText(accum.join(""));\n
},\n
\n
setLineContent: function(line, content) {\n
this.history.commit();\n
this.replaceRange({node: line, offset: 0},\n
{node: line, offset: this.history.textAfter(line).length},\n
content);\n
this.addDirtyNode(line);\n
this.scheduleHighlight();\n
},\n
\n
removeLine: function(line) {\n
var node = line ? line.nextSibling : this.container.firstChild;\n
while (node) {\n
var next = node.nextSibling;\n
removeElement(node);\n
if (isBR(node)) break;\n
node = next;\n
}\n
this.addDirtyNode(line);\n
this.scheduleHighlight();\n
},\n
\n
insertIntoLine: function(line, position, content) {\n
var before = null;\n
if (position == "end") {\n
before = endOfLine(line, this.container);\n
}\n
else {\n
for (var cur = line ? line.nextSibling : this.container.firstChild; cur; cur = cur.nextSibling) {\n
if (position == 0) {\n
before = cur;\n
break;\n
}\n
var text = nodeText(cur);\n
if (text.length > position) {\n
before = cur.nextSibling;\n
content = text.slice(0, position) + content + text.slice(position);\n
removeElement(cur);\n
break;\n
}\n
position -= text.length;\n
}\n
}\n
\n
var lines = asEditorLines(content);\n
for (var i = 0; i < lines.length; i++) {\n
if (i > 0) this.container.insertBefore(document.createElement("BR"), before);\n
this.container.insertBefore(makePartSpan(lines[i]), before);\n
}\n
this.addDirtyNode(line);\n
this.scheduleHighlight();\n
},\n
\n
// Retrieve the selected text.\n
selectedText: function() {\n
var h = this.history;\n
h.commit();\n
\n
var start = select.cursorPos(this.container, true),\n
end = select.cursorPos(this.container, false);\n
if (!start || !end) return "";\n
\n
if (start.node == end.node)\n
return h.textAfter(start.node).slice(start.offset, end.offset);\n
\n
var text = [h.textAfter(start.node).slice(start.offset)];\n
for (var pos = h.nodeAfter(start.node); pos != end.node; pos = h.nodeAfter(pos))\n
text.push(h.textAfter(pos));\n
text.push(h.textAfter(end.node).slice(0, end.offset));\n
return cleanText(text.join("\\n"));\n
},\n
\n
// Replace the selection with another piece of text.\n
replaceSelection: function(text) {\n
this.history.commit();\n
\n
var start = select.cursorPos(this.container, true),\n
end = select.cursorPos(this.container, false);\n
if (!start || !end) return;\n
\n
end = this.replaceRange(start, end, text);\n
select.setCursorPos(this.container, end);\n
webkitLastLineHack(this.container);\n
},\n
\n
cursorCoords: function(start) {\n
var sel = select.cursorPos(this.container, start);\n
if (!sel) return null;\n
var off = sel.offset, node = sel.node, self = this;\n
function measureFromNode(node, xOffset) {\n
var y = -(document.body.scrollTop || document.documentElement.scrollTop || 0),\n
x = -(document.body.scrollLeft || document.documentElement.scrollLeft || 0) + xOffset;\n
forEach([node, window.frameElement], function(n) {\n
while (n) {x += n.offsetLeft; y += n.offsetTop;n = n.offsetParent;}\n
});\n
return {x: x, y: y, yBot: y + node.offsetHeight};\n
}\n
function withTempNode(text, f) {\n
var node = document.createElement("SPAN");\n
node.appendChild(document.createTextNode(text));\n
try {return f(node);}\n
finally {if (node.parentNode) node.parentNode.removeChild(node);}\n
}\n
\n
while (off) {\n
node = node ? node.nextSibling : this.container.firstChild;\n
var txt = nodeText(node);\n
if (off < txt.length)\n
return withTempNode(txt.substr(0, off), function(tmp) {\n
tmp.style.position = "absolute"; tmp.style.visibility = "hidden";\n
tmp.className = node.className;\n
self.container.appendChild(tmp);\n
return measureFromNode(node, tmp.offsetWidth);\n
});\n
off -= txt.length;\n
}\n
if (node && isSpan(node))\n
return measureFromNode(node, node.offsetWidth);\n
else if (node && node.nextSibling && isSpan(node.nextSibling))\n
return measureFromNode(node.nextSibling, 0);\n
else\n
return withTempNode("\\u200b", function(tmp) {\n
if (node) node.parentNode.insertBefore(tmp, node.nextSibling);\n
else self.container.insertBefore(tmp, self.container.firstChild);\n
return measureFromNode(tmp, 0);\n
});\n
},\n
\n
reroutePasteEvent: function() {\n
if (this.capturingPaste || window.opera) return;\n
this.capturingPaste = true;\n
var te = window.frameElement.CodeMirror.textareaHack;\n
parent.focus();\n
te.value = "";\n
te.focus();\n
\n
var self = this;\n
this.parent.setTimeout(function() {\n
self.capturingPaste = false;\n
window.focus();\n
if (self.selectionSnapshot) // IE hack\n
window.select.setBookmark(self.container, self.selectionSnapshot);\n
var text = te.value;\n
if (text) {\n
self.replaceSelection(text);\n
select.scrollToCursor(self.container);\n
}\n
}, 10);\n
},\n
\n
replaceRange: function(from, to, text) {\n
var lines = asEditorLines(text);\n
lines[0] = this.history.textAfter(from.node).slice(0, from.offset) + lines[0];\n
var lastLine = lines[lines.length - 1];\n
lines[lines.length - 1] = lastLine + this.history.textAfter(to.node).slice(to.offset);\n
var end = this.history.nodeAfter(to.node);\n
this.history.push(from.node, end, lines);\n
return {node: this.history.nodeBefore(end),\n
offset: lastLine.length};\n
},\n
\n
getSearchCursor: function(string, fromCursor, caseFold) {\n
return new SearchCursor(this, string, fromCursor, caseFold);\n
},\n
\n
// Re-indent the whole buffer\n
reindent: function() {\n
if (this.container.firstChild)\n
this.indentRegion(null, this.container.lastChild);\n
},\n
\n
reindentSelection: function(direction) {\n
if (!select.somethingSelected()) {\n
this.indentAtCursor(direction);\n
}\n
else {\n
var start = select.selectionTopNode(this.container, true),\n
end = select.selectionTopNode(this.container, false);\n
if (start === false || end === false) return;\n
this.indentRegion(start, end, direction);\n
}\n
},\n
\n
grabKeys: function(eventHandler, filter) {\n
this.frozen = eventHandler;\n
this.keyFilter = filter;\n
},\n
ungrabKeys: function() {\n
this.frozen = "leave";\n
},\n
\n
setParser: function(name, parserConfig) {\n
Editor.Parser = window[name];\n
parserConfig = parserConfig || this.options.parserConfig;\n
if (parserConfig && Editor.Parser.configure)\n
Editor.Parser.configure(parserConfig);\n
\n
if (this.container.firstChild) {\n
forEach(this.container.childNodes, function(n) {\n
if (n.nodeType != 3) n.dirty = true;\n
});\n
this.addDirtyNode(this.firstChild);\n
this.scheduleHighlight();\n
}\n
},\n
\n
// Intercept enter and tab, and assign their new functions.\n
keyDown: function(event) {\n
if (this.frozen == "leave") {this.frozen = null; this.keyFilter = null;}\n
if (this.frozen && (!this.keyFilter || this.keyFilter(event.keyCode, event))) {\n
event.stop();\n
this.frozen(event);\n
return;\n
}\n
\n
var code = event.keyCode;\n
// Don\'t scan when the user is typing.\n
this.delayScanning();\n
// Schedule a paren-highlight event, if configured.\n
if (this.options.autoMatchParens)\n
this.scheduleParenHighlight();\n
\n
// The various checks for !altKey are there because AltGr sets both\n
// ctrlKey and altKey to true, and should not be recognised as\n
// Control.\n
if (code == 13) { // enter\n
if (event.ctrlKey && !event.altKey) {\n
this.reparseBuffer();\n
}\n
else {\n
select.insertNewlineAtCursor();\n
var mode = this.options.enterMode;\n
if (mode != "flat") this.indentAtCursor(mode == "keep" ? "keep" : undefined);\n
select.scrollToCursor(this.container);\n
}\n
event.stop();\n
}\n
else if (code == 9 && this.options.tabMode != "default" && !event.ctrlKey) { // tab\n
this.handleTab(!event.shiftKey);\n
event.stop();\n
}\n
else if (code == 32 && event.shiftKey && this.options.tabMode == "default") { // space\n
this.handleTab(true);\n
event.stop();\n
}\n
else if (code == 36 && !event.shiftKey && !event.ctrlKey) { // home\n
if (this.home()) event.stop();\n
}\n
else if (code == 35 && !event.shiftKey && !event.ctrlKey) { // end\n
if (this.end()) event.stop();\n
}\n
// Only in Firefox is the default behavior for PgUp/PgDn correct.\n
else if (code == 33 && !event.shiftKey && !event.ctrlKey && !gecko) { // PgUp\n
if (this.pageUp()) event.stop();\n
}\n
else if (code == 34 && !event.shiftKey && !event.ctrlKey && !gecko) { // PgDn\n
if (this.pageDown()) event.stop();\n
}\n
else if ((code == 219 || code == 221) && event.ctrlKey && !event.altKey) { // [, ]\n
this.highlightParens(event.shiftKey, true);\n
event.stop();\n
}\n
else if (event.metaKey && !event.shiftKey && (code == 37 || code == 39)) { // Meta-left/right\n
var cursor = select.selectionTopNode(this.container);\n
if (cursor === false || !this.container.firstChild) return;\n
\n
if (code == 37) select.focusAfterNode(startOfLine(cursor), this.container);\n
else {\n
var end = endOfLine(cursor, this.container);\n
select.focusAfterNode(end ? end.previousSibling : this.container.lastChild, this.container);\n
}\n
event.stop();\n
}\n
else if ((event.ctrlKey || event.metaKey) && !event.altKey) {\n
if ((event.shiftKey && code == 90) || code == 89) { // shift-Z, Y\n
select.scrollToNode(this.history.redo());\n
event.stop();\n
}\n
else if (code == 90 || (safari && code == 8)) { // Z, backspace\n
select.scrollToNode(this.history.undo());\n
event.stop();\n
}\n
else if (code == 83 && this.options.saveFunction) { // S\n
this.options.saveFunction();\n
event.stop();\n
}\n
else if (code == 86 && !mac) { // V\n
this.reroutePasteEvent();\n
}\n
}\n
},\n
\n
// Check for characters that should re-indent the current line,\n
// and prevent Opera from handling enter and tab anyway.\n
keyPress: function(event) {\n
var electric = this.options.electricChars && Editor.Parser.electricChars, self = this;\n
// Hack for Opera, and Firefox on OS X, in which stopping a\n
// keydown event does not prevent the associated keypress event\n
// from happening, so we have to cancel enter and tab again\n
// here.\n
if ((this.frozen && (!this.keyFilter || this.keyFilter(event.keyCode || event.code, event))) ||\n
event.code == 13 || (event.code == 9 && this.options.tabMode != "default") ||\n
(event.code == 32 && event.shiftKey && this.options.tabMode == "default"))\n
event.stop();\n
else if (mac && (event.ctrlKey || event.metaKey) && event.character == "v") {\n
this.reroutePasteEvent();\n
}\n
else if (electric && electric.indexOf(event.character) != -1)\n
this.parent.setTimeout(function(){self.indentAtCursor(null);}, 0);\n
// Work around a bug where pressing backspace at the end of a\n
// line, or delete at the start, often causes the cursor to jump\n
// to the start of the line in Opera 10.60.\n
else if (brokenOpera) {\n
if (event.code == 8) { // backspace\n
var sel = select.selectionTopNode(this.container), self = this,\n
next = sel ? sel.nextSibling : this.container.firstChild;\n
if (sel !== false && next && isBR(next))\n
this.parent.setTimeout(function(){\n
if (select.selectionTopNode(self.container) == next)\n
select.focusAfterNode(next.previousSibling, self.container);\n
}, 20);\n
}\n
else if (event.code == 46) { // delete\n
var sel = select.selectionTopNode(this.container), self = this;\n
if (sel && isBR(sel)) {\n
this.parent.setTimeout(function(){\n
if (select.selectionTopNode(self.container) != sel)\n
select.focusAfterNode(sel, self.container);\n
}, 20);\n
}\n
}\n
}\n
// In 533.* WebKit versions, when the document is big, typing\n
// something at the end of a line causes the browser to do some\n
// kind of stupid heavy operation, creating delays of several\n
// seconds before the typed characters appear. This very crude\n
// hack inserts a temporary zero-width space after the cursor to\n
// make it not be at the end of the line.\n
else if (slowWebkit) {\n
var sel = select.selectionTopNode(this.container),\n
next = sel ? sel.nextSibling : this.container.firstChild;\n
// Doesn\'t work on empty lines, for some reason those always\n
// trigger the delay.\n
if (sel && next && isBR(next) && !isBR(sel)) {\n
var cheat = document.createTextNode("\\u200b");\n
this.container.insertBefore(cheat, next);\n
this.parent.setTimeout(function() {\n
if (cheat.nodeValue == "\\u200b") removeElement(cheat);\n
else cheat.nodeValue = cheat.nodeValue.replace("\\u200b", "");\n
}, 20);\n
}\n
}\n
},\n
\n
// Mark the node at the cursor dirty when a non-safe key is\n
// released.\n
keyUp: function(event) {\n
this.cursorActivity(isSafeKey(event.keyCode));\n
},\n
\n
// Indent the line following a given <br>, or null for the first\n
// line. If given a <br> element, this must have been highlighted\n
// so that it has an indentation method. Returns the whitespace\n
// element that has been modified or created (if any).\n
indentLineAfter: function(start, direction) {\n
function whiteSpaceAfter(node) {\n
var ws = node ? node.nextSibling : self.container.firstChild;\n
if (!ws || !hasClass(ws, "whitespace")) return null;\n
return ws;\n
}\n
\n
// whiteSpace is the whitespace span at the start of the line,\n
// or null if there is no such node.\n
var self = this, whiteSpace = whiteSpaceAfter(start);\n
var newIndent = 0, curIndent = whiteSpace ? whiteSpace.currentText.length : 0;\n
\n
if (direction == "keep") {\n
if (start) {\n
var prevWS = whiteSpaceAfter(startOfLine(start.previousSibling))\n
if (prevWS) newIndent = prevWS.currentText.length;\n
}\n
}\n
else {\n
// Sometimes the start of the line can influence the correct\n
// indentation, so we retrieve it.\n
var firstText = whiteSpace ? whiteSpace.nextSibling : (start ? start.nextSibling : this.container.firstChild);\n
var nextChars = (start && firstText && firstText.currentText) ? firstText.currentText : "";\n
\n
// Ask the lexical context for the correct indentation, and\n
// compute how much this differs from the current indentation.\n
if (direction != null && this.options.tabMode == "shift")\n
newIndent = direction ? curIndent + indentUnit : Math.max(0, curIndent - indentUnit)\n
else if (start)\n
newIndent = start.indentation(nextChars, curIndent, direction);\n
else if (Editor.Parser.firstIndentation)\n
newIndent = Editor.Parser.firstIndentation(nextChars, curIndent, direction);\n
}\n
\n
var indentDiff = newIndent - curIndent;\n
\n
// If there is too much, this is just a matter of shrinking a span.\n
if (indentDiff < 0) {\n
if (newIndent == 0) {\n
if (firstText) select.snapshotMove(whiteSpace.firstChild, firstText.firstChild || firstText, 0);\n
removeElement(whiteSpace);\n
whiteSpace = null;\n
}\n
else {\n
select.snapshotMove(whiteSpace.firstChild, whiteSpace.firstChild, indentDiff, true);\n
whiteSpace.currentText = makeWhiteSpace(newIndent);\n
whiteSpace.firstChild.nodeValue = whiteSpace.currentText;\n
}\n
}\n
// Not enough...\n
else if (indentDiff > 0) {\n
// If there is whitespace, we grow it.\n
if (whiteSpace) {\n
whiteSpace.currentText = makeWhiteSpace(newIndent);\n
whiteSpace.firstChild.nodeValue = whiteSpace.currentText;\n
select.snapshotMove(whiteSpace.firstChild, whiteSpace.firstChild, indentDiff, true);\n
}\n
// Otherwise, we have to add a new whitespace node.\n
else {\n
whiteSpace = makePartSpan(makeWhiteSpace(newIndent));\n
whiteSpace.className = "whitespace";\n
if (start) insertAfter(whiteSpace, start);\n
else this.container.insertBefore(whiteSpace, this.container.firstChild);\n
select.snapshotMove(firstText && (firstText.firstChild || firstText),\n
whiteSpace.firstChild, newIndent, false, true);\n
}\n
}\n
// Make sure cursor ends up after the whitespace\n
else if (whiteSpace) {\n
\tselect.snapshotMove(whiteSpace.firstChild, whiteSpace.firstChild, newIndent, false);\n
}\n
if (indentDiff != 0) this.addDirtyNode(start);\n
},\n
\n
// Re-highlight the selected part of the document.\n
highlightAtCursor: function() {\n
var pos = select.selectionTopNode(this.container, true);\n
var to = select.selectionTopNode(this.container, false);\n
if (pos === false || to === false) return false;\n
\n
select.markSelection();\n
if (this.highlight(pos, endOfLine(to, this.container), true, 20) === false)\n
return false;\n
select.selectMarked();\n
return true;\n
},\n
\n
// When tab is pressed with text selected, the whole selection is\n
// re-indented, when nothing is selected, the line with the cursor\n
// is re-indented.\n
handleTab: function(direction) {\n
if (this.options.tabMode == "spaces")\n
select.insertTabAtCursor();\n
else\n
this.reindentSelection(direction);\n
},\n
\n
// Custom home behaviour that doesn\'t land the cursor in front of\n
// leading whitespace unless pressed twice.\n
home: function() {\n
var cur = select.selectionTopNode(this.container, true), start = cur;\n
if (cur === false || !(!cur || cur.isPart || isBR(cur)) || !this.container.firstChild)\n
return false;\n
\n
while (cur && !isBR(cur)) cur = cur.previousSibling;\n
var next = cur ? cur.nextSibling : this.container.firstChild;\n
if (next && next != start && next.isPart && hasClass(next, "whitespace"))\n
select.focusAfterNode(next, this.container);\n
else\n
select.focusAfterNode(cur, this.container);\n
\n
select.scrollToCursor(this.container);\n
return true;\n
},\n
\n
// Some browsers (Opera) don\'t manage to handle the end key\n
// properly in the face of vertical scrolling.\n
end: function() {\n
var cur = select.selectionTopNode(this.container, true);\n
if (cur === false) return false;\n
cur = endOfLine(cur, this.container);\n
if (!cur) return false;\n
select.focusAfterNode(cur.previousSibling, this.container);\n
select.scrollToCursor(this.container);\n
return true;\n
},\n
\n
pageUp: function() {\n
var line = this.cursorPosition().line, scrollAmount = this.visibleLineCount();\n
if (line === false || scrollAmount === false) return false;\n
// Try to keep one line on the screen.\n
scrollAmount -= 2;\n
for (var i = 0; i < scrollAmount; i++) {\n
line = this.prevLine(line);\n
if (line === false) break;\n
}\n
if (i == 0) return false; // Already at first line\n
select.setCursorPos(this.container, {node: line, offset: 0});\n
select.scrollToCursor(this.container);\n
return true;\n
},\n
\n
pageDown: function() {\n
var line = this.cursorPosition().line, scrollAmount = this.visibleLineCount();\n
if (line === false || scrollAmount === false) return false;\n
// Try to move to the last line of the current page.\n
scrollAmount -= 2;\n
for (var i = 0; i < scrollAmount; i++) {\n
var nextLine = this.nextLine(line);\n
if (nextLine === false) break;\n
line = nextLine;\n
}\n
if (i == 0) return false; // Already at last line\n
select.setCursorPos(this.container, {node: line, offset: 0});\n
select.scrollToCursor(this.container);\n
return true;\n
},\n
\n
// Delay (or initiate) the next paren highlight event.\n
scheduleParenHighlight: function() {\n
if (this.parenEvent) this.parent.clearTimeout(this.parenEvent);\n
var self = this;\n
this.parenEvent = this.parent.setTimeout(function(){self.highlightParens();}, 300);\n
},\n
\n
// Take the token before the cursor. If it contains a character in\n
// \'()[]{}\', search for the matching paren/brace/bracket, and\n
// highlight them in green for a moment, or red if no proper match\n
// was found.\n
highlightParens: function(jump, fromKey) {\n
var self = this;\n
// give the relevant nodes a colour.\n
function highlight(node, ok) {\n
if (!node) return;\n
if (self.options.markParen) {\n
self.options.markParen(node, ok);\n
}\n
else {\n
node.style.fontWeight = "bold";\n
node.style.color = ok ? "#8F8" : "#F88";\n
}\n
}\n
function unhighlight(node) {\n
if (!node) return;\n
if (self.options.unmarkParen) {\n
self.options.unmarkParen(node);\n
}\n
else {\n
node.style.fontWeight = "";\n
node.style.color = "";\n
}\n
}\n
if (!fromKey && self.highlighted) {\n
unhighlight(self.highlighted[0]);\n
unhighlight(self.highlighted[1]);\n
}\n
\n
if (!window.parent || !window.select) return;\n
// Clear the event property.\n
if (this.parenEvent) this.parent.clearTimeout(this.parenEvent);\n
this.parenEvent = null;\n
\n
// Extract a \'paren\' from a piece of text.\n
function paren(node) {\n
if (node.currentText) {\n
var match = node.currentText.match(/^[\\s\\u00a0]*([\\(\\)\\[\\]{}])[\\s\\u00a0]*$/);\n
return match && match[1];\n
}\n
}\n
// Determine the direction a paren is facing.\n
function forward(ch) {\n
return /[\\(\\[\\{]/.test(ch);\n
}\n
\n
var ch, cursor = select.selectionTopNode(this.container, true);\n
if (!cursor || !this.highlightAtCursor()) return;\n
cursor = select.selectionTopNode(this.container, true);\n
if (!(cursor && ((ch = paren(cursor)) || (cursor = cursor.nextSibling) && (ch = paren(cursor)))))\n
return;\n
// We only look for tokens with the same className.\n
var className = cursor.className, dir = forward(ch), match = matching[ch];\n
\n
// Since parts of the document might not have been properly\n
// highlighted, and it is hard to know in advance which part we\n
// have to scan, we just try, and when we find dirty nodes we\n
// abort, parse them, and re-try.\n
function tryFindMatch() {\n
var stack = [], ch, ok = true;\n
for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) {\n
if (runner.className == className && isSpan(runner) && (ch = paren(runner))) {\n
if (forward(ch) == dir)\n
stack.push(ch);\n
else if (!stack.length)\n
ok = false;\n
else if (stack.pop() != matching[ch])\n
ok = false;\n
if (!stack.length) break;\n
}\n
else if (runner.dirty || !isSpan(runner) && !isBR(runner)) {\n
return {node: runner, status: "dirty"};\n
}\n
}\n
return {node: runner, status: runner && ok};\n
}\n
\n
while (true) {\n
var found = tryFindMatch();\n
if (found.status == "dirty") {\n
this.highlight(found.node, endOfLine(found.node));\n
// Needed because in some corner cases a highlight does not\n
// reach a node.\n
found.node.dirty = false;\n
continue;\n
}\n
else {\n
highlight(cursor, found.status);\n
highlight(found.node, found.status);\n
if (fromKey)\n
self.parent.setTimeout(function() {unhighlight(cursor); unhighlight(found.node);}, 500);\n
else\n
self.highlighted = [cursor, found.node];\n
if (jump && found.node)\n
select.focusAfterNode(found.node.previousSibling, this.container);\n
break;\n
}\n
}\n
},\n
\n
// Adjust the amount of whitespace at the start of the line that\n
// the cursor is on so that it is indented properly.\n
indentAtCursor: function(direction) {\n
if (!this.container.firstChild) return;\n
// The line has to have up-to-date lexical information, so we\n
// highlight it first.\n
if (!this.highlightAtCursor()) return;\n
var cursor = select.selectionTopNode(this.container, false);\n
// If we couldn\'t determine the place of the cursor,\n
// there\'s nothing to indent.\n
if (cursor === false)\n
return;\n
select.markSelection();\n
this.indentLineAfter(startOfLine(cursor), direction);\n
select.selectMarked();\n
},\n
\n
// Indent all lines whose start falls inside of the current\n
// selection.\n
indentRegion: function(start, end, direction) {\n
var current = (start = startOfLine(start)), before = start && startOfLine(start.previousSibling);\n
if (!isBR(end)) end = endOfLine(end, this.container);\n
this.addDirtyNode(start);\n
\n
do {\n
var next = endOfLine(current, this.container);\n
if (current) this.highlight(before, next, true);\n
this.indentLineAfter(current, direction);\n
before = current;\n
current = next;\n
} while (current != end);\n
select.setCursorPos(this.container, {node: start, offset: 0}, {node: end, offset: 0});\n
},\n
\n
// Find the node that the cursor is in, mark it as dirty, and make\n
// sure a highlight pass is scheduled.\n
cursorActivity: function(safe) {\n
// pagehide event hack above\n
if (this.unloaded) {\n
window.document.designMode = "off";\n
window.document.designMode = "on";\n
this.unloaded = false;\n
}\n
\n
if (internetExplorer) {\n
this.container.createTextRange().execCommand("unlink");\n
this.selectionSnapshot = select.getBookmark(this.container);\n
}\n
\n
var activity = this.options.cursorActivity;\n
if (!safe || activity) {\n
var cursor = select.selectionTopNode(this.container, false);\n
if (cursor === false || !this.container.firstChild) return;\n
cursor = cursor || this.container.firstChild;\n
if (activity) activity(cursor);\n
if (!safe) {\n
this.scheduleHighlight();\n
this.addDirtyNode(cursor);\n
}\n
}\n
},\n
\n
reparseBuffer: function() {\n
forEach(this.container.childNodes, function(node) {node.dirty = true;});\n
if (this.container.firstChild)\n
this.addDirtyNode(this.container.firstChild);\n
},\n
\n
// Add a node to the set of dirty nodes, if it isn\'t already in\n
// there.\n
addDirtyNode: function(node) {\n
node = node || this.container.firstChild;\n
if (!node) return;\n
\n
for (var i = 0; i < this.dirty.length; i++)\n
if (this.dirty[i] == node) return;\n
\n
if (node.nodeType != 3)\n
node.dirty = true;\n
this.dirty.push(node);\n
},\n
\n
allClean: function() {\n
return !this.dirty.length;\n
},\n
\n
// Cause a highlight pass to happen in options.passDelay\n
// milliseconds. Clear the existing timeout, if one exists. This\n
// way, the passes do not happen while the user is typing, and\n
// should as unobtrusive as possible.\n
scheduleHighlight: function() {\n
// Timeouts are routed through the parent window, because on\n
// some browsers designMode windows do not fire timeouts.\n
var self = this;\n
this.parent.clearTimeout(this.highlightTimeout);\n
this.highlightTimeout = this.parent.setTimeout(function(){self.highlightDirty();}, this.options.passDelay);\n
},\n
\n
// Fetch one dirty node, and remove it from the dirty set.\n
getDirtyNode: function() {\n
while (this.dirty.length > 0) {\n
var found = this.dirty.pop();\n
// IE8 sometimes throws an unexplainable \'invalid argument\'\n
// exception for found.parentNode\n
try {\n
// If the node has been coloured in the meantime, or is no\n
// longer in the document, it should not be returned.\n
while (found && found.parentNode != this.container)\n
found = found.parentNode;\n
if (found && (found.dirty || found.nodeType == 3))\n
return found;\n
} catch (e) {}\n
}\n
return null;\n
},\n
\n
// Pick dirty nodes, and highlight them, until options.passTime\n
// milliseconds have gone by. The highlight method will continue\n
// to next lines as long as it finds dirty nodes. It returns\n
// information about the place where it stopped. If there are\n
// dirty nodes left after this function has spent all its lines,\n
// it shedules another highlight to finish the job.\n
highlightDirty: function(force) {\n
// Prevent FF from raising an error when it is firing timeouts\n
// on a page that\'s no longer loaded.\n
if (!window.parent || !window.select) return false;\n
\n
if (!this.options.readOnly) select.markSelection();\n
var start, endTime = force ? null : time() + this.options.passTime;\n
while ((time() < endTime || force) && (start = this.getDirtyNode())) {\n
var result = this.highlight(start, endTime);\n
if (result && result.node && result.dirty)\n
this.addDirtyNode(result.node.nextSibling);\n
}\n
if (!this.options.readOnly) select.selectMarked();\n
if (start) this.scheduleHighlight();\n
return this.dirty.length == 0;\n
},\n
\n
// Creates a function that, when called through a timeout, will\n
// continuously re-parse the document.\n
documentScanner: function(passTime) {\n
var self = this, pos = null;\n
return function() {\n
// FF timeout weirdness workaround.\n
if (!window.parent || !window.select) return;\n
// If the current node is no longer in the document... oh\n
// well, we start over.\n
if (pos && pos.parentNode != self.container)\n
pos = null;\n
select.markSelection();\n
var result = self.highlight(pos, time() + passTime, true);\n
select.selectMarked();\n
var newPos = result ? (result.node && result.node.nextSibling) : null;\n
pos = (pos == newPos) ? null : newPos;\n
self.delayScanning();\n
};\n
},\n
\n
// Starts the continuous scanning process for this document after\n
// a given interval.\n
delayScanning: function() {\n
if (this.scanner) {\n
this.parent.clearTimeout(this.documentScan);\n
this.documentScan = this.parent.setTimeout(this.scanner, this.options.continuousScanning);\n
}\n
},\n
\n
// The function that does the actual highlighting/colouring (with\n
// help from the parser and the DOM normalizer). Its interface is\n
// rather overcomplicated, because it is used in different\n
// situations: ensuring that a certain line is highlighted, or\n
// highlighting up to X milliseconds starting from a certain\n
// point. The \'from\' argument gives the node at which it should\n
// start. If this is null, it will start at the beginning of the\n
// document. When a timestamp is given with the \'target\' argument,\n
// it will stop highlighting at that time. If this argument holds\n
// a DOM node, it will highlight until it reaches that node. If at\n
// any time it comes across two \'clean\' lines (no dirty nodes), it\n
// will stop, except when \'cleanLines\' is true. maxBacktrack is\n
// the maximum number of lines to backtrack to find an existing\n
// parser instance. This is used to give up in situations where a\n
// highlight would take too long and freeze the browser interface.\n
highlight: function(from, target, cleanLines, maxBacktrack){\n
var container = this.container, self = this, active = this.options.activeTokens;\n
var endTime = (typeof target == "number" ? target : null);\n
\n
if (!container.firstChild)\n
return false;\n
// Backtrack to the first node before from that has a partial\n
// parse stored.\n
while (from && (!from.parserFromHere || from.dirty)) {\n
if (maxBacktrack != null && isBR(from) && (--maxBacktrack) < 0)\n
return false;\n
from = from.previousSibling;\n
}\n
// If we are at the end of the document, do nothing.\n
if (from && !from.nextSibling)\n
return false;\n
\n
// Check whether a part (<span> node) and the corresponding token\n
// match.\n
function correctPart(token, part){\n
return !part.reduced && part.currentText == token.value && part.className == token.style;\n
}\n
// Shorten the text associated with a part by chopping off\n
// characters from the front. Note that only the currentText\n
// property gets changed. For efficiency reasons, we leave the\n
// nodeValue alone -- we set the reduced flag to indicate that\n
// this part must be replaced.\n
function shortenPart(part, minus){\n
part.currentText = part.currentText.substring(minus);\n
part.reduced = true;\n
}\n
// Create a part corresponding to a given token.\n
function tokenPart(token){\n
var part = makePartSpan(token.value); \n
part.className = token.style;\n
return part;\n
}\n
\n
function maybeTouch(node) {\n
if (node) {\n
var old = node.oldNextSibling;\n
if (lineDirty || old === undefined || node.nextSibling != old)\n
self.history.touch(node);\n
node.oldNextSibling = node.nextSibling;\n
}\n
else {\n
var old = self.container.oldFirstChild;\n
if (lineDirty || old === undefined || self.container.firstChild != old)\n
self.history.touch(null);\n
self.container.oldFirstChild = self.container.firstChild;\n
}\n
}\n
\n
// Get the token stream. If from is null, we start with a new\n
// parser from the start of the frame, otherwise a partial parse\n
// is resumed.\n
var traversal = traverseDOM(from ? from.nextSibling : container.firstChild),\n
stream = stringStream(traversal),\n
parsed = from ? from.parserFromHere(stream) : Editor.Parser.make(stream);\n
\n
function surroundedByBRs(node) {\n
return (node.previousSibling == null || isBR(node.previousSibling)) &&\n
(node.nextSibling == null || isBR(node.nextSibling));\n
}\n
\n
// parts is an interface to make it possible to \'delay\' fetching\n
// the next DOM node until we are completely done with the one\n
// before it. This is necessary because often the next node is\n
// not yet available when we want to proceed past the current\n
// one.\n
var parts = {\n
current: null,\n
// Fetch current node.\n
get: function(){\n
if (!this.current)\n
this.current = traversal.nodes.shift();\n
return this.current;\n
},\n
// Advance to the next part (do not fetch it yet).\n
next: function(){\n
this.current = null;\n
},\n
// Remove the current part from the DOM tree, and move to the\n
// next.\n
remove: function(){\n
container.removeChild(this.get());\n
this.current = null;\n
},\n
// Advance to the next part that is not empty, discarding empty\n
// parts.\n
getNonEmpty: function(){\n
var part = this.get();\n
// Allow empty nodes when they are alone on a line, needed\n
// for the FF cursor bug workaround (see select.js,\n
// insertNewlineAtCursor).\n
while (part && isSpan(part) && part.currentText == "") {\n
// Leave empty nodes that are alone on a line alone in\n
// Opera, since that browsers doesn\'t deal well with\n
// having 2 BRs in a row.\n
if (window.opera && surroundedByBRs(part)) {\n
this.next();\n
part = this.get();\n
}\n
else {\n
var old = part;\n
this.remove();\n
part = this.get();\n
// Adjust selection information, if any. See select.js for details.\n
select.snapshotMove(old.firstChild, part && (part.firstChild || part), 0);\n
}\n
}\n
\n
return part;\n
}\n
};\n
\n
var lineDirty = false, prevLineDirty = true, lineNodes = 0;\n
\n
// This forEach loops over the tokens from the parsed stream, and\n
// at the same time uses the parts object to proceed through the\n
// corresponding DOM nodes.\n
forEach(parsed, function(token){\n
var part = parts.getNonEmpty();\n
\n
if (token.value == "\\n"){\n
// The idea of the two streams actually staying synchronized\n
// is such a long shot that we explicitly check.\n
if (!isBR(part))\n
throw "Parser out of sync. Expected BR.";\n
\n
if (part.dirty || !part.indentation) lineDirty = true;\n
maybeTouch(from);\n
from = part;\n
\n
// Every <br> gets a copy of the parser state and a lexical\n
// context assigned to it. The first is used to be able to\n
// later resume parsing from this point, the second is used\n
// for indentation.\n
part.parserFromHere = parsed.copy();\n
part.indentation = token.indentation;\n
part.dirty = false;\n
\n
// If the target argument wasn\'t an integer, go at least\n
// until that node.\n
if (endTime == null && part == target) throw StopIteration;\n
\n
// A clean line with more than one node means we are done.\n
// Throwing a StopIteration is the way to break out of a\n
// MochiKit forEach loop.\n
if ((endTime != null && time() >= endTime) || (!lineDirty && !prevLineDirty && lineNodes > 1 && !cleanLines))\n
throw StopIteration;\n
prevLineDirty = lineDirty; lineDirty = false; lineNodes = 0;\n
parts.next();\n
}\n
else {\n
if (!isSpan(part))\n
throw "Parser out of sync. Expected SPAN.";\n
if (part.dirty)\n
lineDirty = true;\n
lineNodes++;\n
\n
// If the part matches the token, we can leave it alone.\n
if (correctPart(token, part)){\n
part.dirty = false;\n
parts.next();\n
}\n
// Otherwise, we have to fix it.\n
else {\n
lineDirty = true;\n
// Insert the correct part.\n
var newPart = tokenPart(token);\n
container.insertBefore(newPart, part);\n
if (active) active(newPart, token, self);\n
var tokensize = token.value.length;\n
var offset = 0;\n
// Eat up parts until the text for this token has been\n
// removed, adjusting the stored selection info (see\n
// select.js) in the process.\n
while (tokensize > 0) {\n
part = parts.get();\n
var partsize = part.currentText.length;\n
select.snapshotReplaceNode(part.firstChild, newPart.firstChild, tokensize, offset);\n
if (partsize > tokensize){\n
shortenPart(part, tokensize);\n
tokensize = 0;\n
}\n
else {\n
tokensize -= partsize;\n
offset += partsize;\n
parts.remove();\n
}\n
}\n
}\n
}\n
});\n
maybeTouch(from);\n
webkitLastLineHack(this.container);\n
\n
// The function returns some status information that is used by\n
// hightlightDirty to determine whether and where it has to\n
// continue.\n
return {node: parts.getNonEmpty(),\n
dirty: lineDirty};\n
}\n
};\n
\n
return Editor;\n
})();\n
\n
addEventHandler(window, "load", function() {\n
var CodeMirror = window.frameElement.CodeMirror;\n
var e = CodeMirror.editor = new Editor(CodeMirror.options);\n
this.parent.setTimeout(method(CodeMirror, "init"), 0);\n
});\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>60366</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>highlight.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
// Minimal framing needed to use CodeMirror-style parsers to highlight\n
// code. Load this along with tokenize.js, stringstream.js, and your\n
// parser. Then call highlightText, passing a string as the first\n
// argument, and as the second argument either a callback function\n
// that will be called with an array of SPAN nodes for every line in\n
// the code, or a DOM node to which to append these spans, and\n
// optionally (not needed if you only loaded one parser) a parser\n
// object.\n
\n
// Stuff from util.js that the parsers are using.\n
var StopIteration = {toString: function() {return "StopIteration"}};\n
\n
var Editor = {};\n
var indentUnit = 2;\n
\n
(function(){\n
function normaliseString(string) {\n
var tab = "";\n
for (var i = 0; i < indentUnit; i++) tab += " ";\n
\n
string = string.replace(/\\t/g, tab).replace(/\\u00a0/g, " ").replace(/\\r\\n?/g, "\\n");\n
var pos = 0, parts = [], lines = string.split("\\n");\n
for (var line = 0; line < lines.length; line++) {\n
if (line != 0) parts.push("\\n");\n
parts.push(lines[line]);\n
}\n
\n
return {\n
next: function() {\n
if (pos < parts.length) return parts[pos++];\n
else throw StopIteration;\n
}\n
};\n
}\n
\n
window.highlightText = function(string, callback, parser) {\n
parser = (parser || Editor.Parser).make(stringStream(normaliseString(string)));\n
var line = [];\n
if (callback.nodeType == 1) {\n
var node = callback;\n
callback = function(line) {\n
for (var i = 0; i < line.length; i++)\n
node.appendChild(line[i]);\n
node.appendChild(document.createElement("BR"));\n
};\n
}\n
\n
try {\n
while (true) {\n
var token = parser.next();\n
if (token.value == "\\n") {\n
callback(line);\n
line = [];\n
}\n
else {\n
var span = document.createElement("SPAN");\n
span.className = token.style;\n
span.appendChild(document.createTextNode(token.value));\n
line.push(span);\n
}\n
}\n
}\n
catch (e) {\n
if (e != StopIteration) throw e;\n
}\n
if (line.length) callback(line);\n
}\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2091</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>mirrorframe.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Demonstration of embedding CodeMirror in a bigger application. The\n
* interface defined here is a mess of prompts and confirms, and\n
* should probably not be used in a real project.\n
*/\n
\n
function MirrorFrame(place, options) {\n
this.home = document.createElement("DIV");\n
if (place.appendChild)\n
place.appendChild(this.home);\n
else\n
place(this.home);\n
\n
var self = this;\n
function makeButton(name, action) {\n
var button = document.createElement("INPUT");\n
button.type = "button";\n
button.value = name;\n
self.home.appendChild(button);\n
button.onclick = function(){self[action].call(self);};\n
}\n
\n
makeButton("Search", "search");\n
makeButton("Replace", "replace");\n
makeButton("Current line", "line");\n
makeButton("Jump to line", "jump");\n
makeButton("Insert constructor", "macro");\n
makeButton("Indent all", "reindent");\n
\n
this.mirror = new CodeMirror(this.home, options);\n
}\n
\n
MirrorFrame.prototype = {\n
search: function() {\n
var text = prompt("Enter search term:", "");\n
if (!text) return;\n
\n
var first = true;\n
do {\n
var cursor = this.mirror.getSearchCursor(text, first);\n
first = false;\n
while (cursor.findNext()) {\n
cursor.select();\n
if (!confirm("Search again?"))\n
return;\n
}\n
} while (confirm("End of document reached. Start over?"));\n
},\n
\n
replace: function() {\n
// This is a replace-all, but it is possible to implement a\n
// prompting replace.\n
var from = prompt("Enter search string:", ""), to;\n
if (from) to = prompt("What should it be replaced with?", "");\n
if (to == null) return;\n
\n
var cursor = this.mirror.getSearchCursor(from, false);\n
while (cursor.findNext())\n
cursor.replace(to);\n
},\n
\n
jump: function() {\n
var line = prompt("Jump to line:", "");\n
if (line && !isNaN(Number(line)))\n
this.mirror.jumpToLine(Number(line));\n
},\n
\n
line: function() {\n
alert("The cursor is currently at line " + this.mirror.currentLine());\n
this.mirror.focus();\n
},\n
\n
macro: function() {\n
var name = prompt("Name your constructor:", "");\n
if (name)\n
this.mirror.replaceSelection("function " + name + "() {\\n \\n}\\n\\n" + name + ".prototype = {\\n \\n};\\n");\n
},\n
\n
reindent: function() {\n
this.mirror.reindent();\n
}\n
};\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2270</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsecss.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Simple parser for CSS */\n
\n
var CSSParser = Editor.Parser = (function() {\n
var tokenizeCSS = (function() {\n
function normal(source, setState) {\n
var ch = source.next();\n
if (ch == "@") {\n
source.nextWhileMatches(/\\w/);\n
return "css-at";\n
}\n
else if (ch == "/" && source.equals("*")) {\n
setState(inCComment);\n
return null;\n
}\n
else if (ch == "<" && source.equals("!")) {\n
setState(inSGMLComment);\n
return null;\n
}\n
else if (ch == "=") {\n
return "css-compare";\n
}\n
else if (source.equals("=") && (ch == "~" || ch == "|")) {\n
source.next();\n
return "css-compare";\n
}\n
else if (ch == "\\"" || ch == "\'") {\n
setState(inString(ch));\n
return null;\n
}\n
else if (ch == "#") {\n
source.nextWhileMatches(/\\w/);\n
return "css-hash";\n
}\n
else if (ch == "!") {\n
source.nextWhileMatches(/[ \\t]/);\n
source.nextWhileMatches(/\\w/);\n
return "css-important";\n
}\n
else if (/\\d/.test(ch)) {\n
source.nextWhileMatches(/[\\w.%]/);\n
return "css-unit";\n
}\n
else if (/[,.+>*\\/]/.test(ch)) {\n
return "css-select-op";\n
}\n
else if (/[;{}:\\[\\]]/.test(ch)) {\n
return "css-punctuation";\n
}\n
else {\n
source.nextWhileMatches(/[\\w\\\\\\-_]/);\n
return "css-identifier";\n
}\n
}\n
\n
function inCComment(source, setState) {\n
var maybeEnd = false;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (maybeEnd && ch == "/") {\n
setState(normal);\n
break;\n
}\n
maybeEnd = (ch == "*");\n
}\n
return "css-comment";\n
}\n
\n
function inSGMLComment(source, setState) {\n
var dashes = 0;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (dashes >= 2 && ch == ">") {\n
setState(normal);\n
break;\n
}\n
dashes = (ch == "-") ? dashes + 1 : 0;\n
}\n
return "css-comment";\n
}\n
\n
function inString(quote) {\n
return function(source, setState) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (ch == quote && !escaped)\n
break;\n
escaped = !escaped && ch == "\\\\";\n
}\n
if (!escaped)\n
setState(normal);\n
return "css-string";\n
};\n
}\n
\n
return function(source, startState) {\n
return tokenizer(source, startState || normal);\n
};\n
})();\n
\n
function indentCSS(inBraces, inRule, base) {\n
return function(nextChars) {\n
if (!inBraces || /^\\}/.test(nextChars)) return base;\n
else if (inRule) return base + indentUnit * 2;\n
else return base + indentUnit;\n
};\n
}\n
\n
// This is a very simplistic parser -- since CSS does not really\n
// nest, it works acceptably well, but some nicer colouroing could\n
// be provided with a more complicated parser.\n
function parseCSS(source, basecolumn) {\n
basecolumn = basecolumn || 0;\n
var tokens = tokenizeCSS(source);\n
var inBraces = false, inRule = false, inDecl = false;;\n
\n
var iter = {\n
next: function() {\n
var token = tokens.next(), style = token.style, content = token.content;\n
\n
if (style == "css-hash")\n
style = token.style = inRule ? "css-colorcode" : "css-identifier";\n
if (style == "css-identifier") {\n
if (inRule) token.style = "css-value";\n
else if (!inBraces && !inDecl) token.style = "css-selector";\n
}\n
\n
if (content == "\\n")\n
token.indentation = indentCSS(inBraces, inRule, basecolumn);\n
\n
if (content == "{")\n
inBraces = true;\n
else if (content == "}")\n
inBraces = inRule = inDecl = false;\n
else if (content == ";")\n
inRule = inDecl = false;\n
else if (inBraces && style != "css-comment" && style != "whitespace")\n
inRule = true;\n
else if (!inBraces && style == "css-at" && content != "@media")\n
inDecl = true;\n
\n
return token;\n
},\n
\n
copy: function() {\n
var _inBraces = inBraces, _inRule = inRule, _tokenState = tokens.state;\n
return function(source) {\n
tokens = tokenizeCSS(source, _tokenState);\n
inBraces = _inBraces;\n
inRule = _inRule;\n
return iter;\n
};\n
}\n
};\n
return iter;\n
}\n
\n
return {make: parseCSS, electricChars: "}"};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>4460</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsedummy.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>var DummyParser = Editor.Parser = (function() {\n
function tokenizeDummy(source) {\n
while (!source.endOfLine()) source.next();\n
return "text";\n
}\n
function parseDummy(source) {\n
function indentTo(n) {return function() {return n;}}\n
source = tokenizer(source, tokenizeDummy);\n
var space = 0;\n
\n
var iter = {\n
next: function() {\n
var tok = source.next();\n
if (tok.type == "whitespace") {\n
if (tok.value == "\\n") tok.indentation = indentTo(space);\n
else space = tok.value.length;\n
}\n
return tok;\n
},\n
copy: function() {\n
var _space = space;\n
return function(_source) {\n
space = _space;\n
source = tokenizer(_source, tokenizeDummy);\n
return iter;\n
};\n
}\n
};\n
return iter;\n
}\n
return {make: parseDummy};\n
})();\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>845</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsehtmlmixed.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
var HTMLMixedParser = Editor.Parser = (function() {\n
if (!(CSSParser && JSParser && XMLParser))\n
throw new Error("CSS, JS, and XML parsers must be loaded for HTML mixed mode to work.");\n
XMLParser.configure({useHTMLKludges: true});\n
\n
function parseMixed(stream) {\n
var htmlParser = XMLParser.make(stream), localParser = null, inTag = false;\n
var iter = {next: top, copy: copy};\n
\n
function top() {\n
var token = htmlParser.next();\n
if (token.content == "<")\n
inTag = true;\n
else if (token.style == "xml-tagname" && inTag === true)\n
inTag = token.content.toLowerCase();\n
else if (token.content == ">") {\n
if (inTag == "script")\n
iter.next = local(JSParser, "</script");\n
else if (inTag == "style")\n
iter.next = local(CSSParser, "</style");\n
inTag = false;\n
}\n
return token;\n
}\n
function local(parser, tag) {\n
var baseIndent = htmlParser.indentation();\n
localParser = parser.make(stream, baseIndent + indentUnit);\n
return function() {\n
if (stream.lookAhead(tag, false, false, true)) {\n
localParser = null;\n
iter.next = top;\n
return top();\n
}\n
\n
var token = localParser.next();\n
var lt = token.value.lastIndexOf("<"), sz = Math.min(token.value.length - lt, tag.length);\n
if (lt != -1 && token.value.slice(lt, lt + sz).toLowerCase() == tag.slice(0, sz) &&\n
stream.lookAhead(tag.slice(sz), false, false, true)) {\n
stream.push(token.value.slice(lt));\n
token.value = token.value.slice(0, lt);\n
}\n
\n
if (token.indentation) {\n
var oldIndent = token.indentation;\n
token.indentation = function(chars) {\n
if (chars == "</")\n
return baseIndent;\n
else\n
return oldIndent(chars);\n
}\n
}\n
\n
return token;\n
};\n
}\n
\n
function copy() {\n
var _html = htmlParser.copy(), _local = localParser && localParser.copy(),\n
_next = iter.next, _inTag = inTag;\n
return function(_stream) {\n
stream = _stream;\n
htmlParser = _html(_stream);\n
localParser = _local && _local(_stream);\n
iter.next = _next;\n
inTag = _inTag;\n
return iter;\n
};\n
}\n
return iter;\n
}\n
\n
return {make: parseMixed, electricChars: "{}/:"};\n
\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2372</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsejavascript.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Parse function for JavaScript. Makes use of the tokenizer from\n
* tokenizejavascript.js. Note that your parsers do not have to be\n
* this complicated -- if you don\'t want to recognize local variables,\n
* in many languages it is enough to just look for braces, semicolons,\n
* parentheses, etc, and know when you are inside a string or comment.\n
*\n
* See manual.html for more info about the parser interface.\n
*/\n
\n
var JSParser = Editor.Parser = (function() {\n
// Token types that can be considered to be atoms.\n
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};\n
// Setting that can be used to have JSON data indent properly.\n
var json = false;\n
// Constructor for the lexical context objects.\n
function JSLexical(indented, column, type, align, prev, info) {\n
// indentation at start of this line\n
this.indented = indented;\n
// column at which this scope was opened\n
this.column = column;\n
// type of scope (\'vardef\', \'stat\' (statement), \'form\' (special form), \'[\', \'{\', or \'(\')\n
this.type = type;\n
// \'[\', \'{\', or \'(\' blocks that have any text after their opening\n
// character are said to be \'aligned\' -- any lines below are\n
// indented all the way to the opening character.\n
if (align != null)\n
this.align = align;\n
// Parent scope, if any.\n
this.prev = prev;\n
this.info = info;\n
}\n
\n
// My favourite JavaScript indentation rules.\n
function indentJS(lexical) {\n
return function(firstChars) {\n
var firstChar = firstChars && firstChars.charAt(0), type = lexical.type;\n
var closing = firstChar == type;\n
if (type == "vardef")\n
return lexical.indented + 4;\n
else if (type == "form" && firstChar == "{")\n
return lexical.indented;\n
else if (type == "stat" || type == "form")\n
return lexical.indented + indentUnit;\n
else if (lexical.info == "switch" && !closing)\n
return lexical.indented + (/^(?:case|default)\\b/.test(firstChars) ? indentUnit : 2 * indentUnit);\n
else if (lexical.align)\n
return lexical.column - (closing ? 1 : 0);\n
else\n
return lexical.indented + (closing ? 0 : indentUnit);\n
};\n
}\n
\n
// The parser-iterator-producing function itself.\n
function parseJS(input, basecolumn) {\n
// Wrap the input in a token stream\n
var tokens = tokenizeJavaScript(input);\n
// The parser state. cc is a stack of actions that have to be\n
// performed to finish the current statement. For example we might\n
// know that we still need to find a closing parenthesis and a\n
// semicolon. Actions at the end of the stack go first. It is\n
// initialized with an infinitely looping action that consumes\n
// whole statements.\n
var cc = [json ? expressions : statements];\n
// Context contains information about the current local scope, the\n
// variables defined in that, and the scopes above it.\n
var context = null;\n
// The lexical scope, used mostly for indentation.\n
var lexical = new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false);\n
// Current column, and the indentation at the start of the current\n
// line. Used to create lexical scope objects.\n
var column = 0;\n
var indented = 0;\n
// Variables which are used by the mark, cont, and pass functions\n
// below to communicate with the driver loop in the \'next\'\n
// function.\n
var consume, marked;\n
\n
// The iterator object.\n
var parser = {next: next, copy: copy};\n
\n
function next(){\n
// Start by performing any \'lexical\' actions (adjusting the\n
// lexical variable), or the operations below will be working\n
// with the wrong lexical state.\n
while(cc[cc.length - 1].lex)\n
cc.pop()();\n
\n
// Fetch a token.\n
var token = tokens.next();\n
\n
// Adjust column and indented.\n
if (token.type == "whitespace" && column == 0)\n
indented = token.value.length;\n
column += token.value.length;\n
if (token.content == "\\n"){\n
indented = column = 0;\n
// If the lexical scope\'s align property is still undefined at\n
// the end of the line, it is an un-aligned scope.\n
if (!("align" in lexical))\n
lexical.align = false;\n
// Newline tokens get an indentation function associated with\n
// them.\n
token.indentation = indentJS(lexical);\n
}\n
// No more processing for meaningless tokens.\n
if (token.type == "whitespace" || token.type == "comment")\n
return token;\n
// When a meaningful token is found and the lexical scope\'s\n
// align is undefined, it is an aligned scope.\n
if (!("align" in lexical))\n
lexical.align = true;\n
\n
// Execute actions until one \'consumes\' the token and we can\n
// return it.\n
while(true) {\n
consume = marked = false;\n
// Take and execute the topmost action.\n
cc.pop()(token.type, token.content);\n
if (consume){\n
// Marked is used to change the style of the current token.\n
if (marked)\n
token.style = marked;\n
// Here we differentiate between local and global variables.\n
else if (token.type == "variable" && inScope(token.content))\n
token.style = "js-localvariable";\n
return token;\n
}\n
}\n
}\n
\n
// This makes a copy of the parser state. It stores all the\n
// stateful variables in a closure, and returns a function that\n
// will restore them when called with a new input stream. Note\n
// that the cc array has to be copied, because it is contantly\n
// being modified. Lexical objects are not mutated, and context\n
// objects are not mutated in a harmful way, so they can be shared\n
// between runs of the parser.\n
function copy(){\n
var _context = context, _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state;\n
\n
return function copyParser(input){\n
context = _context;\n
lexical = _lexical;\n
cc = _cc.concat([]); // copies the array\n
column = indented = 0;\n
tokens = tokenizeJavaScript(input, _tokenState);\n
return parser;\n
};\n
}\n
\n
// Helper function for pushing a number of actions onto the cc\n
// stack in reverse order.\n
function push(fs){\n
for (var i = fs.length - 1; i >= 0; i--)\n
cc.push(fs[i]);\n
}\n
// cont and pass are used by the action functions to add other\n
// actions to the stack. cont will cause the current token to be\n
// consumed, pass will leave it for the next action.\n
function cont(){\n
push(arguments);\n
consume = true;\n
}\n
function pass(){\n
push(arguments);\n
consume = false;\n
}\n
// Used to change the style of the current token.\n
function mark(style){\n
marked = style;\n
}\n
\n
// Push a new scope. Will automatically link the current scope.\n
function pushcontext(){\n
context = {prev: context, vars: {"this": true, "arguments": true}};\n
}\n
// Pop off the current scope.\n
function popcontext(){\n
context = context.prev;\n
}\n
// Register a variable in the current scope.\n
function register(varname){\n
if (context){\n
mark("js-variabledef");\n
context.vars[varname] = true;\n
}\n
}\n
// Check whether a variable is defined in the current scope.\n
function inScope(varname){\n
var cursor = context;\n
while (cursor) {\n
if (cursor.vars[varname])\n
return true;\n
cursor = cursor.prev;\n
}\n
return false;\n
}\n
\n
// Push a new lexical context of the given type.\n
function pushlex(type, info) {\n
var result = function(){\n
lexical = new JSLexical(indented, column, type, null, lexical, info)\n
};\n
result.lex = true;\n
return result;\n
}\n
// Pop off the current lexical context.\n
function poplex(){\n
if (lexical.type == ")")\n
indented = lexical.indented;\n
lexical = lexical.prev;\n
}\n
poplex.lex = true;\n
// The \'lex\' flag on these actions is used by the \'next\' function\n
// to know they can (and have to) be ran before moving on to the\n
// next token.\n
\n
// Creates an action that discards tokens until it finds one of\n
// the given type.\n
function expect(wanted){\n
return function expecting(type){\n
if (type == wanted) cont();\n
else if (wanted == ";") pass();\n
else cont(arguments.callee);\n
};\n
}\n
\n
// Looks for a statement, and then calls itself.\n
function statements(type){\n
return pass(statement, statements);\n
}\n
function expressions(type){\n
return pass(expression, expressions);\n
}\n
// Dispatches various types of statements based on the type of the\n
// current token.\n
function statement(type){\n
if (type == "var") cont(pushlex("vardef"), vardef1, expect(";"), poplex);\n
else if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex);\n
else if (type == "keyword b") cont(pushlex("form"), statement, poplex);\n
else if (type == "{") cont(pushlex("}"), block, poplex);\n
else if (type == ";") cont();\n
else if (type == "function") cont(functiondef);\n
else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex);\n
else if (type == "variable") cont(pushlex("stat"), maybelabel);\n
else if (type == "switch") cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), block, poplex, poplex);\n
else if (type == "case") cont(expression, expect(":"));\n
else if (type == "default") cont(expect(":"));\n
else if (type == "catch") cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), statement, poplex, popcontext);\n
else pass(pushlex("stat"), expression, expect(";"), poplex);\n
}\n
// Dispatch expression types.\n
function expression(type){\n
if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator);\n
else if (type == "function") cont(functiondef);\n
else if (type == "keyword c") cont(expression);\n
else if (type == "(") cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator);\n
else if (type == "operator") cont(expression);\n
else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);\n
else if (type == "{") cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);\n
else cont();\n
}\n
// Called for places where operators, function calls, or\n
// subscripts are valid. Will skip on to the next action if none\n
// is found.\n
function maybeoperator(type, value){\n
if (type == "operator" && /\\+\\+|--/.test(value)) cont(maybeoperator);\n
else if (type == "operator") cont(expression);\n
else if (type == ";") pass();\n
else if (type == "(") cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);\n
else if (type == ".") cont(property, maybeoperator);\n
else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);\n
}\n
// When a statement starts with a variable name, it might be a\n
// label. If no colon follows, it\'s a regular statement.\n
function maybelabel(type){\n
if (type == ":") cont(poplex, statement);\n
else pass(maybeoperator, expect(";"), poplex);\n
}\n
// Property names need to have their style adjusted -- the\n
// tokenizer thinks they are variables.\n
function property(type){\n
if (type == "variable") {mark("js-property"); cont();}\n
}\n
// This parses a property and its value in an object literal.\n
function objprop(type){\n
if (type == "variable") mark("js-property");\n
if (atomicTypes.hasOwnProperty(type)) cont(expect(":"), expression);\n
}\n
// Parses a comma-separated list of the things that are recognized\n
// by the \'what\' argument.\n
function commasep(what, end){\n
function proceed(type) {\n
if (type == ",") cont(what, proceed);\n
else if (type == end) cont();\n
else cont(expect(end));\n
}\n
return function commaSeparated(type) {\n
if (type == end) cont();\n
else pass(what, proceed);\n
};\n
}\n
// Look for statements until a closing brace is found.\n
function block(type){\n
if (type == "}") cont();\n
else pass(statement, block);\n
}\n
// Variable definitions are split into two actions -- 1 looks for\n
// a name or the end of the definition, 2 looks for an \'=\' sign or\n
// a comma.\n
function vardef1(type, value){\n
if (type == "variable"){register(value); cont(vardef2);}\n
else cont();\n
}\n
function vardef2(type, value){\n
if (value == "=") cont(expression, vardef2);\n
else if (type == ",") cont(vardef1);\n
}\n
// For loops.\n
function forspec1(type){\n
if (type == "var") cont(vardef1, forspec2);\n
else if (type == ";") pass(forspec2);\n
else if (type == "variable") cont(formaybein);\n
else pass(forspec2);\n
}\n
function formaybein(type, value){\n
if (value == "in") cont(expression);\n
else cont(maybeoperator, forspec2);\n
}\n
function forspec2(type, value){\n
if (type == ";") cont(forspec3);\n
else if (value == "in") cont(expression);\n
else cont(expression, expect(";"), forspec3);\n
}\n
function forspec3(type) {\n
if (type == ")") pass();\n
else cont(expression);\n
}\n
// A function definition creates a new context, and the variables\n
// in its argument list have to be added to this context.\n
function functiondef(type, value){\n
if (type == "variable"){register(value); cont(functiondef);}\n
else if (type == "(") cont(pushcontext, commasep(funarg, ")"), statement, popcontext);\n
}\n
function funarg(type, value){\n
if (type == "variable"){register(value); cont();}\n
}\n
\n
return parser;\n
}\n
\n
return {\n
make: parseJS,\n
electricChars: "{}:",\n
configure: function(obj) {\n
if (obj.json != null) json = obj.json;\n
}\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>13942</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsesparql.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
var SparqlParser = Editor.Parser = (function() {\n
function wordRegexp(words) {\n
return new RegExp("^(?:" + words.join("|") + ")$", "i");\n
}\n
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",\n
"isblank", "isliteral", "union", "a"]);\n
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",\n
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",\n
"graph", "by", "asc", "desc"]);\n
var operatorChars = /[*+\\-<>=&|]/;\n
\n
var tokenizeSparql = (function() {\n
function normal(source, setState) {\n
var ch = source.next();\n
if (ch == "$" || ch == "?") {\n
source.nextWhileMatches(/[\\w\\d]/);\n
return "sp-var";\n
}\n
else if (ch == "<" && !source.matches(/[\\s\\u00a0=]/)) {\n
source.nextWhileMatches(/[^\\s\\u00a0>]/);\n
if (source.equals(">")) source.next();\n
return "sp-uri";\n
}\n
else if (ch == "\\"" || ch == "\'") {\n
setState(inLiteral(ch));\n
return null;\n
}\n
else if (/[{}\\(\\),\\.;\\[\\]]/.test(ch)) {\n
return "sp-punc";\n
}\n
else if (ch == "#") {\n
while (!source.endOfLine()) source.next();\n
return "sp-comment";\n
}\n
else if (operatorChars.test(ch)) {\n
source.nextWhileMatches(operatorChars);\n
return "sp-operator";\n
}\n
else if (ch == ":") {\n
source.nextWhileMatches(/[\\w\\d\\._\\-]/);\n
return "sp-prefixed";\n
}\n
else {\n
source.nextWhileMatches(/[_\\w\\d]/);\n
if (source.equals(":")) {\n
source.next();\n
source.nextWhileMatches(/[\\w\\d_\\-]/);\n
return "sp-prefixed";\n
}\n
var word = source.get(), type;\n
if (ops.test(word))\n
type = "sp-operator";\n
else if (keywords.test(word))\n
type = "sp-keyword";\n
else\n
type = "sp-word";\n
return {style: type, content: word};\n
}\n
}\n
\n
function inLiteral(quote) {\n
return function(source, setState) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var ch = source.next();\n
if (ch == quote && !escaped) {\n
setState(normal);\n
break;\n
}\n
escaped = !escaped && ch == "\\\\";\n
}\n
return "sp-literal";\n
};\n
}\n
\n
return function(source, startState) {\n
return tokenizer(source, startState || normal);\n
};\n
})();\n
\n
function indentSparql(context) {\n
return function(nextChars) {\n
var firstChar = nextChars && nextChars.charAt(0);\n
if (/[\\]\\}]/.test(firstChar))\n
while (context && context.type == "pattern") context = context.prev;\n
\n
var closing = context && firstChar == matching[context.type];\n
if (!context)\n
return 0;\n
else if (context.type == "pattern")\n
return context.col;\n
else if (context.align)\n
return context.col - (closing ? context.width : 0);\n
else\n
return context.indent + (closing ? 0 : indentUnit);\n
}\n
}\n
\n
function parseSparql(source) {\n
var tokens = tokenizeSparql(source);\n
var context = null, indent = 0, col = 0;\n
function pushContext(type, width) {\n
context = {prev: context, indent: indent, col: col, type: type, width: width};\n
}\n
function popContext() {\n
context = context.prev;\n
}\n
\n
var iter = {\n
next: function() {\n
var token = tokens.next(), type = token.style, content = token.content, width = token.value.length;\n
\n
if (content == "\\n") {\n
token.indentation = indentSparql(context);\n
indent = col = 0;\n
if (context && context.align == null) context.align = false;\n
}\n
else if (type == "whitespace" && col == 0) {\n
indent = width;\n
}\n
else if (type != "sp-comment" && context && context.align == null) {\n
context.align = true;\n
}\n
\n
if (content != "\\n") col += width;\n
\n
if (/[\\[\\{\\(]/.test(content)) {\n
pushContext(content, width);\n
}\n
else if (/[\\]\\}\\)]/.test(content)) {\n
while (context && context.type == "pattern")\n
popContext();\n
if (context && content == matching[context.type])\n
popContext();\n
}\n
else if (content == "." && context && context.type == "pattern") {\n
popContext();\n
}\n
else if ((type == "sp-word" || type == "sp-prefixed" || type == "sp-uri" || type == "sp-var" || type == "sp-literal") &&\n
context && /[\\{\\[]/.test(context.type)) {\n
pushContext("pattern", width);\n
}\n
\n
return token;\n
},\n
\n
copy: function() {\n
var _context = context, _indent = indent, _col = col, _tokenState = tokens.state;\n
return function(source) {\n
tokens = tokenizeSparql(source, _tokenState);\n
context = _context;\n
indent = _indent;\n
col = _col;\n
return iter;\n
};\n
}\n
};\n
return iter;\n
}\n
\n
return {make: parseSparql, electricChars: "}]"};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>5147</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>parsexml.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>/* This file defines an XML parser, with a few kludges to make it\n
* useable for HTML. autoSelfClosers defines a set of tag names that\n
* are expected to not have a closing tag, and doNotIndent specifies\n
* the tags inside of which no indentation should happen (see Config\n
* object). These can be disabled by passing the editor an object like\n
* {useHTMLKludges: false} as parserConfig option.\n
*/\n
\n
var XMLParser = Editor.Parser = (function() {\n
var Kludges = {\n
autoSelfClosers: {"br": true, "img": true, "hr": true, "link": true, "input": true,\n
"meta": true, "col": true, "frame": true, "base": true, "area": true},\n
doNotIndent: {"pre": true, "!cdata": true}\n
};\n
var NoKludges = {autoSelfClosers: {}, doNotIndent: {"!cdata": true}};\n
var UseKludges = Kludges;\n
var alignCDATA = false;\n
\n
// Simple stateful tokenizer for XML documents. Returns a\n
// MochiKit-style iterator, with a state property that contains a\n
// function encapsulating the current state. See tokenize.js.\n
var tokenizeXML = (function() {\n
function inText(source, setState) {\n
var ch = source.next();\n
if (ch == "\074") {\n
if (source.equals("!")) {\n
source.next();\n
if (source.equals("[")) {\n
if (source.lookAhead("[CDATA[", true)) {\n
setState(inBlock("xml-cdata", "]]\076"));\n
return null;\n
}\n
else {\n
return "xml-text";\n
}\n
}\n
else if (source.lookAhead("--", true)) {\n
setState(inBlock("xml-comment", "--\076"));\n
return null;\n
}\n
else {\n
return "xml-text";\n
}\n
}\n
else if (source.equals("?")) {\n
source.next();\n
source.nextWhileMatches(/[\\w\\._\\-]/);\n
setState(inBlock("xml-processing", "?\076"));\n
return "xml-processing";\n
}\n
else {\n
if (source.equals("/")) source.next();\n
setState(inTag);\n
return "xml-punctuation";\n
}\n
}\n
else if (ch == "\046") {\n
while (!source.endOfLine()) {\n
if (source.next() == ";")\n
break;\n
}\n
return "xml-entity";\n
}\n
else {\n
source.nextWhileMatches(/[^\046\074\\n]/);\n
return "xml-text";\n
}\n
}\n
\n
function inTag(source, setState) {\n
var ch = source.next();\n
if (ch == "\076") {\n
setState(inText);\n
return "xml-punctuation";\n
}\n
else if (/[?\\/]/.test(ch) \046\046 source.equals("\076")) {\n
source.next();\n
setState(inText);\n
return "xml-punctuation";\n
}\n
else if (ch == "=") {\n
return "xml-punctuation";\n
}\n
else if (/[\\\'\\"]/.test(ch)) {\n
setState(inAttribute(ch));\n
return null;\n
}\n
else {\n
source.nextWhileMatches(/[^\\s\\u00a0=\074\076\\"\\\'\\/?]/);\n
return "xml-name";\n
}\n
}\n
\n
function inAttribute(quote) {\n
return function(source, setState) {\n
while (!source.endOfLine()) {\n
if (source.next() == quote) {\n
setState(inTag);\n
break;\n
}\n
}\n
return "xml-attribute";\n
};\n
}\n
\n
function inBlock(style, terminator) {\n
return function(source, setState) {\n
while (!source.endOfLine()) {\n
if (source.lookAhead(terminator, true)) {\n
setState(inText);\n
break;\n
}\n
source.next();\n
}\n
return style;\n
};\n
}\n
\n
return function(source, startState) {\n
return tokenizer(source, startState || inText);\n
};\n
})();\n
\n
// The parser. The structure of this function largely follows that of\n
// parseJavaScript in parsejavascript.js (there is actually a bit more\n
// shared code than I\'d like), but it is quite a bit simpler.\n
function parseXML(source) {\n
var tokens = tokenizeXML(source), token;\n
var cc = [base];\n
var tokenNr = 0, indented = 0;\n
var currentTag = null, context = null;\n
var consume;\n
\n
function push(fs) {\n
for (var i = fs.length - 1; i \076= 0; i--)\n
cc.push(fs[i]);\n
}\n
function cont() {\n
push(arguments);\n
consume = true;\n
}\n
function pass() {\n
push(arguments);\n
consume = false;\n
}\n
\n
function markErr() {\n
token.style += " xml-error";\n
}\n
function expect(text) {\n
return function(style, content) {\n
if (content == text) cont();\n
else {markErr(); cont(arguments.callee);}\n
};\n
}\n
\n
function pushContext(tagname, startOfLine) {\n
var noIndent = UseKludges.doNotIndent.hasOwnProperty(tagname) || (context \046\046 context.noIndent);\n
context = {prev: context, name: tagname, indent: indented, startOfLine: startOfLine, noIndent: noIndent};\n
}\n
function popContext() {\n
context = context.prev;\n
}\n
function computeIndentation(baseContext) {\n
return function(nextChars, current) {\n
var context = baseContext;\n
if (context \046\046 context.noIndent)\n
return current;\n
if (alignCDATA \046\046 /\074!\\[CDATA\\[/.test(nextChars))\n
return 0;\n
if (context \046\046 /^\074\\//.test(nextChars))\n
context = context.prev;\n
while (context \046\046 !context.startOfLine)\n
context = context.prev;\n
if (context)\n
return context.indent + indentUnit;\n
else\n
return 0;\n
};\n
}\n
\n
function base() {\n
return pass(element, base);\n
}\n
var harmlessTokens = {"xml-text": true, "xml-entity": true, "xml-comment": true, "xml-processing": true};\n
function element(style, content) {\n
if (content == "\074") cont(tagname, attributes, endtag(tokenNr == 1));\n
else if (content == "\074/") cont(closetagname, expect("\076"));\n
else if (style == "xml-cdata") {\n
if (!context || context.name != "!cdata") pushContext("!cdata");\n
if (/\\]\\]\076$/.test(content)) popContext();\n
cont();\n
}\n
else if (harmlessTokens.hasOwnProperty(style)) cont();\n
else {markErr(); cont();}\n
}\n
function tagname(style, content) {\n
if (style == "xml-name") {\n
currentTag = content.toLowerCase();\n
token.style = "xml-tagname";\n
cont();\n
}\n
else {\n
currentTag = null;\n
pass();\n
}\n
}\n
function closetagname(style, content) {\n
if (style == "xml-name") {\n
token.style = "xml-tagname";\n
if (context \046\046 content.toLowerCase() == context.name) popContext();\n
else markErr();\n
}\n
cont();\n
}\n
function endtag(startOfLine) {\n
return function(style, content) {\n
if (content == "/\076" || (content == "\076" \046\046 UseKludges.autoSelfClosers.hasOwnProperty(currentTag))) cont();\n
else if (content == "\076") {pushContext(currentTag, startOfLine); cont();}\n
else {markErr(); cont(arguments.callee);}\n
};\n
}\n
function attributes(style) {\n
if (style == "xml-name") {token.style = "xml-attname"; cont(attribute, attributes);}\n
else pass();\n
}\n
function attribute(style, content) {\n
if (content == "=") cont(value);\n
else if (content == "\076" || content == "/\076") pass(endtag);\n
else pass();\n
}\n
function value(style) {\n
if (style == "xml-attribute") cont(value);\n
else pass();\n
}\n
\n
return {\n
indentation: function() {return indented;},\n
\n
next: function(){\n
token = tokens.next();\n
if (token.style == "whitespace" \046\046 tokenNr == 0)\n
indented = token.value.length;\n
else\n
tokenNr++;\n
if (token.content == "\\n") {\n
indented = tokenNr = 0;\n
token.indentation = computeIndentation(context);\n
}\n
\n
if (token.style == "whitespace" || token.type == "xml-comment")\n
return token;\n
\n
while(true){\n
consume = false;\n
cc.pop()(token.style, token.content);\n
if (consume) return token;\n
}\n
},\n
\n
copy: function(){\n
var _cc = cc.concat([]), _tokenState = tokens.state, _context = context;\n
var parser = this;\n
\n
return function(input){\n
cc = _cc.concat([]);\n
tokenNr = indented = 0;\n
context = _context;\n
tokens = tokenizeXML(input, _tokenState);\n
return parser;\n
};\n
}\n
};\n
}\n
\n
return {\n
make: parseXML,\n
electricChars: "/",\n
configure: function(config) {\n
if (config.useHTMLKludges != null)\n
UseKludges = config.useHTMLKludges ? Kludges : NoKludges;\n
if (config.alignCDATA)\n
alignCDATA = config.alignCDATA;\n
}\n
};\n
})();\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>8533</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>select.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Functionality for finding, storing, and restoring selections\n
*\n
* This does not provide a generic API, just the minimal functionality\n
* required by the CodeMirror system.\n
*/\n
\n
// Namespace object.\n
var select = {};\n
\n
(function() {\n
select.ie_selection = document.selection && document.selection.createRangeCollection;\n
\n
// Find the \'top-level\' (defined as \'a direct child of the node\n
// passed as the top argument\') node that the given node is\n
// contained in. Return null if the given node is not inside the top\n
// node.\n
function topLevelNodeAt(node, top) {\n
while (node && node.parentNode != top)\n
node = node.parentNode;\n
return node;\n
}\n
\n
// Find the top-level node that contains the node before this one.\n
function topLevelNodeBefore(node, top) {\n
while (!node.previousSibling && node.parentNode != top)\n
node = node.parentNode;\n
return topLevelNodeAt(node.previousSibling, top);\n
}\n
\n
var fourSpaces = "\\u00a0\\u00a0\\u00a0\\u00a0";\n
\n
select.scrollToNode = function(node, cursor) {\n
if (!node) return;\n
var element = node, body = document.body,\n
html = document.documentElement,\n
atEnd = !element.nextSibling || !element.nextSibling.nextSibling\n
|| !element.nextSibling.nextSibling.nextSibling;\n
// In Opera (and recent Webkit versions), BR elements *always*\n
// have a offsetTop property of zero.\n
var compensateHack = 0;\n
while (element && !element.offsetTop) {\n
compensateHack++;\n
element = element.previousSibling;\n
}\n
// atEnd is another kludge for these browsers -- if the cursor is\n
// at the end of the document, and the node doesn\'t have an\n
// offset, just scroll to the end.\n
if (compensateHack == 0) atEnd = false;\n
\n
// WebKit has a bad habit of (sometimes) happily returning bogus\n
// offsets when the document has just been changed. This seems to\n
// always be 5/5, so we don\'t use those.\n
if (webkit && element && element.offsetTop == 5 && element.offsetLeft == 5)\n
return;\n
\n
var y = compensateHack * (element ? element.offsetHeight : 0), x = 0,\n
width = (node ? node.offsetWidth : 0), pos = element;\n
while (pos && pos.offsetParent) {\n
y += pos.offsetTop;\n
// Don\'t count X offset for <br> nodes\n
if (!isBR(pos))\n
x += pos.offsetLeft;\n
pos = pos.offsetParent;\n
}\n
\n
var scroll_x = body.scrollLeft || html.scrollLeft || 0,\n
scroll_y = body.scrollTop || html.scrollTop || 0,\n
scroll = false, screen_width = window.innerWidth || html.clientWidth || 0;\n
\n
if (cursor || width < screen_width) {\n
if (cursor) {\n
var off = select.offsetInNode(node), size = nodeText(node).length;\n
if (size) x += width * (off / size);\n
}\n
var screen_x = x - scroll_x;\n
if (screen_x < 0 || screen_x > screen_width) {\n
scroll_x = x;\n
scroll = true;\n
}\n
}\n
var screen_y = y - scroll_y;\n
if (screen_y < 0 || atEnd || screen_y > (window.innerHeight || html.clientHeight || 0) - 50) {\n
scroll_y = atEnd ? 1e6 : y;\n
scroll = true;\n
}\n
if (scroll) window.scrollTo(scroll_x, scroll_y);\n
};\n
\n
select.scrollToCursor = function(container) {\n
select.scrollToNode(select.selectionTopNode(container, true) || container.firstChild, true);\n
};\n
\n
// Used to prevent restoring a selection when we do not need to.\n
var currentSelection = null;\n
\n
select.snapshotChanged = function() {\n
if (currentSelection) currentSelection.changed = true;\n
};\n
\n
// This is called by the code in editor.js whenever it is replacing\n
// a text node. The function sees whether the given oldNode is part\n
// of the current selection, and updates this selection if it is.\n
// Because nodes are often only partially replaced, the length of\n
// the part that gets replaced has to be taken into account -- the\n
// selection might stay in the oldNode if the newNode is smaller\n
// than the selection\'s offset. The offset argument is needed in\n
// case the selection does move to the new object, and the given\n
// length is not the whole length of the new node (part of it might\n
// have been used to replace another node).\n
select.snapshotReplaceNode = function(from, to, length, offset) {\n
if (!currentSelection) return;\n
\n
function replace(point) {\n
if (from == point.node) {\n
currentSelection.changed = true;\n
if (length && point.offset > length) {\n
point.offset -= length;\n
}\n
else {\n
point.node = to;\n
point.offset += (offset || 0);\n
}\n
}\n
}\n
replace(currentSelection.start);\n
replace(currentSelection.end);\n
};\n
\n
select.snapshotMove = function(from, to, distance, relative, ifAtStart) {\n
if (!currentSelection) return;\n
\n
function move(point) {\n
if (from == point.node && (!ifAtStart || point.offset == 0)) {\n
currentSelection.changed = true;\n
point.node = to;\n
if (relative) point.offset = Math.max(0, point.offset + distance);\n
else point.offset = distance;\n
}\n
}\n
move(currentSelection.start);\n
move(currentSelection.end);\n
};\n
\n
// Most functions are defined in two ways, one for the IE selection\n
// model, one for the W3C one.\n
if (select.ie_selection) {\n
function selectionNode(start) {\n
var range = document.selection.createRange();\n
range.collapse(start);\n
\n
function nodeAfter(node) {\n
var found = null;\n
while (!found && node) {\n
found = node.nextSibling;\n
node = node.parentNode;\n
}\n
return nodeAtStartOf(found);\n
}\n
\n
function nodeAtStartOf(node) {\n
while (node && node.firstChild) node = node.firstChild;\n
return {node: node, offset: 0};\n
}\n
\n
var containing = range.parentElement();\n
if (!isAncestor(document.body, containing)) return null;\n
if (!containing.firstChild) return nodeAtStartOf(containing);\n
\n
var working = range.duplicate();\n
working.moveToElementText(containing);\n
working.collapse(true);\n
for (var cur = containing.firstChild; cur; cur = cur.nextSibling) {\n
if (cur.nodeType == 3) {\n
var size = cur.nodeValue.length;\n
working.move("character", size);\n
}\n
else {\n
working.moveToElementText(cur);\n
working.collapse(false);\n
}\n
\n
var dir = range.compareEndPoints("StartToStart", working);\n
if (dir == 0) return nodeAfter(cur);\n
if (dir == 1) continue;\n
if (cur.nodeType != 3) return nodeAtStartOf(cur);\n
\n
working.setEndPoint("StartToEnd", range);\n
return {node: cur, offset: size - working.text.length};\n
}\n
return nodeAfter(containing);\n
}\n
\n
select.markSelection = function() {\n
currentSelection = null;\n
var sel = document.selection;\n
if (!sel) return;\n
var start = selectionNode(true),\n
end = selectionNode(false);\n
if (!start || !end) return;\n
currentSelection = {start: start, end: end, changed: false};\n
};\n
\n
select.selectMarked = function() {\n
if (!currentSelection || !currentSelection.changed) return;\n
\n
function makeRange(point) {\n
var range = document.body.createTextRange(),\n
node = point.node;\n
if (!node) {\n
range.moveToElementText(document.body);\n
range.collapse(false);\n
}\n
else if (node.nodeType == 3) {\n
range.moveToElementText(node.parentNode);\n
var offset = point.offset;\n
while (node.previousSibling) {\n
node = node.previousSibling;\n
offset += (node.innerText || "").length;\n
}\n
range.move("character", offset);\n
}\n
else {\n
range.moveToElementText(node);\n
range.collapse(true);\n
}\n
return range;\n
}\n
\n
var start = makeRange(currentSelection.start), end = makeRange(currentSelection.end);\n
start.setEndPoint("StartToEnd", end);\n
start.select();\n
};\n
\n
select.offsetInNode = function(node) {\n
var sel = document.selection;\n
if (!sel) return 0;\n
var range = sel.createRange(), range2 = range.duplicate();\n
try {range2.moveToElementText(node);} catch(e){return 0;}\n
range.setEndPoint("StartToStart", range2);\n
return range.text.length;\n
};\n
\n
// Get the top-level node that one end of the cursor is inside or\n
// after. Note that this returns false for \'no cursor\', and null\n
// for \'start of document\'.\n
select.selectionTopNode = function(container, start) {\n
var selection = document.selection;\n
if (!selection) return false;\n
\n
var range = selection.createRange(), range2 = range.duplicate();\n
range.collapse(start);\n
var around = range.parentElement();\n
if (around && isAncestor(container, around)) {\n
// Only use this node if the selection is not at its start.\n
range2.moveToElementText(around);\n
if (range.compareEndPoints("StartToStart", range2) == 1)\n
return topLevelNodeAt(around, container);\n
}\n
\n
// Move the start of a range to the start of a node,\n
// compensating for the fact that you can\'t call\n
// moveToElementText with text nodes.\n
function moveToNodeStart(range, node) {\n
if (node.nodeType == 3) {\n
var count = 0, cur = node.previousSibling;\n
while (cur && cur.nodeType == 3) {\n
count += cur.nodeValue.length;\n
cur = cur.previousSibling;\n
}\n
if (cur) {\n
try{range.moveToElementText(cur);}\n
catch(e){return false;}\n
range.collapse(false);\n
}\n
else range.moveToElementText(node.parentNode);\n
if (count) range.move("character", count);\n
}\n
else {\n
try{range.moveToElementText(node);}\n
catch(e){return false;}\n
}\n
return true;\n
}\n
\n
// Do a binary search through the container object, comparing\n
// the start of each node to the selection\n
var start = 0, end = container.childNodes.length - 1;\n
while (start < end) {\n
var middle = Math.ceil((end + start) / 2), node = container.childNodes[middle];\n
if (!node) return false; // Don\'t ask. IE6 manages this sometimes.\n
if (!moveToNodeStart(range2, node)) return false;\n
if (range.compareEndPoints("StartToStart", range2) == 1)\n
start = middle;\n
else\n
end = middle - 1;\n
}\n
\n
if (start == 0) {\n
var test1 = selection.createRange(), test2 = test1.duplicate();\n
test2.moveToElementText(container);\n
if (test1.compareEndPoints("StartToStart", test2) == 0)\n
return null;\n
}\n
return container.childNodes[start] || null;\n
};\n
\n
// Place the cursor after this.start. This is only useful when\n
// manually moving the cursor instead of restoring it to its old\n
// position.\n
select.focusAfterNode = function(node, container) {\n
var range = document.body.createTextRange();\n
range.moveToElementText(node || container);\n
range.collapse(!node);\n
range.select();\n
};\n
\n
select.somethingSelected = function() {\n
var sel = document.selection;\n
return sel && (sel.createRange().text != "");\n
};\n
\n
function insertAtCursor(html) {\n
var selection = document.selection;\n
if (selection) {\n
var range = selection.createRange();\n
range.pasteHTML(html);\n
range.collapse(false);\n
range.select();\n
}\n
}\n
\n
// Used to normalize the effect of the enter key, since browsers\n
// do widely different things when pressing enter in designMode.\n
select.insertNewlineAtCursor = function() {\n
insertAtCursor("<br>");\n
};\n
\n
select.insertTabAtCursor = function() {\n
insertAtCursor(fourSpaces);\n
};\n
\n
// Get the BR node at the start of the line on which the cursor\n
// currently is, and the offset into the line. Returns null as\n
// node if cursor is on first line.\n
select.cursorPos = function(container, start) {\n
var selection = document.selection;\n
if (!selection) return null;\n
\n
var topNode = select.selectionTopNode(container, start);\n
while (topNode && !isBR(topNode))\n
topNode = topNode.previousSibling;\n
\n
var range = selection.createRange(), range2 = range.duplicate();\n
range.collapse(start);\n
if (topNode) {\n
range2.moveToElementText(topNode);\n
range2.collapse(false);\n
}\n
else {\n
// When nothing is selected, we can get all kinds of funky errors here.\n
try { range2.moveToElementText(container); }\n
catch (e) { return null; }\n
range2.collapse(true);\n
}\n
range.setEndPoint("StartToStart", range2);\n
\n
return {node: topNode, offset: range.text.length};\n
};\n
\n
select.setCursorPos = function(container, from, to) {\n
function rangeAt(pos) {\n
var range = document.body.createTextRange();\n
if (!pos.node) {\n
range.moveToElementText(container);\n
range.collapse(true);\n
}\n
else {\n
range.moveToElementText(pos.node);\n
range.collapse(false);\n
}\n
range.move("character", pos.offset);\n
return range;\n
}\n
\n
var range = rangeAt(from);\n
if (to && to != from)\n
range.setEndPoint("EndToEnd", rangeAt(to));\n
range.select();\n
}\n
\n
// Some hacks for storing and re-storing the selection when the editor loses and regains focus.\n
select.getBookmark = function (container) {\n
var from = select.cursorPos(container, true), to = select.cursorPos(container, false);\n
if (from && to) return {from: from, to: to};\n
};\n
\n
// Restore a stored selection.\n
select.setBookmark = function(container, mark) {\n
if (!mark) return;\n
select.setCursorPos(container, mark.from, mark.to);\n
};\n
}\n
// W3C model\n
else {\n
// Find the node right at the cursor, not one of its\n
// ancestors with a suitable offset. This goes down the DOM tree\n
// until a \'leaf\' is reached (or is it *up* the DOM tree?).\n
function innerNode(node, offset) {\n
while (node.nodeType != 3 && !isBR(node)) {\n
var newNode = node.childNodes[offset] || node.nextSibling;\n
offset = 0;\n
while (!newNode && node.parentNode) {\n
node = node.parentNode;\n
newNode = node.nextSibling;\n
}\n
node = newNode;\n
if (!newNode) break;\n
}\n
return {node: node, offset: offset};\n
}\n
\n
// Store start and end nodes, and offsets within these, and refer\n
// back to the selection object from those nodes, so that this\n
// object can be updated when the nodes are replaced before the\n
// selection is restored.\n
select.markSelection = function () {\n
var selection = window.getSelection();\n
if (!selection || selection.rangeCount == 0)\n
return (currentSelection = null);\n
var range = selection.getRangeAt(0);\n
\n
currentSelection = {\n
start: innerNode(range.startContainer, range.startOffset),\n
end: innerNode(range.endContainer, range.endOffset),\n
changed: false\n
};\n
};\n
\n
select.selectMarked = function () {\n
var cs = currentSelection;\n
// on webkit-based browsers, it is apparently possible that the\n
// selection gets reset even when a node that is not one of the\n
// endpoints get messed with. the most common situation where\n
// this occurs is when a selection is deleted or overwitten. we\n
// check for that here.\n
function focusIssue() {\n
if (cs.start.node == cs.end.node && cs.start.offset == cs.end.offset) {\n
var selection = window.getSelection();\n
if (!selection || selection.rangeCount == 0) return true;\n
var range = selection.getRangeAt(0), point = innerNode(range.startContainer, range.startOffset);\n
return cs.start.node != point.node || cs.start.offset != point.offset;\n
}\n
}\n
if (!cs || !(cs.changed || (webkit && focusIssue()))) return;\n
var range = document.createRange();\n
\n
function setPoint(point, which) {\n
if (point.node) {\n
// Some magic to generalize the setting of the start and end\n
// of a range.\n
if (point.offset == 0)\n
range["set" + which + "Before"](point.node);\n
else\n
range["set" + which](point.node, point.offset);\n
}\n
else {\n
range.setStartAfter(document.body.lastChild || document.body);\n
}\n
}\n
\n
setPoint(cs.end, "End");\n
setPoint(cs.start, "Start");\n
selectRange(range);\n
};\n
\n
// Helper for selecting a range object.\n
function selectRange(range) {\n
var selection = window.getSelection();\n
if (!selection) return;\n
selection.removeAllRanges();\n
selection.addRange(range);\n
}\n
function selectionRange() {\n
var selection = window.getSelection();\n
if (!selection || selection.rangeCount == 0)\n
return false;\n
else\n
return selection.getRangeAt(0);\n
}\n
\n
// Finding the top-level node at the cursor in the W3C is, as you\n
// can see, quite an involved process.\n
select.selectionTopNode = function(container, start) {\n
var range = selectionRange();\n
if (!range) return false;\n
\n
var node = start ? range.startContainer : range.endContainer;\n
var offset = start ? range.startOffset : range.endOffset;\n
// Work around (yet another) bug in Opera\'s selection model.\n
if (window.opera && !start && range.endContainer == container && range.endOffset == range.startOffset + 1 &&\n
container.childNodes[range.startOffset] && isBR(container.childNodes[range.startOffset]))\n
offset--;\n
\n
// For text nodes, we look at the node itself if the cursor is\n
// inside, or at the node before it if the cursor is at the\n
// start.\n
if (node.nodeType == 3){\n
if (offset > 0)\n
return topLevelNodeAt(node, container);\n
else\n
return topLevelNodeBefore(node, container);\n
}\n
// Occasionally, browsers will return the HTML node as\n
// selection. If the offset is 0, we take the start of the frame\n
// (\'after null\'), otherwise, we take the last node.\n
else if (node.nodeName.toUpperCase() == "HTML") {\n
return (offset == 1 ? null : container.lastChild);\n
}\n
// If the given node is our \'container\', we just look up the\n
// correct node by using the offset.\n
else if (node == container) {\n
return (offset == 0) ? null : node.childNodes[offset - 1];\n
}\n
// In any other case, we have a regular node. If the cursor is\n
// at the end of the node, we use the node itself, if it is at\n
// the start, we use the node before it, and in any other\n
// case, we look up the child before the cursor and use that.\n
else {\n
if (offset == node.childNodes.length)\n
return topLevelNodeAt(node, container);\n
else if (offset == 0)\n
return topLevelNodeBefore(node, container);\n
else\n
return topLevelNodeAt(node.childNodes[offset - 1], container);\n
}\n
};\n
\n
select.focusAfterNode = function(node, container) {\n
var range = document.createRange();\n
range.setStartBefore(container.firstChild || container);\n
// In Opera, setting the end of a range at the end of a line\n
// (before a BR) will cause the cursor to appear on the next\n
// line, so we set the end inside of the start node when\n
// possible.\n
if (node && !node.firstChild)\n
range.setEndAfter(node);\n
else if (node)\n
range.setEnd(node, node.childNodes.length);\n
else\n
range.setEndBefore(container.firstChild || container);\n
range.collapse(false);\n
selectRange(range);\n
};\n
\n
select.somethingSelected = function() {\n
var range = selectionRange();\n
return range && !range.collapsed;\n
};\n
\n
select.offsetInNode = function(node) {\n
var range = selectionRange();\n
if (!range) return 0;\n
range = range.cloneRange();\n
range.setStartBefore(node);\n
return range.toString().length;\n
};\n
\n
function insertNodeAtCursor(node) {\n
var range = selectionRange();\n
if (!range) return;\n
\n
range.deleteContents();\n
range.insertNode(node);\n
webkitLastLineHack(document.body);\n
\n
// work around weirdness where Opera will magically insert a new\n
// BR node when a BR node inside a span is moved around. makes\n
// sure the BR ends up outside of spans.\n
if (window.opera && isBR(node) && isSpan(node.parentNode)) {\n
var next = node.nextSibling, p = node.parentNode, outer = p.parentNode;\n
outer.insertBefore(node, p.nextSibling);\n
var textAfter = "";\n
for (; next && next.nodeType == 3; next = next.nextSibling) {\n
textAfter += next.nodeValue;\n
removeElement(next);\n
}\n
outer.insertBefore(makePartSpan(textAfter, document), node.nextSibling);\n
}\n
range = document.createRange();\n
range.selectNode(node);\n
range.collapse(false);\n
selectRange(range);\n
}\n
\n
select.insertNewlineAtCursor = function() {\n
insertNodeAtCursor(document.createElement("BR"));\n
};\n
\n
select.insertTabAtCursor = function() {\n
insertNodeAtCursor(document.createTextNode(fourSpaces));\n
};\n
\n
select.cursorPos = function(container, start) {\n
var range = selectionRange();\n
if (!range) return;\n
\n
var topNode = select.selectionTopNode(container, start);\n
while (topNode && !isBR(topNode))\n
topNode = topNode.previousSibling;\n
\n
range = range.cloneRange();\n
range.collapse(start);\n
if (topNode)\n
range.setStartAfter(topNode);\n
else\n
range.setStartBefore(container);\n
\n
var text = range.toString();\n
return {node: topNode, offset: text.length};\n
};\n
\n
select.setCursorPos = function(container, from, to) {\n
var range = document.createRange();\n
\n
function setPoint(node, offset, side) {\n
if (offset == 0 && node && !node.nextSibling) {\n
range["set" + side + "After"](node);\n
return true;\n
}\n
\n
if (!node)\n
node = container.firstChild;\n
else\n
node = node.nextSibling;\n
\n
if (!node) return;\n
\n
if (offset == 0) {\n
range["set" + side + "Before"](node);\n
return true;\n
}\n
\n
var backlog = []\n
function decompose(node) {\n
if (node.nodeType == 3)\n
backlog.push(node);\n
else\n
forEach(node.childNodes, decompose);\n
}\n
while (true) {\n
while (node && !backlog.length) {\n
decompose(node);\n
node = node.nextSibling;\n
}\n
var cur = backlog.shift();\n
if (!cur) return false;\n
\n
var length = cur.nodeValue.length;\n
if (length >= offset) {\n
range["set" + side](cur, offset);\n
return true;\n
}\n
offset -= length;\n
}\n
}\n
\n
to = to || from;\n
if (setPoint(to.node, to.offset, "End") && setPoint(from.node, from.offset, "Start"))\n
selectRange(range);\n
};\n
}\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>23211</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.95</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>stringstream.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* String streams are the things fed to parsers (which can feed them\n
* to a tokenizer if they want). They provide peek and next methods\n
* for looking at the current character (next \'consumes\' this\n
* character, peek does not), and a get method for retrieving all the\n
* text that was consumed since the last time get was called.\n
*\n
* An easy mistake to make is to let a StopIteration exception finish\n
* the token stream while there are still characters pending in the\n
* string stream (hitting the end of the buffer while parsing a\n
* token). To make it easier to detect such errors, the stringstreams\n
* throw an exception when this happens.\n
*/\n
\n
// Make a stringstream stream out of an iterator that returns strings.\n
// This is applied to the result of traverseDOM (see codemirror.js),\n
// and the resulting stream is fed to the parser.\n
var stringStream = function(source){\n
// String that\'s currently being iterated over.\n
var current = "";\n
// Position in that string.\n
var pos = 0;\n
// Accumulator for strings that have been iterated over but not\n
// get()-ed yet.\n
var accum = "";\n
// Make sure there are more characters ready, or throw\n
// StopIteration.\n
function ensureChars() {\n
while (pos == current.length) {\n
accum += current;\n
current = ""; // In case source.next() throws\n
pos = 0;\n
try {current = source.next();}\n
catch (e) {\n
if (e != StopIteration) throw e;\n
else return false;\n
}\n
}\n
return true;\n
}\n
\n
return {\n
// peek: -> character\n
// Return the next character in the stream.\n
peek: function() {\n
if (!ensureChars()) return null;\n
return current.charAt(pos);\n
},\n
// next: -> character\n
// Get the next character, throw StopIteration if at end, check\n
// for unused content.\n
next: function() {\n
if (!ensureChars()) {\n
if (accum.length > 0)\n
throw "End of stringstream reached without emptying buffer (\'" + accum + "\').";\n
else\n
throw StopIteration;\n
}\n
return current.charAt(pos++);\n
},\n
// get(): -> string\n
// Return the characters iterated over since the last call to\n
// .get().\n
get: function() {\n
var temp = accum;\n
accum = "";\n
if (pos > 0){\n
temp += current.slice(0, pos);\n
current = current.slice(pos);\n
pos = 0;\n
}\n
return temp;\n
},\n
// Push a string back into the stream.\n
push: function(str) {\n
current = current.slice(0, pos) + str + current.slice(pos);\n
},\n
lookAhead: function(str, consume, skipSpaces, caseInsensitive) {\n
function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}\n
str = cased(str);\n
var found = false;\n
\n
var _accum = accum, _pos = pos;\n
if (skipSpaces) this.nextWhileMatches(/[\\s\\u00a0]/);\n
\n
while (true) {\n
var end = pos + str.length, left = current.length - pos;\n
if (end <= current.length) {\n
found = str == cased(current.slice(pos, end));\n
pos = end;\n
break;\n
}\n
else if (str.slice(0, left) == cased(current.slice(pos))) {\n
accum += current; current = "";\n
try {current = source.next();}\n
catch (e) {break;}\n
pos = 0;\n
str = str.slice(left);\n
}\n
else {\n
break;\n
}\n
}\n
\n
if (!(found && consume)) {\n
current = accum.slice(_accum.length) + current;\n
pos = _pos;\n
accum = _accum;\n
}\n
\n
return found;\n
},\n
\n
// Utils built on top of the above\n
// more: -> boolean\n
// Produce true if the stream isn\'t empty.\n
more: function() {\n
return this.peek() !== null;\n
},\n
applies: function(test) {\n
var next = this.peek();\n
return (next !== null && test(next));\n
},\n
nextWhile: function(test) {\n
var next;\n
while ((next = this.peek()) !== null && test(next))\n
this.next();\n
},\n
matches: function(re) {\n
var next = this.peek();\n
return (next !== null && re.test(next));\n
},\n
nextWhileMatches: function(re) {\n
var next;\n
while ((next = this.peek()) !== null && re.test(next))\n
this.next();\n
},\n
equals: function(ch) {\n
return ch === this.peek();\n
},\n
endOfLine: function() {\n
var next = this.peek();\n
return next == null || next == "\\n";\n
}\n
};\n
};\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>4363</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>tokenize.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
// A framework for simple tokenizers. Takes care of newlines and\n
// white-space, and of getting the text from the source stream into\n
// the token object. A state is a function of two arguments -- a\n
// string stream and a setState function. The second can be used to\n
// change the tokenizer\'s state, and can be ignored for stateless\n
// tokenizers. This function should advance the stream over a token\n
// and return a string or object containing information about the next\n
// token, or null to pass and have the (new) state be called to finish\n
// the token. When a string is given, it is wrapped in a {style, type}\n
// object. In the resulting object, the characters consumed are stored\n
// under the content property. Any whitespace following them is also\n
// automatically consumed, and added to the value property. (Thus,\n
// content is the actual meaningful part of the token, while value\n
// contains all the text it spans.)\n
\n
function tokenizer(source, state) {\n
// Newlines are always a separate token.\n
function isWhiteSpace(ch) {\n
// The messy regexp is because IE\'s regexp matcher is of the\n
// opinion that non-breaking spaces are no whitespace.\n
return ch != "\\n" && /^[\\s\\u00a0]*$/.test(ch);\n
}\n
\n
var tokenizer = {\n
state: state,\n
\n
take: function(type) {\n
if (typeof(type) == "string")\n
type = {style: type, type: type};\n
\n
type.content = (type.content || "") + source.get();\n
if (!/\\n$/.test(type.content))\n
source.nextWhile(isWhiteSpace);\n
type.value = type.content + source.get();\n
return type;\n
},\n
\n
next: function () {\n
if (!source.more()) throw StopIteration;\n
\n
var type;\n
if (source.equals("\\n")) {\n
source.next();\n
return this.take("whitespace");\n
}\n
\n
if (source.applies(isWhiteSpace))\n
type = "whitespace";\n
else\n
while (!type)\n
type = this.state(source, function(s) {tokenizer.state = s;});\n
\n
return this.take(type);\n
}\n
};\n
return tokenizer;\n
}\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2006</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>tokenizejavascript.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* Tokenizer for JavaScript code */\n
\n
var tokenizeJavaScript = (function() {\n
// Advance the stream until the given character (not preceded by a\n
// backslash) is encountered, or the end of the line is reached.\n
function nextUntilUnescaped(source, end) {\n
var escaped = false;\n
while (!source.endOfLine()) {\n
var next = source.next();\n
if (next == end && !escaped)\n
return false;\n
escaped = !escaped && next == "\\\\";\n
}\n
return escaped;\n
}\n
\n
// A map of JavaScript\'s keywords. The a/b/c keyword distinction is\n
// very rough, but it gives the parser enough information to parse\n
// correct code correctly (we don\'t care that much how we parse\n
// incorrect code). The style information included in these objects\n
// is used by the highlighter to pick the correct CSS style for a\n
// token.\n
var keywords = function(){\n
function result(type, style){\n
return {type: type, style: "js-" + style};\n
}\n
// keywords that take a parenthised expression, and then a\n
// statement (if)\n
var keywordA = result("keyword a", "keyword");\n
// keywords that take just a statement (else)\n
var keywordB = result("keyword b", "keyword");\n
// keywords that optionally take an expression, and form a\n
// statement (return)\n
var keywordC = result("keyword c", "keyword");\n
var operator = result("operator", "keyword");\n
var atom = result("atom", "atom");\n
return {\n
"if": keywordA, "while": keywordA, "with": keywordA,\n
"else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB,\n
"return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "delete": keywordC, "throw": keywordC,\n
"in": operator, "typeof": operator, "instanceof": operator,\n
"var": result("var", "keyword"), "function": result("function", "keyword"), "catch": result("catch", "keyword"),\n
"for": result("for", "keyword"), "switch": result("switch", "keyword"),\n
"case": result("case", "keyword"), "default": result("default", "keyword"),\n
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom\n
};\n
}();\n
\n
// Some helper regexps\n
var isOperatorChar = /[+\\-*&%=<>!?|]/;\n
var isHexDigit = /[0-9A-Fa-f]/;\n
var isWordChar = /[\\w\\$_]/;\n
\n
// Wrapper around jsToken that helps maintain parser state (whether\n
// we are inside of a multi-line comment and whether the next token\n
// could be a regular expression).\n
function jsTokenState(inside, regexp) {\n
return function(source, setState) {\n
var newInside = inside;\n
var type = jsToken(inside, regexp, source, function(c) {newInside = c;});\n
var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\\[{}\\(,;:]$/);\n
if (newRegexp != regexp || newInside != inside)\n
setState(jsTokenState(newInside, newRegexp));\n
return type;\n
};\n
}\n
\n
// The token reader, intended to be used by the tokenizer from\n
// tokenize.js (through jsTokenState). Advances the source stream\n
// over a token, and returns an object containing the type and style\n
// of that token.\n
function jsToken(inside, regexp, source, setInside) {\n
function readHexNumber(){\n
source.next(); // skip the \'x\'\n
source.nextWhileMatches(isHexDigit);\n
return {type: "number", style: "js-atom"};\n
}\n
\n
function readNumber() {\n
source.nextWhileMatches(/[0-9]/);\n
if (source.equals(".")){\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
if (source.equals("e") || source.equals("E")){\n
source.next();\n
if (source.equals("-"))\n
source.next();\n
source.nextWhileMatches(/[0-9]/);\n
}\n
return {type: "number", style: "js-atom"};\n
}\n
// Read a word, look it up in keywords. If not found, it is a\n
// variable, otherwise it is a keyword of the type found.\n
function readWord() {\n
source.nextWhileMatches(isWordChar);\n
var word = source.get();\n
var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];\n
return known ? {type: known.type, style: known.style, content: word} :\n
{type: "variable", style: "js-variable", content: word};\n
}\n
function readRegexp() {\n
nextUntilUnescaped(source, "/");\n
source.nextWhileMatches(/[gi]/);\n
return {type: "regexp", style: "js-string"};\n
}\n
// Mutli-line comments are tricky. We want to return the newlines\n
// embedded in them as regular newline tokens, and then continue\n
// returning a comment token for every line of the comment. So\n
// some state has to be saved (inside) to indicate whether we are\n
// inside a /* */ sequence.\n
function readMultilineComment(start){\n
var newInside = "/*";\n
var maybeEnd = (start == "*");\n
while (true) {\n
if (source.endOfLine())\n
break;\n
var next = source.next();\n
if (next == "/" && maybeEnd){\n
newInside = null;\n
break;\n
}\n
maybeEnd = (next == "*");\n
}\n
setInside(newInside);\n
return {type: "comment", style: "js-comment"};\n
}\n
function readOperator() {\n
source.nextWhileMatches(isOperatorChar);\n
return {type: "operator", style: "js-operator"};\n
}\n
function readString(quote) {\n
var endBackSlash = nextUntilUnescaped(source, quote);\n
setInside(endBackSlash ? quote : null);\n
return {type: "string", style: "js-string"};\n
}\n
\n
// Fetch the next token. Dispatches on first character in the\n
// stream, or first two characters when the first is a slash.\n
if (inside == "\\"" || inside == "\'")\n
return readString(inside);\n
var ch = source.next();\n
if (inside == "/*")\n
return readMultilineComment(ch);\n
else if (ch == "\\"" || ch == "\'")\n
return readString(ch);\n
// with punctuation, the type of the token is the symbol itself\n
else if (/[\\[\\]{}\\(\\),;\\:\\.]/.test(ch))\n
return {type: ch, style: "js-punctuation"};\n
else if (ch == "0" && (source.equals("x") || source.equals("X")))\n
return readHexNumber();\n
else if (/[0-9]/.test(ch))\n
return readNumber();\n
else if (ch == "/"){\n
if (source.equals("*"))\n
{ source.next(); return readMultilineComment(ch); }\n
else if (source.equals("/"))\n
{ nextUntilUnescaped(source, null); return {type: "comment", style: "js-comment"};}\n
else if (regexp)\n
return readRegexp();\n
else\n
return readOperator();\n
}\n
else if (isOperatorChar.test(ch))\n
return readOperator();\n
else\n
return readWord();\n
}\n
\n
// The external interface to the tokenizer.\n
return function(source, startState) {\n
return tokenizer(source, startState || jsTokenState(false, true));\n
};\n
})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>6769</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>undo.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/**\n
* Storage and control for undo information within a CodeMirror\n
* editor. \'Why on earth is such a complicated mess required for\n
* that?\', I hear you ask. The goal, in implementing this, was to make\n
* the complexity of storing and reverting undo information depend\n
* only on the size of the edited or restored content, not on the size\n
* of the whole document. This makes it necessary to use a kind of\n
* \'diff\' system, which, when applied to a DOM tree, causes some\n
* complexity and hackery.\n
*\n
* In short, the editor \'touches\' BR elements as it parses them, and\n
* the UndoHistory stores these. When nothing is touched in commitDelay\n
* milliseconds, the changes are committed: It goes over all touched\n
* nodes, throws out the ones that did not change since last commit or\n
* are no longer in the document, and assembles the rest into zero or\n
* more \'chains\' -- arrays of adjacent lines. Links back to these\n
* chains are added to the BR nodes, while the chain that previously\n
* spanned these nodes is added to the undo history. Undoing a change\n
* means taking such a chain off the undo history, restoring its\n
* content (text is saved per line) and linking it back into the\n
* document.\n
*/\n
\n
// A history object needs to know about the DOM container holding the\n
// document, the maximum amount of undo levels it should store, the\n
// delay (of no input) after which it commits a set of changes, and,\n
// unfortunately, the \'parent\' window -- a window that is not in\n
// designMode, and on which setTimeout works in every browser.\n
function UndoHistory(container, maxDepth, commitDelay, editor) {\n
this.container = container;\n
this.maxDepth = maxDepth; this.commitDelay = commitDelay;\n
this.editor = editor; this.parent = editor.parent;\n
// This line object represents the initial, empty editor.\n
var initial = {text: "", from: null, to: null};\n
// As the borders between lines are represented by BR elements, the\n
// start of the first line and the end of the last one are\n
// represented by null. Since you can not store any properties\n
// (links to line objects) in null, these properties are used in\n
// those cases.\n
this.first = initial; this.last = initial;\n
// Similarly, a \'historyTouched\' property is added to the BR in\n
// front of lines that have already been touched, and \'firstTouched\'\n
// is used for the first line.\n
this.firstTouched = false;\n
// History is the set of committed changes, touched is the set of\n
// nodes touched since the last commit.\n
this.history = []; this.redoHistory = []; this.touched = [];\n
}\n
\n
UndoHistory.prototype = {\n
// Schedule a commit (if no other touches come in for commitDelay\n
// milliseconds).\n
scheduleCommit: function() {\n
var self = this;\n
this.parent.clearTimeout(this.commitTimeout);\n
this.commitTimeout = this.parent.setTimeout(function(){self.tryCommit();}, this.commitDelay);\n
},\n
\n
// Mark a node as touched. Null is a valid argument.\n
touch: function(node) {\n
this.setTouched(node);\n
this.scheduleCommit();\n
},\n
\n
// Undo the last change.\n
undo: function() {\n
// Make sure pending changes have been committed.\n
this.commit();\n
\n
if (this.history.length) {\n
// Take the top diff from the history, apply it, and store its\n
// shadow in the redo history.\n
var item = this.history.pop();\n
this.redoHistory.push(this.updateTo(item, "applyChain"));\n
this.notifyEnvironment();\n
return this.chainNode(item);\n
}\n
},\n
\n
// Redo the last undone change.\n
redo: function() {\n
this.commit();\n
if (this.redoHistory.length) {\n
// The inverse of undo, basically.\n
var item = this.redoHistory.pop();\n
this.addUndoLevel(this.updateTo(item, "applyChain"));\n
this.notifyEnvironment();\n
return this.chainNode(item);\n
}\n
},\n
\n
clear: function() {\n
this.history = [];\n
this.redoHistory = [];\n
},\n
\n
// Ask for the size of the un/redo histories.\n
historySize: function() {\n
return {undo: this.history.length, redo: this.redoHistory.length};\n
},\n
\n
// Push a changeset into the document.\n
push: function(from, to, lines) {\n
var chain = [];\n
for (var i = 0; i < lines.length; i++) {\n
var end = (i == lines.length - 1) ? to : this.container.ownerDocument.createElement("BR");\n
chain.push({from: from, to: end, text: cleanText(lines[i])});\n
from = end;\n
}\n
this.pushChains([chain], from == null && to == null);\n
this.notifyEnvironment();\n
},\n
\n
pushChains: function(chains, doNotHighlight) {\n
this.commit(doNotHighlight);\n
this.addUndoLevel(this.updateTo(chains, "applyChain"));\n
this.redoHistory = [];\n
},\n
\n
// Retrieve a DOM node from a chain (for scrolling to it after undo/redo).\n
chainNode: function(chains) {\n
for (var i = 0; i < chains.length; i++) {\n
var start = chains[i][0], node = start && (start.from || start.to);\n
if (node) return node;\n
}\n
},\n
\n
// Clear the undo history, make the current document the start\n
// position.\n
reset: function() {\n
this.history = []; this.redoHistory = [];\n
},\n
\n
textAfter: function(br) {\n
return this.after(br).text;\n
},\n
\n
nodeAfter: function(br) {\n
return this.after(br).to;\n
},\n
\n
nodeBefore: function(br) {\n
return this.before(br).from;\n
},\n
\n
// Commit unless there are pending dirty nodes.\n
tryCommit: function() {\n
if (!window.parent || !window.UndoHistory) return; // Stop when frame has been unloaded\n
if (this.editor.highlightDirty()) this.commit(true);\n
else this.scheduleCommit();\n
},\n
\n
// Check whether the touched nodes hold any changes, if so, commit\n
// them.\n
commit: function(doNotHighlight) {\n
this.parent.clearTimeout(this.commitTimeout);\n
// Make sure there are no pending dirty nodes.\n
if (!doNotHighlight) this.editor.highlightDirty(true);\n
// Build set of chains.\n
var chains = this.touchedChains(), self = this;\n
\n
if (chains.length) {\n
this.addUndoLevel(this.updateTo(chains, "linkChain"));\n
this.redoHistory = [];\n
this.notifyEnvironment();\n
}\n
},\n
\n
// [ end of public interface ]\n
\n
// Update the document with a given set of chains, return its\n
// shadow. updateFunc should be "applyChain" or "linkChain". In the\n
// second case, the chains are taken to correspond the the current\n
// document, and only the state of the line data is updated. In the\n
// first case, the content of the chains is also pushed iinto the\n
// document.\n
updateTo: function(chains, updateFunc) {\n
var shadows = [], dirty = [];\n
for (var i = 0; i < chains.length; i++) {\n
shadows.push(this.shadowChain(chains[i]));\n
dirty.push(this[updateFunc](chains[i]));\n
}\n
if (updateFunc == "applyChain")\n
this.notifyDirty(dirty);\n
return shadows;\n
},\n
\n
// Notify the editor that some nodes have changed.\n
notifyDirty: function(nodes) {\n
forEach(nodes, method(this.editor, "addDirtyNode"))\n
this.editor.scheduleHighlight();\n
},\n
\n
notifyEnvironment: function() {\n
if (this.onChange) this.onChange();\n
// Used by the line-wrapping line-numbering code.\n
if (window.frameElement && window.frameElement.CodeMirror.updateNumbers)\n
window.frameElement.CodeMirror.updateNumbers();\n
},\n
\n
// Link a chain into the DOM nodes (or the first/last links for null\n
// nodes).\n
linkChain: function(chain) {\n
for (var i = 0; i < chain.length; i++) {\n
var line = chain[i];\n
if (line.from) line.from.historyAfter = line;\n
else this.first = line;\n
if (line.to) line.to.historyBefore = line;\n
else this.last = line;\n
}\n
},\n
\n
// Get the line object after/before a given node.\n
after: function(node) {\n
return node ? node.historyAfter : this.first;\n
},\n
before: function(node) {\n
return node ? node.historyBefore : this.last;\n
},\n
\n
// Mark a node as touched if it has not already been marked.\n
setTouched: function(node) {\n
if (node) {\n
if (!node.historyTouched) {\n
this.touched.push(node);\n
node.historyTouched = true;\n
}\n
}\n
else {\n
this.firstTouched = true;\n
}\n
},\n
\n
// Store a new set of undo info, throw away info if there is more of\n
// it than allowed.\n
addUndoLevel: function(diffs) {\n
this.history.push(diffs);\n
if (this.history.length > this.maxDepth)\n
this.history.shift();\n
},\n
\n
// Build chains from a set of touched nodes.\n
touchedChains: function() {\n
var self = this;\n
\n
// The temp system is a crummy hack to speed up determining\n
// whether a (currently touched) node has a line object associated\n
// with it. nullTemp is used to store the object for the first\n
// line, other nodes get it stored in their historyTemp property.\n
var nullTemp = null;\n
function temp(node) {return node ? node.historyTemp : nullTemp;}\n
function setTemp(node, line) {\n
if (node) node.historyTemp = line;\n
else nullTemp = line;\n
}\n
\n
function buildLine(node) {\n
var text = [];\n
for (var cur = node ? node.nextSibling : self.container.firstChild;\n
cur && !isBR(cur); cur = cur.nextSibling)\n
if (cur.currentText) text.push(cur.currentText);\n
return {from: node, to: cur, text: cleanText(text.join(""))};\n
}\n
\n
// Filter out unchanged lines and nodes that are no longer in the\n
// document. Build up line objects for remaining nodes.\n
var lines = [];\n
if (self.firstTouched) self.touched.push(null);\n
forEach(self.touched, function(node) {\n
if (node && node.parentNode != self.container) return;\n
\n
if (node) node.historyTouched = false;\n
else self.firstTouched = false;\n
\n
var line = buildLine(node), shadow = self.after(node);\n
if (!shadow || shadow.text != line.text || shadow.to != line.to) {\n
lines.push(line);\n
setTemp(node, line);\n
}\n
});\n
\n
// Get the BR element after/before the given node.\n
function nextBR(node, dir) {\n
var link = dir + "Sibling", search = node[link];\n
while (search && !isBR(search))\n
search = search[link];\n
return search;\n
}\n
\n
// Assemble line objects into chains by scanning the DOM tree\n
// around them.\n
var chains = []; self.touched = [];\n
forEach(lines, function(line) {\n
// Note that this makes the loop skip line objects that have\n
// been pulled into chains by lines before them.\n
if (!temp(line.from)) return;\n
\n
var chain = [], curNode = line.from, safe = true;\n
// Put any line objects (referred to by temp info) before this\n
// one on the front of the array.\n
while (true) {\n
var curLine = temp(curNode);\n
if (!curLine) {\n
if (safe) break;\n
else curLine = buildLine(curNode);\n
}\n
chain.unshift(curLine);\n
setTemp(curNode, null);\n
if (!curNode) break;\n
safe = self.after(curNode);\n
curNode = nextBR(curNode, "previous");\n
}\n
curNode = line.to; safe = self.before(line.from);\n
// Add lines after this one at end of array.\n
while (true) {\n
if (!curNode) break;\n
var curLine = temp(curNode);\n
if (!curLine) {\n
if (safe) break;\n
else curLine = buildLine(curNode);\n
}\n
chain.push(curLine);\n
setTemp(curNode, null);\n
safe = self.before(curNode);\n
curNode = nextBR(curNode, "next");\n
}\n
chains.push(chain);\n
});\n
\n
return chains;\n
},\n
\n
// Find the \'shadow\' of a given chain by following the links in the\n
// DOM nodes at its start and end.\n
shadowChain: function(chain) {\n
var shadows = [], next = this.after(chain[0].from), end = chain[chain.length - 1].to;\n
while (true) {\n
shadows.push(next);\n
var nextNode = next.to;\n
if (!nextNode || nextNode == end)\n
break;\n
else\n
next = nextNode.historyAfter || this.before(end);\n
// (The this.before(end) is a hack -- FF sometimes removes\n
// properties from BR nodes, in which case the best we can hope\n
// for is to not break.)\n
}\n
return shadows;\n
},\n
\n
// Update the DOM tree to contain the lines specified in a given\n
// chain, link this chain into the DOM nodes.\n
applyChain: function(chain) {\n
// Some attempt is made to prevent the cursor from jumping\n
// randomly when an undo or redo happens. It still behaves a bit\n
// strange sometimes.\n
var cursor = select.cursorPos(this.container, false), self = this;\n
\n
// Remove all nodes in the DOM tree between from and to (null for\n
// start/end of container).\n
function removeRange(from, to) {\n
var pos = from ? from.nextSibling : self.container.firstChild;\n
while (pos != to) {\n
var temp = pos.nextSibling;\n
removeElement(pos);\n
pos = temp;\n
}\n
}\n
\n
var start = chain[0].from, end = chain[chain.length - 1].to;\n
// Clear the space where this change has to be made.\n
removeRange(start, end);\n
\n
// Insert the content specified by the chain into the DOM tree.\n
for (var i = 0; i < chain.length; i++) {\n
var line = chain[i];\n
// The start and end of the space are already correct, but BR\n
// tags inside it have to be put back.\n
if (i > 0)\n
self.container.insertBefore(line.from, end);\n
\n
// Add the text.\n
var node = makePartSpan(fixSpaces(line.text));\n
self.container.insertBefore(node, end);\n
// See if the cursor was on this line. Put it back, adjusting\n
// for changed line length, if it was.\n
if (cursor && cursor.node == line.from) {\n
var cursordiff = 0;\n
var prev = this.after(line.from);\n
if (prev && i == chain.length - 1) {\n
// Only adjust if the cursor is after the unchanged part of\n
// the line.\n
for (var match = 0; match < cursor.offset &&\n
line.text.charAt(match) == prev.text.charAt(match); match++){}\n
if (cursor.offset > match)\n
cursordiff = line.text.length - prev.text.length;\n
}\n
select.setCursorPos(this.container, {node: line.from, offset: Math.max(0, cursor.offset + cursordiff)});\n
}\n
// Cursor was in removed line, this is last new line.\n
else if (cursor && (i == chain.length - 1) && cursor.node && cursor.node.parentNode != this.container) {\n
select.setCursorPos(this.container, {node: line.from, offset: line.text.length});\n
}\n
}\n
\n
// Anchor the chain in the DOM tree.\n
this.linkChain(chain);\n
return start;\n
}\n
};\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>14379</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>util.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/* A few useful utility functions. */\n
\n
// Capture a method on an object.\n
function method(obj, name) {\n
return function() {obj[name].apply(obj, arguments);};\n
}\n
\n
// The value used to signal the end of a sequence in iterators.\n
var StopIteration = {toString: function() {return "StopIteration"}};\n
\n
// Apply a function to each element in a sequence.\n
function forEach(iter, f) {\n
if (iter.next) {\n
try {while (true) f(iter.next());}\n
catch (e) {if (e != StopIteration) throw e;}\n
}\n
else {\n
for (var i = 0; i < iter.length; i++)\n
f(iter[i]);\n
}\n
}\n
\n
// Map a function over a sequence, producing an array of results.\n
function map(iter, f) {\n
var accum = [];\n
forEach(iter, function(val) {accum.push(f(val));});\n
return accum;\n
}\n
\n
// Create a predicate function that tests a string againsts a given\n
// regular expression. No longer used but might be used by 3rd party\n
// parsers.\n
function matcher(regexp){\n
return function(value){return regexp.test(value);};\n
}\n
\n
// Test whether a DOM node has a certain CSS class. Much faster than\n
// the MochiKit equivalent, for some reason.\n
function hasClass(element, className){\n
var classes = element.className;\n
return classes && new RegExp("(^| )" + className + "($| )").test(classes);\n
}\n
\n
// Insert a DOM node after another node.\n
function insertAfter(newNode, oldNode) {\n
var parent = oldNode.parentNode;\n
parent.insertBefore(newNode, oldNode.nextSibling);\n
return newNode;\n
}\n
\n
function removeElement(node) {\n
if (node.parentNode)\n
node.parentNode.removeChild(node);\n
}\n
\n
function clearElement(node) {\n
while (node.firstChild)\n
node.removeChild(node.firstChild);\n
}\n
\n
// Check whether a node is contained in another one.\n
function isAncestor(node, child) {\n
while (child = child.parentNode) {\n
if (node == child)\n
return true;\n
}\n
return false;\n
}\n
\n
// The non-breaking space character.\n
var nbsp = "\\u00a0";\n
var matching = {"{": "}", "[": "]", "(": ")",\n
"}": "{", "]": "[", ")": "("};\n
\n
// Standardize a few unportable event properties.\n
function normalizeEvent(event) {\n
if (!event.stopPropagation) {\n
event.stopPropagation = function() {this.cancelBubble = true;};\n
event.preventDefault = function() {this.returnValue = false;};\n
}\n
if (!event.stop) {\n
event.stop = function() {\n
this.stopPropagation();\n
this.preventDefault();\n
};\n
}\n
\n
if (event.type == "keypress") {\n
event.code = (event.charCode == null) ? event.keyCode : event.charCode;\n
event.character = String.fromCharCode(event.code);\n
}\n
return event;\n
}\n
\n
// Portably register event handlers.\n
function addEventHandler(node, type, handler, removeFunc) {\n
function wrapHandler(event) {\n
handler(normalizeEvent(event || window.event));\n
}\n
if (typeof node.addEventListener == "function") {\n
node.addEventListener(type, wrapHandler, false);\n
if (removeFunc) return function() {node.removeEventListener(type, wrapHandler, false);};\n
}\n
else {\n
node.attachEvent("on" + type, wrapHandler);\n
if (removeFunc) return function() {node.detachEvent("on" + type, wrapHandler);};\n
}\n
}\n
\n
function nodeText(node) {\n
return node.textContent || node.innerText || node.nodeValue || "";\n
}\n
\n
function nodeTop(node) {\n
var top = 0;\n
while (node.offsetParent) {\n
top += node.offsetTop;\n
node = node.offsetParent;\n
}\n
return top;\n
}\n
\n
function isBR(node) {\n
var nn = node.nodeName;\n
return nn == "BR" || nn == "br";\n
}\n
function isSpan(node) {\n
var nn = node.nodeName;\n
return nn == "SPAN" || nn == "span";\n
}\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>3491</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts87948228.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>unittests.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>/**\n
* Test Harness for CodeMirror\n
* JS-unit compatible tests here. The two available assertions are\n
* assertEquals (strict equality) and assertEquivalent (looser equivalency).\n
*\n
* \'editor\' is a global object for the CodeMirror editor shared between all\n
* tests. After manipulating it in each test, try to restore it to\n
* approximately its original state.\n
*/\n
\n
function testSetGet() {\n
var code = \'It was the best of times.\\nIt was the worst of times.\';\n
editor.setCode(code);\n
assertEquals(code, editor.getCode());\n
editor.setCode(\'\');\n
assertEquals(\'\', editor.getCode());\n
}\n
\n
function testSetStylesheet() {\n
function cssStatus() {\n
// Returns a list of tuples, for each CSS link return the filename and\n
// whether it is enabled.\n
links = editor.win.document.getElementsByTagName(\'link\');\n
css = [];\n
for (var x = 0, link; link = links[x]; x++) {\n
if (link.rel.indexOf("stylesheet") !== -1) {\n
css.push([link.href.substring(link.href.lastIndexOf(\'/\') + 1),\n
!link.disabled])\n
}\n
}\n
return css;\n
}\n
assertEquivalent([], cssStatus());\n
editor.setStylesheet(\'css/jscolors.css\');\n
assertEquivalent([[\'jscolors.css\', true]], cssStatus());\n
editor.setStylesheet([\'css/csscolors.css\', \'css/xmlcolors.css\']);\n
assertEquivalent([[\'jscolors.css\', false], [\'csscolors.css\', true], [\'xmlcolors.css\', true]], cssStatus());\n
editor.setStylesheet([]);\n
assertEquivalent([[\'jscolors.css\', false], [\'csscolors.css\', false], [\'xmlcolors.css\', false]], cssStatus());\n
}\n
\n
// Update this list of tests as new ones are added.\n
var tests = [\'testSetGet\', \'testSetStylesheet\'];\n
\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1630</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2011-01-13 Seb
* Initial creation
\ No newline at end of file
Copyright (c) 2011 Nexedi SA
\ No newline at end of file
erp5_view_style
\ No newline at end of file
This Business Template contains CodeMirror code.
zlib-style License
\ No newline at end of file
seb
\ No newline at end of file
1
\ No newline at end of file
erp5_code_mirror
\ No newline at end of file
erp5_code_mirror
\ No newline at end of file
5.4.7
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment