codemirror-rails 2.36 → 3.00
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +3727 -2345
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +2226 -825
- data/vendor/assets/javascripts/codemirror/modes/clike.js +23 -8
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +4 -4
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/commonlisp.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/css.js +20 -3
- data/vendor/assets/javascripts/codemirror/modes/diff.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +192 -203
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/go.js +1 -6
- data/vendor/assets/javascripts/codemirror/modes/groovy.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/haskell.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +13 -13
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/http.js +98 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/jinja2.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +7 -14
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/ntriples.js +0 -2
- data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -2
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/php.js +5 -4
- data/vendor/assets/javascripts/codemirror/modes/pig.js +3 -4
- data/vendor/assets/javascripts/codemirror/modes/plsql.js +3 -4
- data/vendor/assets/javascripts/codemirror/modes/python.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/r.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/rpm-changes.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -13
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/rust.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +4 -4
- data/vendor/assets/javascripts/codemirror/modes/shell.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sieve.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sparql.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/stex.js +6 -13
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +6 -37
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/vb.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/velocity.js +2 -4
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +182 -194
- data/vendor/assets/javascripts/codemirror/modes/xml.js +9 -5
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +3 -4
- data/vendor/assets/javascripts/codemirror/utils/closetag.js +85 -164
- data/vendor/assets/javascripts/codemirror/utils/colorize.js +29 -0
- data/vendor/assets/javascripts/codemirror/utils/continuecomment.js +1 -1
- data/vendor/assets/javascripts/codemirror/utils/continuelist.js +28 -0
- data/vendor/assets/javascripts/codemirror/utils/dialog.js +21 -16
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +59 -73
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +43 -131
- data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +22 -19
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +5 -3
- data/vendor/assets/javascripts/codemirror/utils/matchbrackets.js +63 -0
- data/vendor/assets/javascripts/codemirror/utils/multiplex.js +18 -0
- data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +3 -9
- data/vendor/assets/javascripts/codemirror/utils/runmode.js +19 -20
- data/vendor/assets/javascripts/codemirror/utils/search.js +6 -5
- data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +1 -1
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +10 -10
- data/vendor/assets/javascripts/codemirror/utils/xml-hint.js +2 -2
- data/vendor/assets/stylesheets/codemirror.css +169 -104
- data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +7 -12
- data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/cobalt.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +4 -4
- data/vendor/assets/stylesheets/codemirror/themes/monokai.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/night.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/solarized.css +207 -0
- data/vendor/assets/stylesheets/codemirror/themes/twilight.css +4 -4
- data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +3 -3
- data/vendor/assets/stylesheets/codemirror/utils/dialog.css +12 -7
- metadata +16 -11
@@ -1,5 +1,6 @@
|
|
1
1
|
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
2
2
|
var indentUnit = config.indentUnit,
|
3
|
+
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
3
4
|
keywords = parserConfig.keywords || {},
|
4
5
|
builtin = parserConfig.builtin || {},
|
5
6
|
blockKeywords = parserConfig.blockKeywords || {},
|
@@ -89,7 +90,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
89
90
|
this.prev = prev;
|
90
91
|
}
|
91
92
|
function pushContext(state, col, type) {
|
92
|
-
|
93
|
+
var indent = state.indented;
|
94
|
+
if (state.context && state.context.type == "statement")
|
95
|
+
indent = state.context.indented;
|
96
|
+
return state.context = new Context(indent, col, type, null, state.context);
|
93
97
|
}
|
94
98
|
function popContext(state) {
|
95
99
|
var t = state.context.type;
|
@@ -123,7 +127,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
123
127
|
if (style == "comment" || style == "meta") return style;
|
124
128
|
if (ctx.align == null) ctx.align = true;
|
125
129
|
|
126
|
-
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
130
|
+
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
|
127
131
|
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
128
132
|
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
129
133
|
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
@@ -140,12 +144,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
140
144
|
},
|
141
145
|
|
142
146
|
indent: function(state, textAfter) {
|
143
|
-
if (state.tokenize
|
144
|
-
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
147
|
+
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
145
148
|
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
146
149
|
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
147
150
|
var closing = firstChar == ctx.type;
|
148
|
-
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 :
|
151
|
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
149
152
|
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
150
153
|
else return ctx.indented + (closing ? 0 : indentUnit);
|
151
154
|
},
|
@@ -166,7 +169,19 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
166
169
|
|
167
170
|
function cppHook(stream, state) {
|
168
171
|
if (!state.startOfLine) return false;
|
169
|
-
|
172
|
+
for (;;) {
|
173
|
+
if (stream.skipTo("\\")) {
|
174
|
+
stream.next();
|
175
|
+
if (stream.eol()) {
|
176
|
+
state.tokenize = cppHook;
|
177
|
+
break;
|
178
|
+
}
|
179
|
+
} else {
|
180
|
+
stream.skipToEnd();
|
181
|
+
state.tokenize = null;
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
}
|
170
185
|
return "meta";
|
171
186
|
}
|
172
187
|
|
@@ -213,7 +228,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
213
228
|
blockKeywords: words("catch class do else finally for if switch try while"),
|
214
229
|
atoms: words("true false null"),
|
215
230
|
hooks: {
|
216
|
-
"@": function(stream
|
231
|
+
"@": function(stream) {
|
217
232
|
stream.eatWhile(/[\w\$_]/);
|
218
233
|
return "meta";
|
219
234
|
}
|
@@ -276,7 +291,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
276
291
|
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
277
292
|
atoms: words("true false null"),
|
278
293
|
hooks: {
|
279
|
-
"@": function(stream
|
294
|
+
"@": function(stream) {
|
280
295
|
stream.eatWhile(/[\w\$_]/);
|
281
296
|
return "meta";
|
282
297
|
}
|
@@ -2,10 +2,10 @@
|
|
2
2
|
* Author: Hans Engel
|
3
3
|
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
|
4
4
|
*/
|
5
|
-
CodeMirror.defineMode("clojure", function (
|
6
|
-
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
5
|
+
CodeMirror.defineMode("clojure", function () {
|
6
|
+
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
7
7
|
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
|
8
|
-
var INDENT_WORD_SKIP = 2
|
8
|
+
var INDENT_WORD_SKIP = 2;
|
9
9
|
|
10
10
|
function makeKeywords(str) {
|
11
11
|
var obj = {}, words = str.split(" ");
|
@@ -196,7 +196,7 @@ CodeMirror.defineMode("clojure", function (config, mode) {
|
|
196
196
|
return returnType;
|
197
197
|
},
|
198
198
|
|
199
|
-
indent: function (state
|
199
|
+
indent: function (state) {
|
200
200
|
if (state.indentStack == null) return state.indentation;
|
201
201
|
return state.indentStack.indent;
|
202
202
|
}
|
@@ -237,6 +237,11 @@ CodeMirror.defineMode("css", function(config) {
|
|
237
237
|
else if (/[;{}\[\]\(\)]/.test(ch)) {
|
238
238
|
return ret(null, ch);
|
239
239
|
}
|
240
|
+
else if (ch == "u" && stream.match("rl(")) {
|
241
|
+
stream.backUp(1);
|
242
|
+
state.tokenize = tokenParenthesized;
|
243
|
+
return ret("property", "variable");
|
244
|
+
}
|
240
245
|
else {
|
241
246
|
stream.eatWhile(/[\w\\\-]/);
|
242
247
|
return ret("property", "variable");
|
@@ -267,7 +272,7 @@ CodeMirror.defineMode("css", function(config) {
|
|
267
272
|
return ret("comment", "comment");
|
268
273
|
}
|
269
274
|
|
270
|
-
function tokenString(quote) {
|
275
|
+
function tokenString(quote, nonInclusive) {
|
271
276
|
return function(stream, state) {
|
272
277
|
var escaped = false, ch;
|
273
278
|
while ((ch = stream.next()) != null) {
|
@@ -275,11 +280,23 @@ CodeMirror.defineMode("css", function(config) {
|
|
275
280
|
break;
|
276
281
|
escaped = !escaped && ch == "\\";
|
277
282
|
}
|
278
|
-
if (!escaped)
|
283
|
+
if (!escaped) {
|
284
|
+
if (nonInclusive) stream.backUp(1);
|
285
|
+
state.tokenize = tokenBase;
|
286
|
+
}
|
279
287
|
return ret("string", "string");
|
280
288
|
};
|
281
289
|
}
|
282
290
|
|
291
|
+
function tokenParenthesized(stream, state) {
|
292
|
+
stream.next(); // Must be '('
|
293
|
+
if (!stream.match(/\s*[\"\']/, false))
|
294
|
+
state.tokenize = tokenString(")", true);
|
295
|
+
else
|
296
|
+
state.tokenize = tokenBase;
|
297
|
+
return ret(null, "(");
|
298
|
+
}
|
299
|
+
|
283
300
|
return {
|
284
301
|
startState: function(base) {
|
285
302
|
return {tokenize: tokenBase,
|
@@ -335,7 +352,7 @@ CodeMirror.defineMode("css", function(config) {
|
|
335
352
|
// sequence of selectors:
|
336
353
|
// One or more of the named type of selector chained with commas.
|
337
354
|
|
338
|
-
if (stream.eatSpace()) return null;
|
355
|
+
if (state.tokenize == tokenBase && stream.eatSpace()) return null;
|
339
356
|
var style = state.tokenize(stream, state);
|
340
357
|
|
341
358
|
// Changing style returned based on context
|
@@ -1,203 +1,192 @@
|
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
var
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
return
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
if (
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
}
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
if (
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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");
|
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
|
+
var indentUnit = config.indentUnit;
|
16
|
+
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");
|
17
|
+
var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
|
18
|
+
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");
|
19
|
+
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");
|
20
|
+
var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
|
21
|
+
var blockKeywords = words("catch class do else finally for if switch try while");
|
22
|
+
var atoms = words("true false null");
|
23
|
+
var hooks = {"#": metaHook};
|
24
|
+
var multiLineStrings;
|
25
|
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
26
|
+
|
27
|
+
var curPunc;
|
28
|
+
|
29
|
+
function tokenBase(stream, state) {
|
30
|
+
var ch = stream.next();
|
31
|
+
if (hooks[ch]) {
|
32
|
+
var result = hooks[ch](stream, state);
|
33
|
+
if (result !== false) return result;
|
34
|
+
}
|
35
|
+
if (ch == '"' || ch == "'") {
|
36
|
+
state.tokenize = tokenString(ch);
|
37
|
+
return state.tokenize(stream, state);
|
38
|
+
}
|
39
|
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
40
|
+
curPunc = ch;
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
if (/\d/.test(ch)) {
|
44
|
+
stream.eatWhile(/[\w\.]/);
|
45
|
+
return "number";
|
46
|
+
}
|
47
|
+
if (ch == "/") {
|
48
|
+
if (stream.eat("*")) {
|
49
|
+
state.tokenize = tokenComment;
|
50
|
+
return tokenComment(stream, state);
|
51
|
+
}
|
52
|
+
if (stream.eat("/")) {
|
53
|
+
stream.skipToEnd();
|
54
|
+
return "comment";
|
55
|
+
}
|
56
|
+
}
|
57
|
+
if (isOperatorChar.test(ch)) {
|
58
|
+
stream.eatWhile(isOperatorChar);
|
59
|
+
return "operator";
|
60
|
+
}
|
61
|
+
stream.eatWhile(/[\w\$_]/);
|
62
|
+
var cur = stream.current().toLowerCase();
|
63
|
+
if (keyword.propertyIsEnumerable(cur)) {
|
64
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
65
|
+
return "keyword";
|
66
|
+
} else if (variable.propertyIsEnumerable(cur)) {
|
67
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
68
|
+
return "variable";
|
69
|
+
} else if (variable_2.propertyIsEnumerable(cur)) {
|
70
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
71
|
+
return "variable-2";
|
72
|
+
} else if (variable_3.propertyIsEnumerable(cur)) {
|
73
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
74
|
+
return "variable-3";
|
75
|
+
} else if (builtin.propertyIsEnumerable(cur)) {
|
76
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
77
|
+
return "builtin";
|
78
|
+
} else { //Data types are of from KEYWORD##
|
79
|
+
var i = cur.length - 1;
|
80
|
+
while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
|
81
|
+
--i;
|
82
|
+
|
83
|
+
if (i > 0) {
|
84
|
+
var cur2 = cur.substr(0, i + 1);
|
85
|
+
if (variable_3.propertyIsEnumerable(cur2)) {
|
86
|
+
if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
|
87
|
+
return "variable-3";
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
92
|
+
return null;
|
93
|
+
}
|
94
|
+
|
95
|
+
function tokenString(quote) {
|
96
|
+
return function(stream, state) {
|
97
|
+
var escaped = false, next, end = false;
|
98
|
+
while ((next = stream.next()) != null) {
|
99
|
+
if (next == quote && !escaped) {end = true; break;}
|
100
|
+
escaped = !escaped && next == "\\";
|
101
|
+
}
|
102
|
+
if (end || !(escaped || multiLineStrings))
|
103
|
+
state.tokenize = tokenBase;
|
104
|
+
return "string";
|
105
|
+
};
|
106
|
+
}
|
107
|
+
|
108
|
+
function tokenComment(stream, state) {
|
109
|
+
var maybeEnd = false, ch;
|
110
|
+
while (ch = stream.next()) {
|
111
|
+
if (ch == "/" && maybeEnd) {
|
112
|
+
state.tokenize = tokenBase;
|
113
|
+
break;
|
114
|
+
}
|
115
|
+
maybeEnd = (ch == "*");
|
116
|
+
}
|
117
|
+
return "comment";
|
118
|
+
}
|
119
|
+
|
120
|
+
function Context(indented, column, type, align, prev) {
|
121
|
+
this.indented = indented;
|
122
|
+
this.column = column;
|
123
|
+
this.type = type;
|
124
|
+
this.align = align;
|
125
|
+
this.prev = prev;
|
126
|
+
}
|
127
|
+
function pushContext(state, col, type) {
|
128
|
+
return state.context = new Context(state.indented, col, type, null, state.context);
|
129
|
+
}
|
130
|
+
function popContext(state) {
|
131
|
+
var t = state.context.type;
|
132
|
+
if (t == ")" || t == "]" || t == "}")
|
133
|
+
state.indented = state.context.indented;
|
134
|
+
return state.context = state.context.prev;
|
135
|
+
}
|
136
|
+
|
137
|
+
// Interface
|
138
|
+
|
139
|
+
return {
|
140
|
+
startState: function(basecolumn) {
|
141
|
+
return {
|
142
|
+
tokenize: null,
|
143
|
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
144
|
+
indented: 0,
|
145
|
+
startOfLine: true
|
146
|
+
};
|
147
|
+
},
|
148
|
+
|
149
|
+
token: function(stream, state) {
|
150
|
+
var ctx = state.context;
|
151
|
+
if (stream.sol()) {
|
152
|
+
if (ctx.align == null) ctx.align = false;
|
153
|
+
state.indented = stream.indentation();
|
154
|
+
state.startOfLine = true;
|
155
|
+
}
|
156
|
+
if (stream.eatSpace()) return null;
|
157
|
+
curPunc = null;
|
158
|
+
var style = (state.tokenize || tokenBase)(stream, state);
|
159
|
+
if (style == "comment" || style == "meta") return style;
|
160
|
+
if (ctx.align == null) ctx.align = true;
|
161
|
+
|
162
|
+
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
163
|
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
164
|
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
165
|
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
166
|
+
else if (curPunc == "}") {
|
167
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
168
|
+
if (ctx.type == "}") ctx = popContext(state);
|
169
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
170
|
+
}
|
171
|
+
else if (curPunc == ctx.type) popContext(state);
|
172
|
+
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
173
|
+
pushContext(state, stream.column(), "statement");
|
174
|
+
state.startOfLine = false;
|
175
|
+
return style;
|
176
|
+
},
|
177
|
+
|
178
|
+
indent: function(state, textAfter) {
|
179
|
+
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
180
|
+
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
181
|
+
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
182
|
+
var closing = firstChar == ctx.type;
|
183
|
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
184
|
+
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
185
|
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
186
|
+
},
|
187
|
+
|
188
|
+
electricChars: "{}"
|
189
|
+
};
|
190
|
+
});
|
191
|
+
|
192
|
+
CodeMirror.defineMIME("text/x-ecl", "ecl");
|