codemirror-rails 2.36 → 3.00

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/lib/codemirror/rails/version.rb +2 -2
  2. data/vendor/assets/javascripts/codemirror.js +3727 -2345
  3. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +2226 -825
  4. data/vendor/assets/javascripts/codemirror/modes/clike.js +23 -8
  5. data/vendor/assets/javascripts/codemirror/modes/clojure.js +4 -4
  6. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +1 -1
  7. data/vendor/assets/javascripts/codemirror/modes/commonlisp.js +1 -1
  8. data/vendor/assets/javascripts/codemirror/modes/css.js +20 -3
  9. data/vendor/assets/javascripts/codemirror/modes/diff.js +2 -2
  10. data/vendor/assets/javascripts/codemirror/modes/ecl.js +192 -203
  11. data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
  12. data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -1
  13. data/vendor/assets/javascripts/codemirror/modes/go.js +1 -6
  14. data/vendor/assets/javascripts/codemirror/modes/groovy.js +1 -1
  15. data/vendor/assets/javascripts/codemirror/modes/haskell.js +1 -1
  16. data/vendor/assets/javascripts/codemirror/modes/haxe.js +13 -13
  17. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +3 -3
  18. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +1 -1
  19. data/vendor/assets/javascripts/codemirror/modes/http.js +98 -0
  20. data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -1
  21. data/vendor/assets/javascripts/codemirror/modes/jinja2.js +1 -1
  22. data/vendor/assets/javascripts/codemirror/modes/markdown.js +7 -14
  23. data/vendor/assets/javascripts/codemirror/modes/mysql.js +2 -2
  24. data/vendor/assets/javascripts/codemirror/modes/ntriples.js +0 -2
  25. data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -2
  26. data/vendor/assets/javascripts/codemirror/modes/pascal.js +2 -2
  27. data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
  28. data/vendor/assets/javascripts/codemirror/modes/php.js +5 -4
  29. data/vendor/assets/javascripts/codemirror/modes/pig.js +3 -4
  30. data/vendor/assets/javascripts/codemirror/modes/plsql.js +3 -4
  31. data/vendor/assets/javascripts/codemirror/modes/python.js +1 -1
  32. data/vendor/assets/javascripts/codemirror/modes/r.js +1 -1
  33. data/vendor/assets/javascripts/codemirror/modes/rpm-changes.js +1 -1
  34. data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
  35. data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -13
  36. data/vendor/assets/javascripts/codemirror/modes/ruby.js +1 -1
  37. data/vendor/assets/javascripts/codemirror/modes/rust.js +3 -3
  38. data/vendor/assets/javascripts/codemirror/modes/scheme.js +4 -4
  39. data/vendor/assets/javascripts/codemirror/modes/shell.js +1 -1
  40. data/vendor/assets/javascripts/codemirror/modes/sieve.js +1 -1
  41. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +2 -2
  42. data/vendor/assets/javascripts/codemirror/modes/smarty.js +1 -1
  43. data/vendor/assets/javascripts/codemirror/modes/sparql.js +2 -2
  44. data/vendor/assets/javascripts/codemirror/modes/stex.js +6 -13
  45. data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +6 -37
  46. data/vendor/assets/javascripts/codemirror/modes/tiki.js +3 -3
  47. data/vendor/assets/javascripts/codemirror/modes/vb.js +3 -3
  48. data/vendor/assets/javascripts/codemirror/modes/velocity.js +2 -4
  49. data/vendor/assets/javascripts/codemirror/modes/verilog.js +182 -194
  50. data/vendor/assets/javascripts/codemirror/modes/xml.js +9 -5
  51. data/vendor/assets/javascripts/codemirror/modes/xquery.js +3 -4
  52. data/vendor/assets/javascripts/codemirror/utils/closetag.js +85 -164
  53. data/vendor/assets/javascripts/codemirror/utils/colorize.js +29 -0
  54. data/vendor/assets/javascripts/codemirror/utils/continuecomment.js +1 -1
  55. data/vendor/assets/javascripts/codemirror/utils/continuelist.js +28 -0
  56. data/vendor/assets/javascripts/codemirror/utils/dialog.js +21 -16
  57. data/vendor/assets/javascripts/codemirror/utils/foldcode.js +59 -73
  58. data/vendor/assets/javascripts/codemirror/utils/formatting.js +43 -131
  59. data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +22 -19
  60. data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +5 -3
  61. data/vendor/assets/javascripts/codemirror/utils/matchbrackets.js +63 -0
  62. data/vendor/assets/javascripts/codemirror/utils/multiplex.js +18 -0
  63. data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +3 -9
  64. data/vendor/assets/javascripts/codemirror/utils/runmode.js +19 -20
  65. data/vendor/assets/javascripts/codemirror/utils/search.js +6 -5
  66. data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +1 -1
  67. data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +10 -10
  68. data/vendor/assets/javascripts/codemirror/utils/xml-hint.js +2 -2
  69. data/vendor/assets/stylesheets/codemirror.css +169 -104
  70. data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +1 -1
  71. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +7 -12
  72. data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +3 -3
  73. data/vendor/assets/stylesheets/codemirror/themes/cobalt.css +3 -3
  74. data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +3 -3
  75. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +4 -4
  76. data/vendor/assets/stylesheets/codemirror/themes/monokai.css +3 -3
  77. data/vendor/assets/stylesheets/codemirror/themes/night.css +3 -3
  78. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +3 -3
  79. data/vendor/assets/stylesheets/codemirror/themes/solarized.css +207 -0
  80. data/vendor/assets/stylesheets/codemirror/themes/twilight.css +4 -4
  81. data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +3 -3
  82. data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +3 -3
  83. data/vendor/assets/stylesheets/codemirror/utils/dialog.css +12 -7
  84. 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
- return state.context = new Context(state.indented, col, type, null, state.context);
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 == tokenComment) return CodeMirror.Pass;
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 : indentUnit);
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
- stream.skipToEnd();
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, state) {
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, state) {
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 (config, mode) {
6
- var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", TAG = "tag",
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, KEYWORDS_SKIP = 1;
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, textAfter) {
199
+ indent: function (state) {
200
200
  if (state.indentStack == null) return state.indentation;
201
201
  return state.indentStack.indent;
202
202
  }
@@ -331,7 +331,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
331
331
  return style;
332
332
  },
333
333
 
334
- indent: function(state, textAfter) {
334
+ indent: function(state) {
335
335
  if (state.tokenize != tokenBase) {
336
336
  return 0;
337
337
  }
@@ -91,7 +91,7 @@ CodeMirror.defineMode("commonlisp", function (config) {
91
91
  return style;
92
92
  },
93
93
 
94
- indent: function (state, textAfter) {
94
+ indent: function (state, _textAfter) {
95
95
  var i = state.ctx.indentTo;
96
96
  return typeof i == "number" ? i : state.ctx.start + 1;
97
97
  }
@@ -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) state.tokenize = tokenBase;
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,8 +1,8 @@
1
1
  CodeMirror.defineMode("diff", function() {
2
2
 
3
3
  var TOKEN_NAMES = {
4
- '+': 'tag',
5
- '-': 'string',
4
+ '+': 'positive',
5
+ '-': 'negative',
6
6
  '@': 'meta'
7
7
  };
8
8
 
@@ -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
- 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 null;
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");
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");