From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 27 Jan 2012 12:05:17 -0800 Subject: Merged old FileIO --- imports/codemirror/mode/clike/clike.js | 249 +++++++ imports/codemirror/mode/clike/index.html | 101 +++ imports/codemirror/mode/clojure/clojure.js | 207 ++++++ imports/codemirror/mode/clojure/index.html | 66 ++ imports/codemirror/mode/coffeescript/LICENSE | 22 + .../codemirror/mode/coffeescript/coffeescript.js | 325 ++++++++ imports/codemirror/mode/coffeescript/index.html | 721 ++++++++++++++++++ imports/codemirror/mode/css/css.js | 124 ++++ imports/codemirror/mode/css/index.html | 55 ++ imports/codemirror/mode/diff/diff.css | 3 + imports/codemirror/mode/diff/diff.js | 13 + imports/codemirror/mode/diff/index.html | 99 +++ imports/codemirror/mode/gfm/gfm.js | 108 +++ imports/codemirror/mode/gfm/index.html | 47 ++ imports/codemirror/mode/groovy/groovy.js | 210 ++++++ imports/codemirror/mode/groovy/index.html | 71 ++ imports/codemirror/mode/haskell/haskell.js | 242 ++++++ imports/codemirror/mode/haskell/index.html | 60 ++ .../codemirror/mode/htmlembedded/htmlembedded.js | 68 ++ imports/codemirror/mode/htmlembedded/index.html | 49 ++ imports/codemirror/mode/htmlmixed/htmlmixed.js | 83 +++ imports/codemirror/mode/htmlmixed/index.html | 51 ++ imports/codemirror/mode/javascript/index.html | 77 ++ imports/codemirror/mode/javascript/javascript.js | 360 +++++++++ imports/codemirror/mode/jinja2/index.html | 37 + imports/codemirror/mode/jinja2/jinja2.js | 42 ++ imports/codemirror/mode/lua/index.html | 72 ++ imports/codemirror/mode/lua/lua.js | 140 ++++ imports/codemirror/mode/markdown/index.html | 339 +++++++++ imports/codemirror/mode/markdown/markdown.js | 242 ++++++ imports/codemirror/mode/ntriples/index.html | 32 + imports/codemirror/mode/ntriples/ntriples.js | 172 +++++ imports/codemirror/mode/pascal/LICENSE | 7 + imports/codemirror/mode/pascal/index.html | 48 ++ imports/codemirror/mode/pascal/pascal.js | 138 ++++ imports/codemirror/mode/perl/LICENSE | 19 + imports/codemirror/mode/perl/index.html | 62 ++ imports/codemirror/mode/perl/perl.js | 816 +++++++++++++++++++++ imports/codemirror/mode/php/index.html | 48 ++ imports/codemirror/mode/php/php.js | 120 +++ imports/codemirror/mode/plsql/index.html | 62 ++ imports/codemirror/mode/plsql/plsql.js | 217 ++++++ imports/codemirror/mode/python/LICENSE.txt | 21 + imports/codemirror/mode/python/index.html | 122 +++ imports/codemirror/mode/python/python.js | 333 +++++++++ imports/codemirror/mode/r/LICENSE | 24 + imports/codemirror/mode/r/index.html | 73 ++ imports/codemirror/mode/r/r.js | 141 ++++ imports/codemirror/mode/rpm/changes/changes.js | 19 + imports/codemirror/mode/rpm/changes/index.html | 53 ++ imports/codemirror/mode/rpm/spec/index.html | 99 +++ imports/codemirror/mode/rpm/spec/spec.css | 5 + imports/codemirror/mode/rpm/spec/spec.js | 66 ++ imports/codemirror/mode/rst/index.html | 525 +++++++++++++ imports/codemirror/mode/rst/rst.js | 326 ++++++++ imports/codemirror/mode/ruby/LICENSE | 24 + imports/codemirror/mode/ruby/index.html | 171 +++++ imports/codemirror/mode/ruby/ruby.js | 195 +++++ imports/codemirror/mode/rust/index.html | 48 ++ imports/codemirror/mode/rust/rust.js | 411 +++++++++++ imports/codemirror/mode/scheme/index.html | 64 ++ imports/codemirror/mode/scheme/scheme.js | 202 +++++ imports/codemirror/mode/smalltalk/index.html | 55 ++ imports/codemirror/mode/smalltalk/smalltalk.js | 139 ++++ imports/codemirror/mode/sparql/index.html | 40 + imports/codemirror/mode/sparql/sparql.js | 143 ++++ imports/codemirror/mode/stex/index.html | 95 +++ imports/codemirror/mode/stex/stex.js | 167 +++++ imports/codemirror/mode/tiddlywiki/index.html | 183 +++++ imports/codemirror/mode/tiddlywiki/tiddlywiki.css | 21 + imports/codemirror/mode/tiddlywiki/tiddlywiki.js | 374 ++++++++++ imports/codemirror/mode/velocity/index.html | 103 +++ imports/codemirror/mode/velocity/velocity.js | 146 ++++ imports/codemirror/mode/xml/index.html | 44 ++ imports/codemirror/mode/xml/xml.js | 252 +++++++ imports/codemirror/mode/xmlpure/index.html | 59 ++ imports/codemirror/mode/xmlpure/xmlpure.js | 485 ++++++++++++ imports/codemirror/mode/yaml/index.html | 67 ++ imports/codemirror/mode/yaml/yaml.js | 95 +++ 79 files changed, 11414 insertions(+) create mode 100755 imports/codemirror/mode/clike/clike.js create mode 100755 imports/codemirror/mode/clike/index.html create mode 100755 imports/codemirror/mode/clojure/clojure.js create mode 100755 imports/codemirror/mode/clojure/index.html create mode 100755 imports/codemirror/mode/coffeescript/LICENSE create mode 100755 imports/codemirror/mode/coffeescript/coffeescript.js create mode 100755 imports/codemirror/mode/coffeescript/index.html create mode 100755 imports/codemirror/mode/css/css.js create mode 100755 imports/codemirror/mode/css/index.html create mode 100755 imports/codemirror/mode/diff/diff.css create mode 100755 imports/codemirror/mode/diff/diff.js create mode 100755 imports/codemirror/mode/diff/index.html create mode 100755 imports/codemirror/mode/gfm/gfm.js create mode 100755 imports/codemirror/mode/gfm/index.html create mode 100755 imports/codemirror/mode/groovy/groovy.js create mode 100755 imports/codemirror/mode/groovy/index.html create mode 100755 imports/codemirror/mode/haskell/haskell.js create mode 100755 imports/codemirror/mode/haskell/index.html create mode 100755 imports/codemirror/mode/htmlembedded/htmlembedded.js create mode 100755 imports/codemirror/mode/htmlembedded/index.html create mode 100755 imports/codemirror/mode/htmlmixed/htmlmixed.js create mode 100755 imports/codemirror/mode/htmlmixed/index.html create mode 100755 imports/codemirror/mode/javascript/index.html create mode 100755 imports/codemirror/mode/javascript/javascript.js create mode 100755 imports/codemirror/mode/jinja2/index.html create mode 100755 imports/codemirror/mode/jinja2/jinja2.js create mode 100755 imports/codemirror/mode/lua/index.html create mode 100755 imports/codemirror/mode/lua/lua.js create mode 100755 imports/codemirror/mode/markdown/index.html create mode 100755 imports/codemirror/mode/markdown/markdown.js create mode 100755 imports/codemirror/mode/ntriples/index.html create mode 100755 imports/codemirror/mode/ntriples/ntriples.js create mode 100755 imports/codemirror/mode/pascal/LICENSE create mode 100755 imports/codemirror/mode/pascal/index.html create mode 100755 imports/codemirror/mode/pascal/pascal.js create mode 100755 imports/codemirror/mode/perl/LICENSE create mode 100755 imports/codemirror/mode/perl/index.html create mode 100755 imports/codemirror/mode/perl/perl.js create mode 100755 imports/codemirror/mode/php/index.html create mode 100755 imports/codemirror/mode/php/php.js create mode 100755 imports/codemirror/mode/plsql/index.html create mode 100755 imports/codemirror/mode/plsql/plsql.js create mode 100755 imports/codemirror/mode/python/LICENSE.txt create mode 100755 imports/codemirror/mode/python/index.html create mode 100755 imports/codemirror/mode/python/python.js create mode 100755 imports/codemirror/mode/r/LICENSE create mode 100755 imports/codemirror/mode/r/index.html create mode 100755 imports/codemirror/mode/r/r.js create mode 100755 imports/codemirror/mode/rpm/changes/changes.js create mode 100755 imports/codemirror/mode/rpm/changes/index.html create mode 100755 imports/codemirror/mode/rpm/spec/index.html create mode 100755 imports/codemirror/mode/rpm/spec/spec.css create mode 100755 imports/codemirror/mode/rpm/spec/spec.js create mode 100755 imports/codemirror/mode/rst/index.html create mode 100755 imports/codemirror/mode/rst/rst.js create mode 100755 imports/codemirror/mode/ruby/LICENSE create mode 100755 imports/codemirror/mode/ruby/index.html create mode 100755 imports/codemirror/mode/ruby/ruby.js create mode 100755 imports/codemirror/mode/rust/index.html create mode 100755 imports/codemirror/mode/rust/rust.js create mode 100755 imports/codemirror/mode/scheme/index.html create mode 100755 imports/codemirror/mode/scheme/scheme.js create mode 100755 imports/codemirror/mode/smalltalk/index.html create mode 100755 imports/codemirror/mode/smalltalk/smalltalk.js create mode 100755 imports/codemirror/mode/sparql/index.html create mode 100755 imports/codemirror/mode/sparql/sparql.js create mode 100755 imports/codemirror/mode/stex/index.html create mode 100755 imports/codemirror/mode/stex/stex.js create mode 100755 imports/codemirror/mode/tiddlywiki/index.html create mode 100755 imports/codemirror/mode/tiddlywiki/tiddlywiki.css create mode 100755 imports/codemirror/mode/tiddlywiki/tiddlywiki.js create mode 100755 imports/codemirror/mode/velocity/index.html create mode 100755 imports/codemirror/mode/velocity/velocity.js create mode 100755 imports/codemirror/mode/xml/index.html create mode 100755 imports/codemirror/mode/xml/xml.js create mode 100755 imports/codemirror/mode/xmlpure/index.html create mode 100755 imports/codemirror/mode/xmlpure/xmlpure.js create mode 100755 imports/codemirror/mode/yaml/index.html create mode 100755 imports/codemirror/mode/yaml/yaml.js (limited to 'imports/codemirror/mode') diff --git a/imports/codemirror/mode/clike/clike.js b/imports/codemirror/mode/clike/clike.js new file mode 100755 index 00000000..69877efd --- /dev/null +++ b/imports/codemirror/mode/clike/clike.js @@ -0,0 +1,249 @@ +CodeMirror.defineMode("clike", function(config, parserConfig) { + var indentUnit = config.indentUnit, + keywords = parserConfig.keywords || {}, + blockKeywords = parserConfig.blockKeywords || {}, + atoms = parserConfig.atoms || {}, + hooks = parserConfig.hooks || {}, + multiLineStrings = parserConfig.multiLineStrings; + var isOperatorChar = /[+\-*&%=<>!?|\/]/; + + var curPunc; + + function tokenBase(stream, state) { + var ch = stream.next(); + if (hooks[ch]) { + var result = hooks[ch](stream, state); + if (result !== false) return result; + } + if (ch == '"' || ch == "'") { + state.tokenize = tokenString(ch); + return state.tokenize(stream, state); + } + if (/[\[\]{}\(\),;\:\.]/.test(ch)) { + curPunc = ch; + return null + } + if (/\d/.test(ch)) { + stream.eatWhile(/[\w\.]/); + return "number"; + } + if (ch == "/") { + if (stream.eat("*")) { + state.tokenize = tokenComment; + return tokenComment(stream, state); + } + if (stream.eat("/")) { + stream.skipToEnd(); + return "comment"; + } + } + if (isOperatorChar.test(ch)) { + stream.eatWhile(isOperatorChar); + return "operator"; + } + stream.eatWhile(/[\w\$_]/); + var cur = stream.current(); + if (keywords.propertyIsEnumerable(cur)) { + if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; + return "keyword"; + } + if (atoms.propertyIsEnumerable(cur)) return "atom"; + return "word"; + } + + function tokenString(quote) { + return function(stream, state) { + var escaped = false, next, end = false; + while ((next = stream.next()) != null) { + if (next == quote && !escaped) {end = true; break;} + escaped = !escaped && next == "\\"; + } + if (end || !(escaped || multiLineStrings)) + state.tokenize = tokenBase; + return "string"; + }; + } + + function tokenComment(stream, state) { + var maybeEnd = false, ch; + while (ch = stream.next()) { + if (ch == "/" && maybeEnd) { + state.tokenize = tokenBase; + break; + } + maybeEnd = (ch == "*"); + } + return "comment"; + } + + function Context(indented, column, type, align, prev) { + this.indented = indented; + this.column = column; + this.type = type; + this.align = align; + this.prev = prev; + } + function pushContext(state, col, type) { + return state.context = new Context(state.indented, col, type, null, state.context); + } + function popContext(state) { + var t = state.context.type; + if (t == ")" || t == "]" || t == "}") + state.indented = state.context.indented; + return state.context = state.context.prev; + } + + // Interface + + return { + startState: function(basecolumn) { + return { + tokenize: null, + context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), + indented: 0, + startOfLine: true + }; + }, + + token: function(stream, state) { + var ctx = state.context; + if (stream.sol()) { + if (ctx.align == null) ctx.align = false; + state.indented = stream.indentation(); + state.startOfLine = true; + } + if (stream.eatSpace()) return null; + curPunc = null; + var style = (state.tokenize || tokenBase)(stream, state); + if (style == "comment" || style == "meta") return style; + if (ctx.align == null) ctx.align = true; + + if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state); + else if (curPunc == "{") pushContext(state, stream.column(), "}"); + else if (curPunc == "[") pushContext(state, stream.column(), "]"); + else if (curPunc == "(") pushContext(state, stream.column(), ")"); + else if (curPunc == "}") { + while (ctx.type == "statement") ctx = popContext(state); + if (ctx.type == "}") ctx = popContext(state); + while (ctx.type == "statement") ctx = popContext(state); + } + else if (curPunc == ctx.type) popContext(state); + else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement")) + pushContext(state, stream.column(), "statement"); + state.startOfLine = false; + return style; + }, + + indent: function(state, textAfter) { + if (state.tokenize != tokenBase && state.tokenize != null) return 0; + var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); + if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; + var closing = firstChar == ctx.type; + if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit); + else if (ctx.align) return ctx.column + (closing ? 0 : 1); + else return ctx.indented + (closing ? 0 : indentUnit); + }, + + electricChars: "{}" + }; +}); + +(function() { + function words(str) { + var obj = {}, words = str.split(" "); + for (var i = 0; i < words.length; ++i) obj[words[i]] = true; + return obj; + } + var cKeywords = "auto if break int case long char register continue return default short do sizeof " + + "double static else struct entry switch extern typedef float union for unsigned " + + "goto while enum void const signed volatile"; + + function cppHook(stream, state) { + if (!state.startOfLine) return false; + stream.skipToEnd(); + return "meta"; + } + + // C#-style strings where "" escapes a quote. + function tokenAtString(stream, state) { + var next; + while ((next = stream.next()) != null) { + if (next == '"' && !stream.eat('"')) { + state.tokenize = null; + break; + } + } + return "string"; + } + + CodeMirror.defineMIME("text/x-csrc", { + name: "clike", + keywords: words(cKeywords), + blockKeywords: words("case do else for if switch while struct"), + atoms: words("null"), + hooks: {"#": cppHook} + }); + CodeMirror.defineMIME("text/x-c++src", { + name: "clike", + keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " + + "static_cast typeid catch operator template typename class friend private " + + "this using const_cast inline public throw virtual delete mutable protected " + + "wchar_t"), + blockKeywords: words("catch class do else finally for if struct switch try while"), + atoms: words("true false null"), + hooks: {"#": cppHook} + }); + CodeMirror.defineMIME("text/x-java", { + name: "clike", + keywords: words("abstract assert boolean break byte case catch char class const continue default " + + "do double else enum extends final finally float for goto if implements import " + + "instanceof int interface long native new package private protected public " + + "return short static strictfp super switch synchronized this throw throws transient " + + "try void volatile while"), + blockKeywords: words("catch class do else finally for if switch try while"), + atoms: words("true false null"), + hooks: { + "@": function(stream, state) { + stream.eatWhile(/[\w\$_]/); + return "meta"; + } + } + }); + CodeMirror.defineMIME("text/x-csharp", { + name: "clike", + keywords: words("abstract as base bool break byte case catch char checked class const continue decimal" + + " default delegate do double else enum event explicit extern finally fixed float for" + + " foreach goto if implicit in int interface internal is lock long namespace new object" + + " operator out override params private protected public readonly ref return sbyte sealed short" + + " sizeof stackalloc static string struct switch this throw try typeof uint ulong unchecked" + + " unsafe ushort using virtual void volatile while add alias ascending descending dynamic from get" + + " global group into join let orderby partial remove select set value var yield"), + blockKeywords: words("catch class do else finally for foreach if struct switch try while"), + atoms: words("true false null"), + hooks: { + "@": function(stream, state) { + if (stream.eat('"')) { + state.tokenize = tokenAtString; + return tokenAtString(stream, state); + } + stream.eatWhile(/[\w\$_]/); + return "meta"; + } + } + }); + CodeMirror.defineMIME("text/x-groovy", { + name: "clike", + keywords: words("abstract as assert boolean break byte case catch char class const continue def default " + + "do double else enum extends final finally float for goto if implements import " + + "in instanceof int interface long native new package property private protected public " + + "return short static strictfp super switch synchronized this throw throws transient " + + "try void volatile while"), + atoms: words("true false null"), + hooks: { + "@": function(stream, state) { + stream.eatWhile(/[\w\$_]/); + return "meta"; + } + } + }); +}()); diff --git a/imports/codemirror/mode/clike/index.html b/imports/codemirror/mode/clike/index.html new file mode 100755 index 00000000..5e375ef4 --- /dev/null +++ b/imports/codemirror/mode/clike/index.html @@ -0,0 +1,101 @@ + + + + CodeMirror: C-like mode + + + + + + + +

CodeMirror: C-like mode

+ +
+ + + +

Simple mode that tries to handle C-like languages as well as it + can. Takes two configuration parameters: keywords, an + object whose property names are the keywords in the language, + and useCPP, which determines whether C preprocessor + directives are recognized.

+ +

MIME types defined: text/x-csrc + (C code), text/x-c++src (C++ + code), text/x-java (Java + code), text/x-groovy (Groovy code).

+ + diff --git a/imports/codemirror/mode/clojure/clojure.js b/imports/codemirror/mode/clojure/clojure.js new file mode 100755 index 00000000..a951589e --- /dev/null +++ b/imports/codemirror/mode/clojure/clojure.js @@ -0,0 +1,207 @@ +/** + * Author: Hans Engel + * Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun) + */ +CodeMirror.defineMode("clojure", function (config, mode) { + var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", TAG = "tag", + ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword"; + var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1; + + function makeKeywords(str) { + var obj = {}, words = str.split(" "); + for (var i = 0; i < words.length; ++i) obj[words[i]] = true; + return obj; + } + + var atoms = makeKeywords("true false nil"); + + var keywords = makeKeywords( + // Control structures + "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle" + + + // Built-ins + "* *1 *2 *3 *agent* *allow-unresolved-vars* *assert *clojure-version* *command-line-args* *compile-files* *compile-path* *e *err* *file* *flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *use-context-classloader* *warn-on-reflection* + - / < <= = == > >= accessor aclone agent agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* butlast byte byte-array bytes case cast char char-array char-escape-string char-name-string char? chars chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement concat cond condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec decimal? declare definline defmacro defmethod defmulti defn defn- defonce defstruct delay delay? deliver deref derive descendants destructure disj disj! dissoc dissoc! distinct distinct? doall doc dorun doseq dosync dotimes doto double double-array doubles drop drop-last drop-while empty empty? ensure enumeration-seq eval even? every? extend extend-protocol extend-type extends? extenders false? ffirst file-seq filter find find-doc find-ns find-var first float float-array float? floats flush fn fn? fnext for force format future future-call future-cancel future-cancelled? future-done? future? gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator hash hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc init-proxy instance? int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy map map? mapcat max max-key memfn memoize merge merge-with meta method-sig methods min min-key mod name namespace neg? newline next nfirst nil? nnext not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? or parents partial partition pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers primitives-classnames print print-ctor print-doc print-dup print-method print-namespace-doc print-simple print-special-doc print-str printf println println-str prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot rand rand-int range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string reify reduce ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure release-pending-sends rem remove remove-method remove-ns repeat repeatedly replace replicate require reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? seque sequence sequential? set set-validator! set? short short-array shorts shutdown-agents slurp some sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-form-anchor special-symbol? split-at split-with str stream? string? struct struct-map subs subseq subvec supers swap! symbol symbol? sync syntax-symbol-anchor take take-last take-nth take-while test the-ns time to-array to-array-2d trampoline transient tree-seq true? type unchecked-add unchecked-dec unchecked-divide unchecked-inc unchecked-multiply unchecked-negate unchecked-remainder unchecked-subtract underive unquote unquote-splicing update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector? when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision xml-seq"); + + var indentKeys = makeKeywords( + // Built-ins + "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch" + + + // Binding forms + "let letfn binding loop for doseq dotimes when-let if-let" + + + // Data structures + "defstruct struct-map assoc" + + + // clojure.test + "testing deftest" + + + // contrib + "handler-case handle dotrace deftrace"); + + var tests = { + digit: /\d/, + digit_or_colon: /[\d:]/, + hex: /[0-9a-fA-F]/, + sign: /[+-]/, + exponent: /[eE]/, + keyword_char: /[^\s\(\[\;\)\]]/, + basic: /[\w\$_\-]/, + lang_keyword: /[\w*+!\-_?:\/]/ + }; + + function stateStack(indent, type, prev) { // represents a state stack object + this.indent = indent; + this.type = type; + this.prev = prev; + } + + function pushStack(state, indent, type) { + state.indentStack = new stateStack(indent, type, state.indentStack); + } + + function popStack(state) { + state.indentStack = state.indentStack.prev; + } + + function isNumber(ch, stream){ + // hex + if ( ch === '0' && 'x' == stream.peek().toLowerCase() ) { + stream.eat('x'); + stream.eatWhile(tests.hex); + return true; + } + + // leading sign + if ( ch == '+' || ch == '-' ) { + stream.eat(tests.sign); + ch = stream.next(); + } + + if ( tests.digit.test(ch) ) { + stream.eat(ch); + stream.eatWhile(tests.digit); + + if ( '.' == stream.peek() ) { + stream.eat('.'); + stream.eatWhile(tests.digit); + } + + if ( 'e' == stream.peek().toLowerCase() ) { + stream.eat(tests.exponent); + stream.eat(tests.sign); + stream.eatWhile(tests.digit); + } + + return true; + } + + return false; + } + + return { + startState: function () { + return { + indentStack: null, + indentation: 0, + mode: false, + }; + }, + + token: function (stream, state) { + if (state.indentStack == null && stream.sol()) { + // update indentation, but only if indentStack is empty + state.indentation = stream.indentation(); + } + + // skip spaces + if (stream.eatSpace()) { + return null; + } + var returnType = null; + + switch(state.mode){ + case "string": // multi-line string parsing mode + var next, escaped = false; + while ((next = stream.next()) != null) { + if (next == "\"" && !escaped) { + + state.mode = false; + break; + } + escaped = !escaped && next == "\\"; + } + returnType = STRING; // continue on in string mode + break; + default: // default parsing mode + var ch = stream.next(); + + if (ch == "\"") { + state.mode = "string"; + returnType = STRING; + } else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) { + returnType = ATOM; + } else if (ch == ";") { // comment + stream.skipToEnd(); // rest of the line is a comment + returnType = COMMENT; + } else if (isNumber(ch,stream)){ + returnType = NUMBER; + } else if (ch == "(" || ch == "[") { + var keyWord = ''; var indentTemp = stream.column(); + /** + Either + (indent-word .. + (non-indent-word .. + (;something else, bracket, etc. + */ + + while ((letter = stream.eat(tests.keyword_char)) != null) { + keyWord += letter; + } + + if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word + + pushStack(state, indentTemp + INDENT_WORD_SKIP, ch); + } else { // non-indent word + // we continue eating the spaces + stream.eatSpace(); + if (stream.eol() || stream.peek() == ";") { + // nothing significant after + // we restart indentation 1 space after + pushStack(state, indentTemp + 1, ch); + } else { + pushStack(state, indentTemp + stream.current().length, ch); // else we match + } + } + stream.backUp(stream.current().length - 1); // undo all the eating + + returnType = BRACKET; + } else if (ch == ")" || ch == "]") { + returnType = BRACKET; + if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) { + popStack(state); + } + } else if ( ch == ":" ) { + stream.eatWhile(tests.lang_keyword); + return TAG; + } else { + stream.eatWhile(tests.basic); + + if (keywords && keywords.propertyIsEnumerable(stream.current())) { + returnType = BUILTIN; + } else if ( atoms && atoms.propertyIsEnumerable(stream.current()) ) { + returnType = ATOM; + } else returnType = null; + } + } + + return returnType; + }, + + indent: function (state, textAfter) { + if (state.indentStack == null) return state.indentation; + return state.indentStack.indent; + } + }; +}); + +CodeMirror.defineMIME("text/x-clojure", "clojure"); diff --git a/imports/codemirror/mode/clojure/index.html b/imports/codemirror/mode/clojure/index.html new file mode 100755 index 00000000..9762d589 --- /dev/null +++ b/imports/codemirror/mode/clojure/index.html @@ -0,0 +1,66 @@ + + + + CodeMirror: Clojure mode + + + + + + + +

CodeMirror: Clojure mode

+
+ + +

MIME types defined: text/x-clojure.

+ + + diff --git a/imports/codemirror/mode/coffeescript/LICENSE b/imports/codemirror/mode/coffeescript/LICENSE new file mode 100755 index 00000000..977e284e --- /dev/null +++ b/imports/codemirror/mode/coffeescript/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2011 Jeff Pickhardt +Modified from the Python CodeMirror mode, Copyright (c) 2010 Timothy Farrell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/imports/codemirror/mode/coffeescript/coffeescript.js b/imports/codemirror/mode/coffeescript/coffeescript.js new file mode 100755 index 00000000..d4d57239 --- /dev/null +++ b/imports/codemirror/mode/coffeescript/coffeescript.js @@ -0,0 +1,325 @@ +/** + * Link to the project's GitHub page: + * https://github.com/pickhardt/coffeescript-codemirror-mode + */ +CodeMirror.defineMode('coffeescript', function(conf) { + var ERRORCLASS = 'error'; + + function wordRegexp(words) { + return new RegExp("^((" + words.join(")|(") + "))\\b"); + } + + var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\?]"); + var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]'); + var doubleOperators = new RegExp("^((\->)|(\=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))"); + var doubleDelimiters = new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"); + var tripleDelimiters = new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))"); + var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*"); + + var wordOperators = wordRegexp(['and', 'or', 'not', + 'is', 'isnt', 'in', + 'instanceof', 'typeof']); + var indentKeywords = ['for', 'while', 'loop', 'if', 'unless', 'else', + 'switch', 'try', 'catch', 'finally', 'class']; + var commonKeywords = ['break', 'by', 'continue', 'debugger', 'delete', + 'do', 'in', 'of', 'new', 'return', 'then', + 'this', 'throw', 'when', 'until']; + + var keywords = wordRegexp(indentKeywords.concat(commonKeywords)); + + indentKeywords = wordRegexp(indentKeywords); + + + var stringPrefixes = new RegExp("^('{3}|\"{3}|['\"])"); + var regexPrefixes = new RegExp("^(/{3}|/)"); + var commonConstants = ['Infinity', 'NaN', 'undefined', 'null', 'true', 'false', 'on', 'off', 'yes', 'no']; + var constants = wordRegexp(commonConstants); + + // Tokenizers + function tokenBase(stream, state) { + // Handle scope changes + if (stream.sol()) { + var scopeOffset = state.scopes[0].offset; + if (stream.eatSpace()) { + var lineOffset = stream.indentation(); + if (lineOffset > scopeOffset) { + return 'indent'; + } else if (lineOffset < scopeOffset) { + return 'dedent'; + } + return null; + } else { + if (scopeOffset > 0) { + dedent(stream, state); + } + } + } + if (stream.eatSpace()) { + return null; + } + + var ch = stream.peek(); + + // Handle comments + if (ch === '#') { + stream.skipToEnd(); + return 'comment'; + } + + // Handle number literals + if (stream.match(/^-?[0-9\.]/, false)) { + var floatLiteral = false; + // Floats + if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) { + floatLiteral = true; + } + if (stream.match(/^-?\d+\.\d*/)) { + floatLiteral = true; + } + if (stream.match(/^-?\.\d+/)) { + floatLiteral = true; + } + if (floatLiteral) { + return 'number'; + } + // Integers + var intLiteral = false; + // Hex + if (stream.match(/^-?0x[0-9a-f]+/i)) { + intLiteral = true; + } + // Decimal + if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) { + intLiteral = true; + } + // Zero by itself with no other piece of number. + if (stream.match(/^-?0(?![\dx])/i)) { + intLiteral = true; + } + if (intLiteral) { + return 'number'; + } + } + + // Handle strings + if (stream.match(stringPrefixes)) { + state.tokenize = tokenFactory(stream.current(), 'string'); + return state.tokenize(stream, state); + } + // Handle regex literals + if (stream.match(regexPrefixes)) { + if (stream.current() != '/' || stream.match(/^.*\//, false)) { // prevent highlight of division + state.tokenize = tokenFactory(stream.current(), 'string-2'); + return state.tokenize(stream, state); + } else { + stream.backUp(1); + } + } + + // Handle operators and delimiters + if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) { + return 'punctuation'; + } + if (stream.match(doubleOperators) + || stream.match(singleOperators) + || stream.match(wordOperators)) { + return 'operator'; + } + if (stream.match(singleDelimiters)) { + return 'punctuation'; + } + + if (stream.match(constants)) { + return 'atom'; + } + + if (stream.match(keywords)) { + return 'keyword'; + } + + if (stream.match(identifiers)) { + return 'variable'; + } + + // Handle non-detected items + stream.next(); + return ERRORCLASS; + } + + function tokenFactory(delimiter, outclass) { + var delim_re = new RegExp(delimiter); + var singleline = delimiter.length == 1; + + return function tokenString(stream, state) { + while (!stream.eol()) { + stream.eatWhile(/[^'"\/\\]/); + if (stream.eat('\\')) { + stream.next(); + if (singleline && stream.eol()) { + return outclass; + } + } else if (stream.match(delim_re)) { + state.tokenize = tokenBase; + return outclass; + } else { + stream.eat(/['"\/]/); + } + } + if (singleline) { + if (conf.mode.singleLineStringErrors) { + outclass = ERRORCLASS + } else { + state.tokenize = tokenBase; + } + } + return outclass; + }; + } + + function indent(stream, state, type) { + type = type || 'coffee'; + var indentUnit = 0; + if (type === 'coffee') { + for (var i = 0; i < state.scopes.length; i++) { + if (state.scopes[i].type === 'coffee') { + indentUnit = state.scopes[i].offset + conf.indentUnit; + break; + } + } + } else { + indentUnit = stream.column() + stream.current().length; + } + state.scopes.unshift({ + offset: indentUnit, + type: type + }); + } + + function dedent(stream, state) { + if (state.scopes.length == 1) return; + if (state.scopes[0].type === 'coffee') { + var _indent = stream.indentation(); + var _indent_index = -1; + for (var i = 0; i < state.scopes.length; ++i) { + if (_indent === state.scopes[i].offset) { + _indent_index = i; + break; + } + } + if (_indent_index === -1) { + return true; + } + while (state.scopes[0].offset !== _indent) { + state.scopes.shift(); + } + return false + } else { + state.scopes.shift(); + return false; + } + } + + function tokenLexer(stream, state) { + var style = state.tokenize(stream, state); + var current = stream.current(); + + // Handle '.' connected identifiers + if (current === '.') { + style = state.tokenize(stream, state); + current = stream.current(); + if (style === 'variable') { + return 'variable'; + } else { + return ERRORCLASS; + } + } + + // Handle properties + if (current === '@') { + style = state.tokenize(stream, state); + current = stream.current(); + if (style === 'variable') { + return 'variable-2'; + } else { + return ERRORCLASS; + } + } + + // Handle scope changes. + if (current === 'return') { + state.dedent += 1; + } + if (((current === '->' || current === '=>') && + !state.lambda && + state.scopes[0].type == 'coffee' && + stream.peek() === '') + || style === 'indent') { + indent(stream, state); + } + var delimiter_index = '[({'.indexOf(current); + if (delimiter_index !== -1) { + indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1)); + } + if (indentKeywords.exec(current)){ + indent(stream, state); + } + if (current == 'then'){ + dedent(stream, state); + } + + + if (style === 'dedent') { + if (dedent(stream, state)) { + return ERRORCLASS; + } + } + delimiter_index = '])}'.indexOf(current); + if (delimiter_index !== -1) { + if (dedent(stream, state)) { + return ERRORCLASS; + } + } + if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'coffee') { + if (state.scopes.length > 1) state.scopes.shift(); + state.dedent -= 1; + } + + return style; + } + + var external = { + startState: function(basecolumn) { + return { + tokenize: tokenBase, + scopes: [{offset:basecolumn || 0, type:'coffee'}], + lastToken: null, + lambda: false, + dedent: 0 + }; + }, + + token: function(stream, state) { + var style = tokenLexer(stream, state); + + state.lastToken = {style:style, content: stream.current()}; + + if (stream.eol() && stream.lambda) { + state.lambda = false; + } + + return style; + }, + + indent: function(state, textAfter) { + if (state.tokenize != tokenBase) { + return 0; + } + + return state.scopes[0].offset; + } + + }; + return external; +}); + +CodeMirror.defineMIME('text/x-coffeescript', 'coffeescript'); diff --git a/imports/codemirror/mode/coffeescript/index.html b/imports/codemirror/mode/coffeescript/index.html new file mode 100755 index 00000000..127c4bf9 --- /dev/null +++ b/imports/codemirror/mode/coffeescript/index.html @@ -0,0 +1,721 @@ + + + + CodeMirror: CoffeeScript mode + + + + + + + +

CodeMirror: CoffeeScript mode

+