codemirror-rails 2.2.1 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -0
- data/codemirror-rails.gemspec +1 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +842 -422
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +2 -2
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +722 -32
- data/vendor/assets/javascripts/codemirror/modes/clike.js +31 -9
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +59 -37
- data/vendor/assets/javascripts/codemirror/modes/css.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/diff.js +24 -5
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +203 -0
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +251 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +40 -4
- data/vendor/assets/javascripts/codemirror/modes/go.js +170 -0
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +4 -2
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +10 -9
- data/vendor/assets/javascripts/codemirror/modes/less.js +232 -0
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +52 -49
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +188 -0
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +2 -46
- data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/php.js +55 -25
- data/vendor/assets/javascripts/codemirror/modes/pig.js +172 -0
- data/vendor/assets/javascripts/codemirror/modes/properties.js +63 -0
- data/vendor/assets/javascripts/codemirror/modes/python.js +37 -32
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/rust.js +36 -15
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +74 -46
- data/vendor/assets/javascripts/codemirror/modes/shell.js +103 -0
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +16 -16
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +148 -0
- data/vendor/assets/javascripts/codemirror/modes/stex.js +21 -6
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +55 -45
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +316 -0
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +26 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +194 -0
- data/vendor/assets/javascripts/codemirror/modes/xml.js +89 -16
- data/vendor/assets/javascripts/codemirror/modes/xmlpure.js +5 -0
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +448 -0
- data/vendor/assets/javascripts/codemirror/utils/closetag.js +146 -0
- data/vendor/assets/javascripts/codemirror/utils/dialog.js +63 -0
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +196 -0
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +297 -0
- data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +134 -0
- data/vendor/assets/javascripts/codemirror/utils/loadmode.js +51 -0
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +44 -0
- data/vendor/assets/javascripts/codemirror/utils/multiplex.js +72 -0
- data/vendor/assets/javascripts/codemirror/{overlay.js → utils/overlay.js} +3 -2
- data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +123 -0
- data/vendor/assets/javascripts/codemirror/utils/runmode.js +49 -0
- data/vendor/assets/javascripts/codemirror/utils/search.js +118 -0
- data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +117 -0
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +72 -0
- data/vendor/assets/stylesheets/codemirror.css +69 -5
- data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +14 -21
- data/vendor/assets/stylesheets/codemirror/modes/tiki.css +26 -0
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +81 -0
- data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +25 -0
- data/vendor/assets/stylesheets/codemirror/themes/cobalt.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/elegant.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +21 -0
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +44 -0
- data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/neat.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +27 -0
- data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +46 -0
- data/vendor/assets/stylesheets/codemirror/utils/dialog.css +23 -0
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +16 -0
- metadata +41 -10
- data/vendor/assets/javascripts/codemirror/runmode.js +0 -27
- data/vendor/assets/stylesheets/codemirror/modes/clike.css +0 -7
- data/vendor/assets/stylesheets/codemirror/modes/markdown.css +0 -10
- data/vendor/assets/stylesheets/codemirror/modes/rst.css +0 -75
- data/vendor/assets/stylesheets/codemirror/themes/default.css +0 -19
@@ -21,7 +21,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
21
21
|
}
|
22
22
|
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
23
23
|
curPunc = ch;
|
24
|
-
return null
|
24
|
+
return null;
|
25
25
|
}
|
26
26
|
if (/\d/.test(ch)) {
|
27
27
|
stream.eatWhile(/[\w\.]/);
|
@@ -59,7 +59,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
59
59
|
escaped = !escaped && next == "\\";
|
60
60
|
}
|
61
61
|
if (end || !(escaped || multiLineStrings))
|
62
|
-
state.tokenize =
|
62
|
+
state.tokenize = null;
|
63
63
|
return "string";
|
64
64
|
};
|
65
65
|
}
|
@@ -68,7 +68,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
68
68
|
var maybeEnd = false, ch;
|
69
69
|
while (ch = stream.next()) {
|
70
70
|
if (ch == "/" && maybeEnd) {
|
71
|
-
state.tokenize =
|
71
|
+
state.tokenize = null;
|
72
72
|
break;
|
73
73
|
}
|
74
74
|
maybeEnd = (ch == "*");
|
@@ -231,13 +231,35 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
231
231
|
}
|
232
232
|
}
|
233
233
|
});
|
234
|
-
CodeMirror.defineMIME("text/x-
|
234
|
+
CodeMirror.defineMIME("text/x-scala", {
|
235
235
|
name: "clike",
|
236
|
-
keywords: words(
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
236
|
+
keywords: words(
|
237
|
+
|
238
|
+
/* scala */
|
239
|
+
"abstract case catch class def do else extends false final finally for forSome if " +
|
240
|
+
"implicit import lazy match new null object override package private protected return " +
|
241
|
+
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
242
|
+
"<% >: # @ " +
|
243
|
+
|
244
|
+
/* package scala */
|
245
|
+
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
246
|
+
"readChar readInt readLong readFloat readDouble " +
|
247
|
+
|
248
|
+
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
249
|
+
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
250
|
+
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
251
|
+
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
252
|
+
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
253
|
+
|
254
|
+
/* package java.lang */
|
255
|
+
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
256
|
+
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
257
|
+
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
258
|
+
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
259
|
+
|
260
|
+
|
261
|
+
),
|
262
|
+
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
241
263
|
atoms: words("true false null"),
|
242
264
|
hooks: {
|
243
265
|
"@": function(stream, state) {
|
@@ -4,7 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
CodeMirror.defineMode("clojure", function (config, mode) {
|
6
6
|
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", TAG = "tag",
|
7
|
-
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
|
7
|
+
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
|
8
8
|
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
|
9
9
|
|
10
10
|
function makeKeywords(str) {
|
@@ -14,26 +14,25 @@ CodeMirror.defineMode("clojure", function (config, mode) {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
var atoms = makeKeywords("true false nil");
|
17
|
-
|
17
|
+
|
18
18
|
var keywords = makeKeywords(
|
19
|
-
|
20
|
-
"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" +
|
19
|
+
"defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject 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");
|
21
20
|
|
22
|
-
|
21
|
+
var builtins = makeKeywords(
|
23
22
|
"* *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");
|
24
23
|
|
25
24
|
var indentKeys = makeKeywords(
|
26
25
|
// Built-ins
|
27
|
-
"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" +
|
26
|
+
"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 " +
|
28
27
|
|
29
28
|
// Binding forms
|
30
|
-
"let letfn binding loop for doseq dotimes when-let if-let" +
|
29
|
+
"let letfn binding loop for doseq dotimes when-let if-let " +
|
31
30
|
|
32
31
|
// Data structures
|
33
|
-
"defstruct struct-map assoc" +
|
32
|
+
"defstruct struct-map assoc " +
|
34
33
|
|
35
34
|
// clojure.test
|
36
|
-
"testing deftest" +
|
35
|
+
"testing deftest " +
|
37
36
|
|
38
37
|
// contrib
|
39
38
|
"handler-case handle dotrace deftrace");
|
@@ -103,7 +102,7 @@ CodeMirror.defineMode("clojure", function (config, mode) {
|
|
103
102
|
return {
|
104
103
|
indentStack: null,
|
105
104
|
indentation: 0,
|
106
|
-
mode: false
|
105
|
+
mode: false
|
107
106
|
};
|
108
107
|
},
|
109
108
|
|
@@ -154,12 +153,11 @@ CodeMirror.defineMode("clojure", function (config, mode) {
|
|
154
153
|
(;something else, bracket, etc.
|
155
154
|
*/
|
156
155
|
|
157
|
-
while ((letter = stream.eat(tests.keyword_char)) != null) {
|
156
|
+
if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) {
|
158
157
|
keyWord += letter;
|
159
158
|
}
|
160
159
|
|
161
160
|
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
162
|
-
|
163
161
|
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
164
162
|
} else { // non-indent word
|
165
163
|
// we continue eating the spaces
|
@@ -182,13 +180,15 @@ CodeMirror.defineMode("clojure", function (config, mode) {
|
|
182
180
|
}
|
183
181
|
} else if ( ch == ":" ) {
|
184
182
|
stream.eatWhile(tests.lang_keyword);
|
185
|
-
return
|
183
|
+
return ATOM;
|
186
184
|
} else {
|
187
185
|
stream.eatWhile(tests.basic);
|
188
186
|
|
189
187
|
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
188
|
+
returnType = KEYWORD;
|
189
|
+
} else if (builtins && builtins.propertyIsEnumerable(stream.current())) {
|
190
190
|
returnType = BUILTIN;
|
191
|
-
} else if (
|
191
|
+
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
|
192
192
|
returnType = ATOM;
|
193
193
|
} else returnType = null;
|
194
194
|
}
|
@@ -4,17 +4,17 @@
|
|
4
4
|
*/
|
5
5
|
CodeMirror.defineMode('coffeescript', function(conf) {
|
6
6
|
var ERRORCLASS = 'error';
|
7
|
-
|
7
|
+
|
8
8
|
function wordRegexp(words) {
|
9
9
|
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
10
10
|
}
|
11
|
-
|
11
|
+
|
12
12
|
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\?]");
|
13
13
|
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
|
14
14
|
var doubleOperators = new RegExp("^((\->)|(\=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))");
|
15
15
|
var doubleDelimiters = new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
16
16
|
var tripleDelimiters = new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))");
|
17
|
-
var identifiers = new RegExp("^[_A-Za-z][_A-Za-
|
17
|
+
var identifiers = new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*");
|
18
18
|
|
19
19
|
var wordOperators = wordRegexp(['and', 'or', 'not',
|
20
20
|
'is', 'isnt', 'in',
|
@@ -57,15 +57,27 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
57
57
|
if (stream.eatSpace()) {
|
58
58
|
return null;
|
59
59
|
}
|
60
|
-
|
60
|
+
|
61
61
|
var ch = stream.peek();
|
62
|
-
|
63
|
-
// Handle
|
62
|
+
|
63
|
+
// Handle docco title comment (single line)
|
64
|
+
if (stream.match("####")) {
|
65
|
+
stream.skipToEnd();
|
66
|
+
return 'comment';
|
67
|
+
}
|
68
|
+
|
69
|
+
// Handle multi line comments
|
70
|
+
if (stream.match("###")) {
|
71
|
+
state.tokenize = longComment;
|
72
|
+
return state.tokenize(stream, state);
|
73
|
+
}
|
74
|
+
|
75
|
+
// Single line comment
|
64
76
|
if (ch === '#') {
|
65
77
|
stream.skipToEnd();
|
66
78
|
return 'comment';
|
67
79
|
}
|
68
|
-
|
80
|
+
|
69
81
|
// Handle number literals
|
70
82
|
if (stream.match(/^-?[0-9\.]/, false)) {
|
71
83
|
var floatLiteral = false;
|
@@ -79,7 +91,12 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
79
91
|
if (stream.match(/^-?\.\d+/)) {
|
80
92
|
floatLiteral = true;
|
81
93
|
}
|
94
|
+
|
82
95
|
if (floatLiteral) {
|
96
|
+
// prevent from getting extra . on 1..
|
97
|
+
if (stream.peek() == "."){
|
98
|
+
stream.backUp(1);
|
99
|
+
}
|
83
100
|
return 'number';
|
84
101
|
}
|
85
102
|
// Integers
|
@@ -100,7 +117,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
100
117
|
return 'number';
|
101
118
|
}
|
102
119
|
}
|
103
|
-
|
120
|
+
|
104
121
|
// Handle strings
|
105
122
|
if (stream.match(stringPrefixes)) {
|
106
123
|
state.tokenize = tokenFactory(stream.current(), 'string');
|
@@ -115,7 +132,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
115
132
|
stream.backUp(1);
|
116
133
|
}
|
117
134
|
}
|
118
|
-
|
135
|
+
|
119
136
|
// Handle operators and delimiters
|
120
137
|
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
|
121
138
|
return 'punctuation';
|
@@ -128,28 +145,26 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
128
145
|
if (stream.match(singleDelimiters)) {
|
129
146
|
return 'punctuation';
|
130
147
|
}
|
131
|
-
|
148
|
+
|
132
149
|
if (stream.match(constants)) {
|
133
150
|
return 'atom';
|
134
151
|
}
|
135
|
-
|
152
|
+
|
136
153
|
if (stream.match(keywords)) {
|
137
154
|
return 'keyword';
|
138
155
|
}
|
139
|
-
|
156
|
+
|
140
157
|
if (stream.match(identifiers)) {
|
141
158
|
return 'variable';
|
142
159
|
}
|
143
|
-
|
160
|
+
|
144
161
|
// Handle non-detected items
|
145
162
|
stream.next();
|
146
163
|
return ERRORCLASS;
|
147
164
|
}
|
148
|
-
|
165
|
+
|
149
166
|
function tokenFactory(delimiter, outclass) {
|
150
|
-
var delim_re = new RegExp(delimiter);
|
151
167
|
var singleline = delimiter.length == 1;
|
152
|
-
|
153
168
|
return function tokenString(stream, state) {
|
154
169
|
while (!stream.eol()) {
|
155
170
|
stream.eatWhile(/[^'"\/\\]/);
|
@@ -158,7 +173,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
158
173
|
if (singleline && stream.eol()) {
|
159
174
|
return outclass;
|
160
175
|
}
|
161
|
-
} else if (stream.match(
|
176
|
+
} else if (stream.match(delimiter)) {
|
162
177
|
state.tokenize = tokenBase;
|
163
178
|
return outclass;
|
164
179
|
} else {
|
@@ -175,7 +190,19 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
175
190
|
return outclass;
|
176
191
|
};
|
177
192
|
}
|
178
|
-
|
193
|
+
|
194
|
+
function longComment(stream, state) {
|
195
|
+
while (!stream.eol()) {
|
196
|
+
stream.eatWhile(/[^#]/);
|
197
|
+
if (stream.match("###")) {
|
198
|
+
state.tokenize = tokenBase;
|
199
|
+
break;
|
200
|
+
}
|
201
|
+
stream.eatWhile("#");
|
202
|
+
}
|
203
|
+
return "comment"
|
204
|
+
}
|
205
|
+
|
179
206
|
function indent(stream, state, type) {
|
180
207
|
type = type || 'coffee';
|
181
208
|
var indentUnit = 0;
|
@@ -194,7 +221,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
194
221
|
type: type
|
195
222
|
});
|
196
223
|
}
|
197
|
-
|
224
|
+
|
198
225
|
function dedent(stream, state) {
|
199
226
|
if (state.scopes.length == 1) return;
|
200
227
|
if (state.scopes[0].type === 'coffee') {
|
@@ -233,18 +260,13 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
233
260
|
return ERRORCLASS;
|
234
261
|
}
|
235
262
|
}
|
236
|
-
|
263
|
+
|
237
264
|
// Handle properties
|
238
265
|
if (current === '@') {
|
239
|
-
|
240
|
-
|
241
|
-
if (style === 'variable') {
|
242
|
-
return 'variable-2';
|
243
|
-
} else {
|
244
|
-
return ERRORCLASS;
|
245
|
-
}
|
266
|
+
stream.eat('@');
|
267
|
+
return 'keyword';
|
246
268
|
}
|
247
|
-
|
269
|
+
|
248
270
|
// Handle scope changes.
|
249
271
|
if (current === 'return') {
|
250
272
|
state.dedent += 1;
|
@@ -266,7 +288,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
266
288
|
if (current == 'then'){
|
267
289
|
dedent(stream, state);
|
268
290
|
}
|
269
|
-
|
291
|
+
|
270
292
|
|
271
293
|
if (style === 'dedent') {
|
272
294
|
if (dedent(stream, state)) {
|
@@ -283,7 +305,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
283
305
|
if (state.scopes.length > 1) state.scopes.shift();
|
284
306
|
state.dedent -= 1;
|
285
307
|
}
|
286
|
-
|
308
|
+
|
287
309
|
return style;
|
288
310
|
}
|
289
311
|
|
@@ -297,27 +319,27 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|
297
319
|
dedent: 0
|
298
320
|
};
|
299
321
|
},
|
300
|
-
|
322
|
+
|
301
323
|
token: function(stream, state) {
|
302
324
|
var style = tokenLexer(stream, state);
|
303
|
-
|
325
|
+
|
304
326
|
state.lastToken = {style:style, content: stream.current()};
|
305
|
-
|
327
|
+
|
306
328
|
if (stream.eol() && stream.lambda) {
|
307
329
|
state.lambda = false;
|
308
330
|
}
|
309
|
-
|
331
|
+
|
310
332
|
return style;
|
311
333
|
},
|
312
|
-
|
334
|
+
|
313
335
|
indent: function(state, textAfter) {
|
314
336
|
if (state.tokenize != tokenBase) {
|
315
337
|
return 0;
|
316
338
|
}
|
317
|
-
|
339
|
+
|
318
340
|
return state.scopes[0].offset;
|
319
341
|
}
|
320
|
-
|
342
|
+
|
321
343
|
};
|
322
344
|
return external;
|
323
345
|
});
|
@@ -92,7 +92,7 @@ CodeMirror.defineMode("css", function(config) {
|
|
92
92
|
var style = state.tokenize(stream, state);
|
93
93
|
|
94
94
|
var context = state.stack[state.stack.length-1];
|
95
|
-
if (type == "hash" && context
|
95
|
+
if (type == "hash" && context != "rule") style = "string-2";
|
96
96
|
else if (style == "variable") {
|
97
97
|
if (context == "rule") style = "number";
|
98
98
|
else if (!context || context == "@media{") style = "tag";
|
@@ -1,11 +1,30 @@
|
|
1
1
|
CodeMirror.defineMode("diff", function() {
|
2
|
+
|
3
|
+
var TOKEN_NAMES = {
|
4
|
+
'+': 'tag',
|
5
|
+
'-': 'string',
|
6
|
+
'@': 'meta'
|
7
|
+
};
|
8
|
+
|
2
9
|
return {
|
3
10
|
token: function(stream) {
|
4
|
-
var
|
5
|
-
|
6
|
-
if (
|
7
|
-
|
8
|
-
|
11
|
+
var tw_pos = stream.string.search(/[\t ]+?$/);
|
12
|
+
|
13
|
+
if (!stream.sol() || tw_pos === 0) {
|
14
|
+
stream.skipToEnd();
|
15
|
+
return ("error " + (
|
16
|
+
TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
|
17
|
+
}
|
18
|
+
|
19
|
+
var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
|
20
|
+
|
21
|
+
if (tw_pos === -1) {
|
22
|
+
stream.skipToEnd();
|
23
|
+
} else {
|
24
|
+
stream.pos = tw_pos;
|
25
|
+
}
|
26
|
+
|
27
|
+
return token_name;
|
9
28
|
}
|
10
29
|
};
|
11
30
|
});
|
@@ -0,0 +1,203 @@
|
|
1
|
+
CodeMirror.defineMode("ecl", function(config) {
|
2
|
+
|
3
|
+
function words(str) {
|
4
|
+
var obj = {}, words = str.split(" ");
|
5
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
6
|
+
return obj;
|
7
|
+
}
|
8
|
+
|
9
|
+
function metaHook(stream, state) {
|
10
|
+
if (!state.startOfLine) return false;
|
11
|
+
stream.skipToEnd();
|
12
|
+
return "meta";
|
13
|
+
}
|
14
|
+
|
15
|
+
function tokenAtString(stream, state) {
|
16
|
+
var next;
|
17
|
+
while ((next = stream.next()) != null) {
|
18
|
+
if (next == '"' && !stream.eat('"')) {
|
19
|
+
state.tokenize = null;
|
20
|
+
break;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
return "string";
|
24
|
+
}
|
25
|
+
|
26
|
+
var indentUnit = config.indentUnit;
|
27
|
+
var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
|
28
|
+
var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
|
29
|
+
var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
|
30
|
+
var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
|
31
|
+
var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
|
32
|
+
var blockKeywords = words("catch class do else finally for if switch try while");
|
33
|
+
var atoms = words("true false null");
|
34
|
+
var hooks = {"#": metaHook};
|
35
|
+
var multiLineStrings;
|
36
|
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
37
|
+
|
38
|
+
var curPunc;
|
39
|
+
|
40
|
+
function tokenBase(stream, state) {
|
41
|
+
var ch = stream.next();
|
42
|
+
if (hooks[ch]) {
|
43
|
+
var result = hooks[ch](stream, state);
|
44
|
+
if (result !== false) return result;
|
45
|
+
}
|
46
|
+
if (ch == '"' || ch == "'") {
|
47
|
+
state.tokenize = tokenString(ch);
|
48
|
+
return state.tokenize(stream, state);
|
49
|
+
}
|
50
|
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
51
|
+
curPunc = ch;
|
52
|
+
return null
|
53
|
+
}
|
54
|
+
if (/\d/.test(ch)) {
|
55
|
+
stream.eatWhile(/[\w\.]/);
|
56
|
+
return "number";
|
57
|
+
}
|
58
|
+
if (ch == "/") {
|
59
|
+
if (stream.eat("*")) {
|
60
|
+
state.tokenize = tokenComment;
|
61
|
+
return tokenComment(stream, state);
|
62
|
+
}
|
63
|
+
if (stream.eat("/")) {
|
64
|
+
stream.skipToEnd();
|
65
|
+
return "comment";
|
66
|
+
}
|
67
|
+
}
|
68
|
+
if (isOperatorChar.test(ch)) {
|
69
|
+
stream.eatWhile(isOperatorChar);
|
70
|
+
return "operator";
|
71
|
+
}
|
72
|
+
stream.eatWhile(/[\w\$_]/);
|
73
|
+
var cur = stream.current().toLowerCase();
|
74
|
+
if (keyword.propertyIsEnumerable(cur)) {
|
75
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
76
|
+
return "keyword";
|
77
|
+
} else if (variable.propertyIsEnumerable(cur)) {
|
78
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
79
|
+
return "variable";
|
80
|
+
} else if (variable_2.propertyIsEnumerable(cur)) {
|
81
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
82
|
+
return "variable-2";
|
83
|
+
} else if (variable_3.propertyIsEnumerable(cur)) {
|
84
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
85
|
+
return "variable-3";
|
86
|
+
} else if (builtin.propertyIsEnumerable(cur)) {
|
87
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
88
|
+
return "builtin";
|
89
|
+
} else { //Data types are of from KEYWORD##
|
90
|
+
var i = cur.length - 1;
|
91
|
+
while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
|
92
|
+
--i;
|
93
|
+
|
94
|
+
if (i > 0) {
|
95
|
+
var cur2 = cur.substr(0, i + 1);
|
96
|
+
if (variable_3.propertyIsEnumerable(cur2)) {
|
97
|
+
if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
|
98
|
+
return "variable-3";
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
103
|
+
return "word";
|
104
|
+
}
|
105
|
+
|
106
|
+
function tokenString(quote) {
|
107
|
+
return function(stream, state) {
|
108
|
+
var escaped = false, next, end = false;
|
109
|
+
while ((next = stream.next()) != null) {
|
110
|
+
if (next == quote && !escaped) {end = true; break;}
|
111
|
+
escaped = !escaped && next == "\\";
|
112
|
+
}
|
113
|
+
if (end || !(escaped || multiLineStrings))
|
114
|
+
state.tokenize = tokenBase;
|
115
|
+
return "string";
|
116
|
+
};
|
117
|
+
}
|
118
|
+
|
119
|
+
function tokenComment(stream, state) {
|
120
|
+
var maybeEnd = false, ch;
|
121
|
+
while (ch = stream.next()) {
|
122
|
+
if (ch == "/" && maybeEnd) {
|
123
|
+
state.tokenize = tokenBase;
|
124
|
+
break;
|
125
|
+
}
|
126
|
+
maybeEnd = (ch == "*");
|
127
|
+
}
|
128
|
+
return "comment";
|
129
|
+
}
|
130
|
+
|
131
|
+
function Context(indented, column, type, align, prev) {
|
132
|
+
this.indented = indented;
|
133
|
+
this.column = column;
|
134
|
+
this.type = type;
|
135
|
+
this.align = align;
|
136
|
+
this.prev = prev;
|
137
|
+
}
|
138
|
+
function pushContext(state, col, type) {
|
139
|
+
return state.context = new Context(state.indented, col, type, null, state.context);
|
140
|
+
}
|
141
|
+
function popContext(state) {
|
142
|
+
var t = state.context.type;
|
143
|
+
if (t == ")" || t == "]" || t == "}")
|
144
|
+
state.indented = state.context.indented;
|
145
|
+
return state.context = state.context.prev;
|
146
|
+
}
|
147
|
+
|
148
|
+
// Interface
|
149
|
+
|
150
|
+
return {
|
151
|
+
startState: function(basecolumn) {
|
152
|
+
return {
|
153
|
+
tokenize: null,
|
154
|
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
155
|
+
indented: 0,
|
156
|
+
startOfLine: true
|
157
|
+
};
|
158
|
+
},
|
159
|
+
|
160
|
+
token: function(stream, state) {
|
161
|
+
var ctx = state.context;
|
162
|
+
if (stream.sol()) {
|
163
|
+
if (ctx.align == null) ctx.align = false;
|
164
|
+
state.indented = stream.indentation();
|
165
|
+
state.startOfLine = true;
|
166
|
+
}
|
167
|
+
if (stream.eatSpace()) return null;
|
168
|
+
curPunc = null;
|
169
|
+
var style = (state.tokenize || tokenBase)(stream, state);
|
170
|
+
if (style == "comment" || style == "meta") return style;
|
171
|
+
if (ctx.align == null) ctx.align = true;
|
172
|
+
|
173
|
+
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
174
|
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
175
|
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
176
|
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
177
|
+
else if (curPunc == "}") {
|
178
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
179
|
+
if (ctx.type == "}") ctx = popContext(state);
|
180
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
181
|
+
}
|
182
|
+
else if (curPunc == ctx.type) popContext(state);
|
183
|
+
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
184
|
+
pushContext(state, stream.column(), "statement");
|
185
|
+
state.startOfLine = false;
|
186
|
+
return style;
|
187
|
+
},
|
188
|
+
|
189
|
+
indent: function(state, textAfter) {
|
190
|
+
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
191
|
+
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
192
|
+
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
193
|
+
var closing = firstChar == ctx.type;
|
194
|
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
195
|
+
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
196
|
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
197
|
+
},
|
198
|
+
|
199
|
+
electricChars: "{}"
|
200
|
+
};
|
201
|
+
});
|
202
|
+
|
203
|
+
CodeMirror.defineMIME("text/x-ecl", "ecl");
|