codemirror-rails 3.23 → 3.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +51 -10
  4. data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +1 -1
  5. data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +13 -3
  6. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +14 -9
  7. data/vendor/assets/javascripts/codemirror/addons/mode/overlay.js +8 -2
  8. data/vendor/assets/javascripts/codemirror/addons/search/search.js +14 -14
  9. data/vendor/assets/javascripts/codemirror/modes/clike.js +4 -3
  10. data/vendor/assets/javascripts/codemirror/modes/css.js +3 -3
  11. data/vendor/assets/javascripts/codemirror/modes/django.js +55 -0
  12. data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
  13. data/vendor/assets/javascripts/codemirror/modes/go.js +1 -0
  14. data/vendor/assets/javascripts/codemirror/modes/haxe.js +7 -3
  15. data/vendor/assets/javascripts/codemirror/modes/javascript.js +13 -7
  16. data/vendor/assets/javascripts/codemirror/modes/jinja2.js +111 -35
  17. data/vendor/assets/javascripts/codemirror/modes/livescript.js +4 -4
  18. data/vendor/assets/javascripts/codemirror/modes/php.js +99 -9
  19. data/vendor/assets/javascripts/codemirror/modes/r.js +3 -1
  20. data/vendor/assets/javascripts/codemirror/modes/verilog.js +237 -80
  21. data/vendor/assets/javascripts/codemirror/modes/xml.js +4 -1
  22. data/vendor/assets/stylesheets/codemirror.css +4 -3
  23. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -1
  24. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +0 -4
  25. data/vendor/assets/stylesheets/codemirror/themes/mdn-like.css +1 -1
  26. data/vendor/assets/stylesheets/codemirror/themes/pastel-on-dark.css +0 -1
  27. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +0 -2
  28. data/vendor/assets/stylesheets/codemirror/themes/solarized.css +0 -1
  29. metadata +19 -18
@@ -1,33 +1,139 @@
1
1
  CodeMirror.defineMode("verilog", function(config, parserConfig) {
2
+
2
3
  var indentUnit = config.indentUnit,
3
- keywords = parserConfig.keywords || {},
4
- blockKeywords = parserConfig.blockKeywords || {},
5
- atoms = parserConfig.atoms || {},
6
- hooks = parserConfig.hooks || {},
4
+ statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
5
+ dontAlignCalls = parserConfig.dontAlignCalls,
6
+ noIndentKeywords = parserConfig.noIndentKeywords || [],
7
7
  multiLineStrings = parserConfig.multiLineStrings;
8
- var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
8
+
9
+ function words(str) {
10
+ var obj = {}, words = str.split(" ");
11
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
12
+ return obj;
13
+ }
14
+
15
+ /**
16
+ * Keywords from IEEE 1800-2012
17
+ */
18
+ var keywords = words(
19
+ "accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind " +
20
+ "bins binsof bit break buf bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config " +
21
+ "const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable " +
22
+ "dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup " +
23
+ "endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask " +
24
+ "enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin " +
25
+ "function generate genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import " +
26
+ "incdir include initial inout input inside instance int integer interconnect interface intersect join join_any " +
27
+ "join_none large let liblist library local localparam logic longint macromodule matches medium modport module " +
28
+ "nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 null or output package packed " +
29
+ "parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup " +
30
+ "pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg " +
31
+ "reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime " +
32
+ "s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify " +
33
+ "specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on " +
34
+ "table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior " +
35
+ "trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void " +
36
+ "wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor");
37
+
38
+ /** Operators from IEEE 1800-2012
39
+ unary_operator ::=
40
+ + | - | ! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
41
+ binary_operator ::=
42
+ + | - | * | / | % | == | != | === | !== | ==? | !=? | && | || | **
43
+ | < | <= | > | >= | & | | | ^ | ^~ | ~^ | >> | << | >>> | <<<
44
+ | -> | <->
45
+ inc_or_dec_operator ::= ++ | --
46
+ unary_module_path_operator ::=
47
+ ! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
48
+ binary_module_path_operator ::=
49
+ == | != | && | || | & | | | ^ | ^~ | ~^
50
+ */
51
+ var isOperatorChar = /[\+\-\*\/!~&|^%=?:]/;
52
+ var isBracketChar = /[\[\]{}()]/;
53
+
54
+ var unsignedNumber = /\d[0-9_]*/;
55
+ var decimalLiteral = /\d*\s*'s?d\s*\d[0-9_]*/i;
56
+ var binaryLiteral = /\d*\s*'s?b\s*[xz01][xz01_]*/i;
57
+ var octLiteral = /\d*\s*'s?o\s*[xz0-7][xz0-7_]*/i;
58
+ var hexLiteral = /\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i;
59
+ var realLiteral = /(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i;
60
+
61
+ var closingBracketOrWord = /^((\w+)|[)}\]])/;
62
+ var closingBracket = /[)}\]]/;
9
63
 
