From eaa8ccaccb1091820d0a8d1223996a6dd057347d Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 17 Jan 2016 14:28:04 -0600 Subject: Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor --- public/vendor/codemirror/mode/haxe/haxe.js | 165 +++++++++++++------------- public/vendor/codemirror/mode/haxe/index.html | 0 2 files changed, 81 insertions(+), 84 deletions(-) mode change 100755 => 100644 public/vendor/codemirror/mode/haxe/haxe.js mode change 100755 => 100644 public/vendor/codemirror/mode/haxe/index.html (limited to 'public/vendor/codemirror/mode/haxe') diff --git a/public/vendor/codemirror/mode/haxe/haxe.js b/public/vendor/codemirror/mode/haxe/haxe.js old mode 100755 new mode 100644 index d49ad70f..a9573dd7 --- a/public/vendor/codemirror/mode/haxe/haxe.js +++ b/public/vendor/codemirror/mode/haxe/haxe.js @@ -16,23 +16,21 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { // Tokenizer - var keywords = function(){ - function kw(type) {return {type: type, style: "keyword"};} - var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); - var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"}; + function kw(type) {return {type: type, style: "keyword"};} + var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); + var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"}; var type = kw("typedef"); - return { - "if": A, "while": A, "else": B, "do": B, "try": B, - "return": C, "break": C, "continue": C, "new": C, "throw": C, - "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"), + var keywords = { + "if": A, "while": A, "else": B, "do": B, "try": B, + "return": C, "break": C, "continue": C, "new": C, "throw": C, + "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"), "public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"), - "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"), - "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), - "in": operator, "never": kw("property_access"), "trace":kw("trace"), + "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"), + "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), + "in": operator, "never": kw("property_access"), "trace":kw("trace"), "class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type, - "true": atom, "false": atom, "null": atom - }; - }(); + "true": atom, "false": atom, "null": atom + }; var isOperatorChar = /[+\-*&%=<>!?|]/; @@ -41,14 +39,13 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { return f(stream, state); } - function nextUntilUnescaped(stream, end) { + function toUnescaped(stream, end) { var escaped = false, next; while ((next = stream.next()) != null) { if (next == end && !escaped) - return false; + return true; escaped = !escaped && next == "\\"; } - return escaped; } // Used as scratch variables to communicate multiple values without @@ -61,70 +58,58 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { function haxeTokenBase(stream, state) { var ch = stream.next(); - if (ch == '"' || ch == "'") + if (ch == '"' || ch == "'") { return chain(stream, state, haxeTokenString(ch)); - else if (/[\[\]{}\(\),;\:\.]/.test(ch)) + } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) { return ret(ch); - else if (ch == "0" && stream.eat(/x/i)) { + } else if (ch == "0" && stream.eat(/x/i)) { stream.eatWhile(/[\da-f]/i); return ret("number", "number"); - } - else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { - stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); + } else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { + stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/); return ret("number", "number"); - } - else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) { - nextUntilUnescaped(stream, "/"); + } else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) { + toUnescaped(stream, "/"); stream.eatWhile(/[gimsu]/); return ret("regexp", "string-2"); - } - else if (ch == "/") { + } else if (ch == "/") { if (stream.eat("*")) { return chain(stream, state, haxeTokenComment); - } - else if (stream.eat("/")) { + } else if (stream.eat("/")) { stream.skipToEnd(); return ret("comment", "comment"); - } - else { + } else { stream.eatWhile(isOperatorChar); return ret("operator", null, stream.current()); } - } - else if (ch == "#") { + } else if (ch == "#") { stream.skipToEnd(); return ret("conditional", "meta"); - } - else if (ch == "@") { + } else if (ch == "@") { stream.eat(/:/); stream.eatWhile(/[\w_]/); return ret ("metadata", "meta"); - } - else if (isOperatorChar.test(ch)) { + } else if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); return ret("operator", null, stream.current()); - } - else { - var word; - if(/[A-Z]/.test(ch)) - { - stream.eatWhile(/[\w_<>]/); - word = stream.current(); - return ret("type", "variable-3", word); - } - else - { + } else { + var word; + if(/[A-Z]/.test(ch)) { + stream.eatWhile(/[\w_<>]/); + word = stream.current(); + return ret("type", "variable-3", word); + } else { stream.eatWhile(/[\w_]/); var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; return (known && state.kwAllowed) ? ret(known.type, known.style, word) : ret("variable", "variable", word); - } + } } } function haxeTokenString(quote) { return function(stream, state) { - if (!nextUntilUnescaped(stream, quote)) + if (toUnescaped(stream, quote)) state.tokenize = haxeTokenBase; return ret("string", "string"); }; @@ -176,27 +161,25 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { cc.pop()(); if (cx.marked) return cx.marked; if (type == "variable" && inScope(state, content)) return "variable-2"; - if (type == "variable" && imported(state, content)) return "variable-3"; + if (type == "variable" && imported(state, content)) return "variable-3"; return style; } } } - function imported(state, typename) - { - if (/[a-z]/.test(typename.charAt(0))) - return false; - var len = state.importedtypes.length; - for (var i = 0; i