10
64
  var curPunc;
65
+ var curKeyword;
66
+
67
+ // Block openings which are closed by a matching keyword in the form of ("end" + keyword)
68
+ // E.g. "task" => "endtask"
69
+ var blockKeywords = words(
70
+ "case checker class clocking config function generate group interface module package" +
71
+ "primitive program property specify sequence table task"
72
+ );
73
+
74
+ // Opening/closing pairs
75
+ var openClose = {};
76
+ for (var keyword in blockKeywords) {
77
+ openClose[keyword] = "end" + keyword;
78
+ }
79
+ openClose["begin"] = "end";
80
+ openClose["casex"] = "endcase";
81
+ openClose["casez"] = "endcase";
82
+ openClose["do" ] = "while";
83
+ openClose["fork" ] = "join;join_any;join_none";
84
+
85
+ for (var i in noIndentKeywords) {
86
+ var keyword = noIndentKeywords[i];
87
+ if (openClose[keyword]) {
88
+ openClose[keyword] = undefined;
89
+ }
90
+ }
91
+
92
+ var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else for foreach forever if initial repeat while");
11
93
 
12
94
  function tokenBase(stream, state) {
13
- var ch = stream.next();
14
- if (hooks[ch]) {
15
- var result = hooks[ch](stream, state);
16
- if (result !== false) return result;
95
+ var ch = stream.peek();
96
+ if (/[,;:\.]/.test(ch)) {
97
+ curPunc = stream.next();
98
+ return null;
99
+ }
100
+ if (isBracketChar.test(ch)) {
101
+ curPunc = stream.next();
102
+ return "bracket";
103
+ }
104
+ // Macros (tick-defines)
105
+ if (ch == '`') {
106
+ stream.next();
107
+ if (stream.eatWhile(/[\w\$_]/)) {
108
+ return "def";
109
+ } else {
110
+ return null;
111
+ }
112
+ }
113
+ // System calls
114
+ if (ch == '$') {
115
+ stream.next();
116
+ if (stream.eatWhile(/[\w\$_]/)) {
117
+ return "meta";
118
+ } else {
119
+ return null;
120
+ }
17
121
  }
122
+ // Time literals
123
+ if (ch == '#') {
124
+ stream.next();
125
+ stream.eatWhile(/[\d_.]/);
126
+ return "def";
127
+ }
128
+ // Strings
18
129
  if (ch == '"') {
130
+ stream.next();
19
131
  state.tokenize = tokenString(ch);
20
132
  return state.tokenize(stream, state);
21
133
  }
22
- if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
- curPunc = ch;
24
- return null;
25
- }
26
- if (/[\d']/.test(ch)) {
27
- stream.eatWhile(/[\w\.']/);
28
- return "number";
29
- }
134
+ // Comments
30
135
  if (ch == "/") {
136
+ stream.next();
31
137
  if (stream.eat("*")) {
32
138
  state.tokenize = tokenComment;
33
139
  return tokenComment(stream, state);
@@ -36,19 +142,43 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
36
142
  stream.skipToEnd();
37
143
  return "comment";
38
144
  }
145
+ stream.backUp(1);
146
+ }
147
+
148
+ // Numeric literals
149
+ if (stream.match(realLiteral) ||
150
+ stream.match(decimalLiteral) ||
151
+ stream.match(binaryLiteral) ||
152
+ stream.match(octLiteral) ||
153
+ stream.match(hexLiteral) ||
154
+ stream.match(unsignedNumber) ||
155
+ stream.match(realLiteral)) {
156
+ return "number";
39
157
  }
40
- if (isOperatorChar.test(ch)) {
41
- stream.eatWhile(isOperatorChar);
42
- return "operator";
158
+
159
+ // Operators
160
+ if (stream.eatWhile(isOperatorChar)) {
161
+ return "meta";
43
162
  }
44
- stream.eatWhile(/[\w\$_]/);
45
- var cur = stream.current();
46
- if (keywords.propertyIsEnumerable(cur)) {
47
- if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
48
- return "keyword";
163
+
164
+ // Keywords / plain variables
165
+ if (stream.eatWhile(/[\w\$_]/)) {
166
+ var cur = stream.current();
167
+ if (keywords[cur]) {
168
+ if (openClose[cur]) {
169
+ curPunc = "newblock";
170
+ }
171
+ if (statementKeywords[cur]) {
172
+ curPunc = "newstatement";
173
+ }
174
+ curKeyword = cur;
175
+ return "keyword";
176
+ }
177
+ return "variable";
49
178
  }
50
- if (atoms.propertyIsEnumerable(cur)) return "atom";
51
- return "variable";
179
+
180
+ stream.next();
181
+ return null;
52
182
  }
53
183
 
54
184
  function tokenString(quote) {
@@ -84,18 +214,56 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
84
214
  this.prev = prev;
85
215
  }
86
216
  function pushContext(state, col, type) {
87
- return state.context = new Context(state.indented, col, type, null, state.context);
217
+ var indent = state.indented;
218
+ var c = new Context(indent, col, type, null, state.context);
219
+ return state.context = c;
88
220
  }
89
221
  function popContext(state) {
90
222
  var t = state.context.type;
91
- if (t == ")" || t == "]" || t == "}")
223
+ if (t == ")" || t == "]" || t == "}") {
92
224
  state.indented = state.context.indented;
225
+ }
93
226
  return state.context = state.context.prev;
94
227
  }
95
228
 
96
- // Interface
229
+ function isClosing(text, contextClosing) {
230
+ if (text == contextClosing) {
231
+ return true;
232
+ } else {
233
+ // contextClosing may be mulitple keywords separated by ;
234
+ var closingKeywords = contextClosing.split(";");
235
+ for (var i in closingKeywords) {
236
+ if (text == closingKeywords[i]) {
237
+ return true;
238
+ }
239
+ }
240
+ return false;
241
+ }
242
+ }
243
+
244
+ function buildElectricInputRegEx() {
245
+ // Reindentation should occur on any bracket char: {}()[]
246
+ // or on a match of any of the block closing keywords, at
247
+ // the end of a line
248
+ var allClosings = [];
249
+ for (var i in openClose) {
250
+ if (openClose[i]) {
251
+ var closings = openClose[i].split(";");
252
+ for (var j in closings) {
253
+ allClosings.push(closings[j]);
254
+ }
255
+ }
256
+ }
257
+ var re = new RegExp("[{}()\\[\\]]|(" + allClosings.join("|") + ")$");
258
+ return re;
259
+ }
97
260
 
261
+ // Interface
98
262
  return {
263
+
264
+ // Regex to force current line to reindent
265
+ electricInput: buildElectricInputRegEx(),
266
+
99
267
  startState: function(basecolumn) {
100
268
  return {
101
269
  tokenize: null,
@@ -114,69 +282,58 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
114
282
  }
115
283
  if (stream.eatSpace()) return null;
116
284
  curPunc = null;
285
+ curKeyword = null;
117
286
  var style = (state.tokenize || tokenBase)(stream, state);
118
- if (style == "comment" || style == "meta") return style;
287
+ if (style == "comment" || style == "meta" || style == "variable") return style;
119
288
  if (ctx.align == null) ctx.align = true;
120
289
 
121
- if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
122
- else if (curPunc == "{") pushContext(state, stream.column(), "}");
123
- else if (curPunc == "[") pushContext(state, stream.column(), "]");
124
- else if (curPunc == "(") pushContext(state, stream.column(), ")");
125
- else if (curPunc == "}") {
126
- while (ctx.type == "statement") ctx = popContext(state);
127
- if (ctx.type == "}") ctx = popContext(state);
128
- while (ctx.type == "statement") ctx = popContext(state);
290
+ if (curPunc == ctx.type) {
291
+ popContext(state);
292
+ }
293
+ else if ((curPunc == ";" && ctx.type == "statement") ||
294
+ (ctx.type && isClosing(curKeyword, ctx.type))) {
295
+ ctx = popContext(state);
296
+ while (ctx && ctx.type == "statement") ctx = popContext(state);
129
297
  }
130
- else if (curPunc == ctx.type) popContext(state);
131
- else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
298
+ else if (curPunc == "{") { pushContext(state, stream.column(), "}"); }
299
+ else if (curPunc == "[") { pushContext(state, stream.column(), "]"); }
300
+ else if (curPunc == "(") { pushContext(state, stream.column(), ")"); }
301
+ else if (ctx && ctx.type == "endcase" && curPunc == ":") { pushContext(state, stream.column(), "statement"); }
302
+ else if (curPunc == "newstatement") {
132
303
  pushContext(state, stream.column(), "statement");
304
+ } else if (curPunc == "newblock") {
305
+ var close = openClose[curKeyword];
306
+ pushContext(state, stream.column(), close);
307
+ }
308
+
133
309
  state.startOfLine = false;
134
310
  return style;
135
311
  },
136
312
 
137
313
  indent: function(state, textAfter) {
138
- if (state.tokenize != tokenBase && state.tokenize != null) return 0;
139
- var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
140
- if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
141
- else if (ctx.align) return ctx.column + (closing ? 0 : 1);
314
+ if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
315
+ var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
316
+ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
317
+ var closing = false;
318
+ var possibleClosing = textAfter.match(closingBracketOrWord);
319
+ if (possibleClosing) {
320
+ closing = isClosing(possibleClosing[0], ctx.type);
321
+ }
322
+ if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
323
+ else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1);
324
+ else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
142
325
  else return ctx.indented + (closing ? 0 : indentUnit);
143
326
  },
144
327
 
145
- electricChars: "{}"
328
+ blockCommentStart: "/*",
329
+ blockCommentEnd: "*/",
330
+ lineComment: "//"
146
331
  };
147
332
  });
148
333
 
149
- (function() {
150
- function words(str) {
151
- var obj = {}, words = str.split(" ");
152
- for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
153
- return obj;
154
- }
155
-
156
- var verilogKeywords = "always and assign automatic begin buf bufif0 bufif1 case casex casez cell cmos config " +
157
- "deassign default defparam design disable edge else end endcase endconfig endfunction endgenerate endmodule " +
158
- "endprimitive endspecify endtable endtask event for force forever fork function generate genvar highz0 " +
159
- "highz1 if ifnone incdir include initial inout input instance integer join large liblist library localparam " +
160
- "macromodule medium module nand negedge nmos nor noshowcancelled not notif0 notif1 or output parameter pmos " +
161
- "posedge primitive pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect rcmos real realtime " +
162
- "reg release repeat rnmos rpmos rtran rtranif0 rtranif1 scalared showcancelled signed small specify specparam " +
163
- "strong0 strong1 supply0 supply1 table task time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg " +
164
- "unsigned use vectored wait wand weak0 weak1 while wire wor xnor xor";
165
-
166
- var verilogBlockKeywords = "begin bufif0 bufif1 case casex casez config else end endcase endconfig endfunction " +
167
- "endgenerate endmodule endprimitive endspecify endtable endtask for forever function generate if ifnone " +
168
- "macromodule module primitive repeat specify table task while";
169
-
170
- function metaHook(stream) {
171
- stream.eatWhile(/[\w\$_]/);
172
- return "meta";
173
- }
174
-
175
- CodeMirror.defineMIME("text/x-verilog", {
176
- name: "verilog",
177
- keywords: words(verilogKeywords),
178
- blockKeywords: words(verilogBlockKeywords),
179
- atoms: words("null"),
180
- hooks: {"`": metaHook, "$": metaHook}
181
- });
182
- }());
334
+ CodeMirror.defineMIME("text/x-verilog", {
335
+ name: "verilog"
336
+ });
337
+ CodeMirror.defineMIME("text/x-systemverilog", {
338
+ name: "systemverilog"
339
+ });
@@ -310,7 +310,10 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
310
310
  var context = state.context;
311
311
  // Indent multi-line strings (e.g. css).
312
312
  if (state.tokenize.isInAttribute) {
313
- return state.stringStartCol + 1;
313
+ if (state.tagStart == state.indented)
314
+ return state.stringStartCol + 1;
315
+ else
316
+ return state.indented + indentUnit;
314
317
  }
315
318
  if (context && context.noIndent) return CodeMirror.Pass;
316
319
  if (state.tokenize != inTag && state.tokenize != inText)
@@ -72,11 +72,12 @@
72
72
  .cm-s-default .cm-atom {color: #219;}
73
73
  .cm-s-default .cm-number {color: #164;}
74
74
  .cm-s-default .cm-def {color: #00f;}
75
- .cm-s-default .cm-variable {color: black;}
75
+ .cm-s-default .cm-variable,
76
+ .cm-s-default .cm-punctuation,
77
+ .cm-s-default .cm-property,
78
+ .cm-s-default .cm-operator {}
76
79
  .cm-s-default .cm-variable-2 {color: #05a;}
77
80
  .cm-s-default .cm-variable-3 {color: #085;}
78
- .cm-s-default .cm-property {color: black;}
79
- .cm-s-default .cm-operator {color: black;}
80
81
  .cm-s-default .cm-comment {color: #a50;}
81
82
  .cm-s-default .cm-string {color: #a11;}
82
83
  .cm-s-default .cm-string-2 {color: #f50;}
@@ -41,7 +41,6 @@
41
41
 
42
42
  .cm-s-ambiance.CodeMirror {
43
43
  line-height: 1.40em;
44
- font-family: Monaco, Menlo,"Andale Mono","lucida console","Courier New",monospace !important;
45
44
  color: #E6E1DC;
46
45
  background-color: #202020;
47
46
  -webkit-box-shadow: inset 0 0 10px black;
@@ -5,10 +5,6 @@ Ported to CodeMirror by Peter Kroon
5
5
  .cm-s-lesser-dark {
6
6
  line-height: 1.3em;
7
7
  }
8
- .cm-s-lesser-dark {
9
- font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Monaco', Courier, monospace !important;
10
- }
11
-
12
8
  .cm-s-lesser-dark.CodeMirror { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
13
9
  .cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
14
10
  .cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
@@ -7,7 +7,7 @@
7
7
  The mdn-like theme is inspired on the displayed code examples at: https://developer.mozilla.org/en-US/docs/Web/CSS/animation
8
8
 
9
9
  */
10
- .cm-s-mdn-like.CodeMirror { color: #999; font-family: monospace; background-color: #fff; }
10
+ .cm-s-mdn-like.CodeMirror { color: #999; background-color: #fff; }
11
11
  .cm-s-mdn-like .CodeMirror-selected { background: #cfc !important; }
12
12
 
13
13
  .cm-s-mdn-like .CodeMirror-gutters { background: #f8f8f8; border-left: 6px solid rgba(0,83,159,0.65); color: #333; }
@@ -11,7 +11,6 @@
11
11
  background: #2c2827;
12
12
  color: #8F938F;
13
13
  line-height: 1.5;
14
- font-family: consolas, Courier, monospace;
15
14
  font-size: 14px;
16
15
  }
17
16
  .cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2) !important; }
@@ -1,5 +1,3 @@
1
- .cm-s-rubyblue { font-family: Trebuchet, Verdana, sans-serif; } /* - customized editor font - */
2
-
3
1
  .cm-s-rubyblue.CodeMirror { background: #112435; color: white; }
4
2
  .cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
5
3
  .cm-s-rubyblue .CodeMirror-gutters { background: #1F4661; border-right: 7px solid #3E7087; }