codemirror-rails 2.36 → 3.00

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,4 +1,4 @@
1
- CodeMirror.defineMode("changes", function(config, modeConfig) {
1
+ CodeMirror.defineMode("changes", function() {
2
2
  var headerSeperator = /^-+$/;
3
3
  var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
4
4
  var simpleEmail = /^[\w+.-]+@[\w.-]+/;
@@ -1,6 +1,6 @@
1
1
  // Quick and dirty spec file highlighting
2
2
 
3
- CodeMirror.defineMode("spec", function(config, modeConfig) {
3
+ CodeMirror.defineMode("spec", function() {
4
4
  var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
5
5
 
6
6
  var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/;
@@ -18,17 +18,7 @@ CodeMirror.defineMode('rst', function(config, options) {
18
18
  }
19
19
 
20
20
  function hasMode(mode) {
21
- if (mode) {
22
- var modes = CodeMirror.listModes();
23
-
24
- for (var i in modes) {
25
- if (modes[i] == mode) {
26
- return true;
27
- }
28
- }
29
- }
30
-
31
- return false;
21
+ return mode && CodeMirror.modes.hasOwnProperty(mode);
32
22
  }
33
23
 
34
24
  function getMode(mode) {
@@ -53,8 +43,6 @@ CodeMirror.defineMode('rst', function(config, options) {
53
43
  var reVerbatimMarker = /^::\s*$/;
54
44
  var rePreInline = /^[-\s"([{</:]/;
55
45
  var rePostInline = /^[-\s`'")\]}>/:.,;!?\\_]/;
56
- var reEnumeratedList = /^\s*((\d+|[A-Za-z#])[.)]|\((\d+|[A-Z-a-z#])\))\s/;
57
- var reBulletedList = /^\s*[-\+\*]\s/;
58
46
  var reExamples = /^\s+(>>>|In \[\d+\]:)\s/;
59
47
 
60
48
  function normal(stream, state) {
@@ -1,4 +1,4 @@
1
- CodeMirror.defineMode("ruby", function(config, parserConfig) {
1
+ CodeMirror.defineMode("ruby", function(config) {
2
2
  function wordObj(words) {
3
3
  var o = {};
4
4
  for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
@@ -209,7 +209,7 @@ CodeMirror.defineMode("rust", function() {
209
209
  if (type == "(" || type == "[") return matchBrackets(type, expression);
210
210
  return pass();
211
211
  }
212
- function maybeprop(type) {
212
+ function maybeprop() {
213
213
  if (content.match(/^\w+$/)) {cx.marked = "variable"; return cont(maybeop);}
214
214
  return pass(expression);
215
215
  }
@@ -304,7 +304,7 @@ CodeMirror.defineMode("rust", function() {
304
304
  if (type == "{") return cont(pushlex("}"), block, poplex);
305
305
  return pass();
306
306
  }
307
- function typarams(type) {
307
+ function typarams() {
308
308
  if (content == ">") return cont();
309
309
  if (content == ",") return cont(typarams);
310
310
  if (content == ":") return cont(rtype, typarams);
@@ -324,7 +324,7 @@ CodeMirror.defineMode("rust", function() {
324
324
  if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex);
325
325
  return matchBrackets(type, rtype);
326
326
  }
327
- function rtypemaybeparam(type) {
327
+ function rtypemaybeparam() {
328
328
  if (content == "<") return cont(typarams);
329
329
  return pass();
330
330
  }
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Author: Koh Zi Han, based on implementation by Koh Zi Chun
3
3
  */
4
- CodeMirror.defineMode("scheme", function (config, mode) {
4
+ CodeMirror.defineMode("scheme", function () {
5
5
  var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
6
- ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
7
- var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
6
+ ATOM = "atom", NUMBER = "number", BRACKET = "bracket";
7
+ var INDENT_WORD_SKIP = 2;
8
8
 
9
9
  function makeKeywords(str) {
10
10
  var obj = {}, words = str.split(" ");
@@ -220,7 +220,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
220
220
  return (typeof state.sExprComment == "number") ? COMMENT : returnType;
221
221
  },
222
222
 
223
- indent: function (state, textAfter) {
223
+ indent: function (state) {
224
224
  if (state.indentStack == null) return state.indentation;
225
225
  return state.indentStack.indent;
226
226
  }
@@ -1,4 +1,4 @@
1
- CodeMirror.defineMode('shell', function(config) {
1
+ CodeMirror.defineMode('shell', function() {
2
2
 
3
3
  var words = {};
4
4
  function define(style, string) {
@@ -145,7 +145,7 @@ CodeMirror.defineMode("sieve", function(config) {
145
145
  return (state.tokenize || tokenBase)(stream, state);;
146
146
  },
147
147
 
148
- indent: function(state, textAfter) {
148
+ indent: function(state, _textAfter) {
149
149
  return state.baseIndent + state._indent * indentUnit;
150
150
  },
151
151
 
@@ -1,4 +1,4 @@
1
- CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
1
+ CodeMirror.defineMode('smalltalk', function(config) {
2
2
 
3
3
  var specialChars = /[+\-/\\*~<>=@%|&?!.:;^]/;
4
4
  var keywords = /true|false|nil|self|super|thisContext/;
@@ -86,7 +86,7 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
86
86
  return new Token('string', stream.eat('\'') ? context.parent : context, false);
87
87
  };
88
88
 
89
- var nextTemporaries = function(stream, context, state) {
89
+ var nextTemporaries = function(stream, context) {
90
90
  var token = new Token(null, context, false);
91
91
  var aChar = stream.next();
92
92
 
@@ -1,4 +1,4 @@
1
- CodeMirror.defineMode("smarty", function(config, parserConfig) {
1
+ CodeMirror.defineMode("smarty", function(config) {
2
2
  var keyFuncs = ["debug", "extends", "function", "include", "literal"];
3
3
  var last;
4
4
  var regs = {
@@ -49,7 +49,7 @@ CodeMirror.defineMode("sparql", function(config) {
49
49
  stream.eatWhile(/[\w\d_\-]/);
50
50
  return "atom";
51
51
  }
52
- var word = stream.current(), type;
52
+ var word = stream.current();
53
53
  if (ops.test(word))
54
54
  return null;
55
55
  else if (keywords.test(word))
@@ -82,7 +82,7 @@ CodeMirror.defineMode("sparql", function(config) {
82
82
  }
83
83
 
84
84
  return {
85
- startState: function(base) {
85
+ startState: function() {
86
86
  return {tokenize: tokenBase,
87
87
  context: null,
88
88
  indent: 0,
@@ -3,7 +3,7 @@
3
3
  * Licence: MIT
4
4
  */
5
5
 
6
- CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
6
+ CodeMirror.defineMode("stex", function()
7
7
  {
8
8
  function pushCommand(state, command) {
9
9
  state.cmdState.push(command);
@@ -42,18 +42,17 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
42
42
  this.styles = styles;
43
43
  this.brackets = brackets;
44
44
 
45
- this.styleIdentifier = function(content) {
45
+ this.styleIdentifier = function() {
46
46
  if (this.bracketNo<=this.styles.length)
47
47
  return this.styles[this.bracketNo-1];
48
48
  else
49
49
  return null;
50
50
  };
51
- this.openBracket = function(content) {
51
+ this.openBracket = function() {
52
52
  this.bracketNo++;
53
53
  return "bracket";
54
54
  };
55
- this.closeBracket = function(content) {
56
- };
55
+ this.closeBracket = function() {};
57
56
  };
58
57
  }
59
58
 
@@ -69,12 +68,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
69
68
  this.name="DEFAULT";
70
69
  this.style="tag";
71
70
 
72
- this.styleIdentifier = function(content) {
73
- };
74
- this.openBracket = function(content) {
75
- };
76
- this.closeBracket = function(content) {
77
- };
71
+ this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
78
72
  };
79
73
 
80
74
  function setState(state, f) {
@@ -149,7 +143,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
149
143
  var ch = source.peek();
150
144
  if (ch == '{' || ch == '[') {
151
145
  var lastPlug = peekCommand(state);
152
- var style = lastPlug.openBracket(ch);
146
+ lastPlug.openBracket(ch);
153
147
  source.eat(ch);
154
148
  setState(state, normal);
155
149
  return "bracket";
@@ -172,7 +166,6 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
172
166
 
173
167
  token: function(stream, state) {
174
168
  var t = state.f(stream, state);
175
- var w = stream.current();
176
169
  return t;
177
170
  }
178
171
  };
@@ -14,19 +14,9 @@
14
14
  CoreVersion parameter is needed for TiddlyWiki only!
15
15
  ***/
16
16
  //{{{
17
- CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
18
- var indentUnit = config.indentUnit;
19
-
17
+ CodeMirror.defineMode("tiddlywiki", function () {
20
18
  // Tokenizer
21
- var textwords = function () {
22
- function kw(type) {
23
- return {
24
- type: type,
25
- style: "text"
26
- };
27
- }
28
- return {};
29
- }();
19
+ var textwords = {};
30
20
 
31
21
  var keywords = function () {
32
22
  function kw(type) {
@@ -60,7 +50,6 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
60
50
  reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
61
51
  reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
62
52
 
63
- reCodeStart = /\{\{\{/, // {{{ code span start
64
53
  reUntilCodeStop = /.*?\}\}\}/;
65
54
 
66
55
  function chain(stream, state, f) {
@@ -68,17 +57,6 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
68
57
  return f(stream, state);
69
58
  }
70
59
 
71
- // used for strings
72
- function nextUntilUnescaped(stream, end) {
73
- var escaped = false,
74
- next;
75
- while ((next = stream.next()) != null) {
76
- if (next == end && !escaped) return false;
77
- escaped = !escaped && next == "\\";
78
- }
79
- return escaped;
80
- }
81
-
82
60
  // Used as scratch variables to communicate multiple values without
83
61
  // consing up tons of objects.
84
62
  var type, content;
@@ -90,8 +68,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
90
68
  }
91
69
 
92
70
  function jsTokenBase(stream, state) {
93
- var sol = stream.sol(),
94
- ch, tch;
71
+ var sol = stream.sol(), ch;
95
72
 
96
73
  state.block = false; // indicates the start of a code block.
97
74
 
@@ -226,13 +203,6 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
226
203
 
227
204
  } // jsTokenBase()
228
205
 
229
- function twTokenString(quote) {
230
- return function (stream, state) {
231
- if (!nextUntilUnescaped(stream, quote)) state.tokenize = jsTokenBase;
232
- return ret("string", "string");
233
- };
234
- }
235
-
236
206
  // tw invisible comment
237
207
  function twTokenComment(stream, state) {
238
208
  var maybeEnd = false,
@@ -314,8 +284,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
314
284
  // tw strike through text looks ugly
315
285
  // change CSS if needed
316
286
  function twTokenStrike(stream, state) {
317
- var maybeEnd = false,
318
- ch, nr;
287
+ var maybeEnd = false, ch;
319
288
 
320
289
  while (ch = stream.next()) {
321
290
  if (ch == "-" && maybeEnd) {
@@ -329,7 +298,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
329
298
 
330
299
  // macro
331
300
  function twTokenMacro(stream, state) {
332
- var ch, tmp, word, known;
301
+ var ch, word, known;
333
302
 
334
303
  if (stream.current() == '<<') {
335
304
  return ret('brace', 'macro');
@@ -362,7 +331,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
362
331
 
363
332
  // Interface
364
333
  return {
365
- startState: function (basecolumn) {
334
+ startState: function () {
366
335
  return {
367
336
  tokenize: jsTokenBase,
368
337
  indented: 0,
@@ -1,4 +1,4 @@
1
- CodeMirror.defineMode('tiki', function(config, parserConfig) {
1
+ CodeMirror.defineMode('tiki', function(config) {
2
2
  function inBlock(style, terminator, returnTokenizer) {
3
3
  return function(stream, state) {
4
4
  while (!stream.eol()) {
@@ -15,7 +15,7 @@ CodeMirror.defineMode('tiki', function(config, parserConfig) {
15
15
  };
16
16
  }
17
17
 
18
- function inLine(style, terminator) {
18
+ function inLine(style) {
19
19
  return function(stream, state) {
20
20
  while(!stream.eol()) {
21
21
  stream.next();
@@ -37,7 +37,7 @@ CodeMirror.defineMode('tiki', function(config, parserConfig) {
37
37
  //non start of line
38
38
  switch (ch) { //switch is generally much faster than if, so it is used here
39
39
  case "{": //plugin
40
- var type = stream.eat("/") ? "closeTag" : "openTag";
40
+ stream.eat("/");
41
41
  stream.eatSpace();
42
42
  var tagName = "";
43
43
  var c;
@@ -37,11 +37,11 @@ CodeMirror.defineMode("vb", function(conf, parserConf) {
37
37
 
38
38
 
39
39
 
40
- function indent(stream, state) {
40
+ function indent(_stream, state) {
41
41
  state.currentIndent++;
42
42
  }
43
43
 
44
- function dedent(stream, state) {
44
+ function dedent(_stream, state) {
45
45
  state.currentIndent--;
46
46
  }
47
47
  // tokenizers
@@ -218,7 +218,7 @@ CodeMirror.defineMode("vb", function(conf, parserConf) {
218
218
 
219
219
  var external = {
220
220
  electricChars:"dDpPtTfFeE ",
221
- startState: function(basecolumn) {
221
+ startState: function() {
222
222
  return {
223
223
  tokenize: tokenBase,
224
224
  lastToken: null,
@@ -1,18 +1,16 @@
1
- CodeMirror.defineMode("velocity", function(config) {
1
+ CodeMirror.defineMode("velocity", function() {
2
2
  function parseWords(str) {
3
3
  var obj = {}, words = str.split(" ");
4
4
  for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
5
5
  return obj;
6
6
  }
7
7
 
8
- var indentUnit = config.indentUnit;
9
8
  var keywords = parseWords("#end #else #break #stop #[[ #]] " +
10
9
  "#{end} #{else} #{break} #{stop}");
11
10
  var functions = parseWords("#if #elseif #foreach #set #include #parse #macro #define #evaluate " +
12
11
  "#{if} #{elseif} #{foreach} #{set} #{include} #{parse} #{macro} #{define} #{evaluate}");
13
12
  var specials = parseWords("$foreach.count $foreach.hasNext $foreach.first $foreach.last $foreach.topmost $foreach.parent $velocityCount");
14
13
  var isOperatorChar = /[+\-*&%=<>!?:\/|]/;
15
- var multiLineStrings =true;
16
14
 
17
15
  function chain(stream, state, f) {
18
16
  state.tokenize = f;
@@ -128,7 +126,7 @@ CodeMirror.defineMode("velocity", function(config) {
128
126
  // Interface
129
127
 
130
128
  return {
131
- startState: function(basecolumn) {
129
+ startState: function() {
132
130
  return {
133
131
  tokenize: tokenBase,
134
132
  beforeParams: false,
@@ -1,194 +1,182 @@
1
- CodeMirror.defineMode("verilog", function(config, parserConfig) {
2
- var indentUnit = config.indentUnit,
3
- keywords = parserConfig.keywords || {},
4
- blockKeywords = parserConfig.blockKeywords || {},
5
- atoms = parserConfig.atoms || {},
6
- hooks = parserConfig.hooks || {},
7
- multiLineStrings = parserConfig.multiLineStrings;
8
- var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
9
-
10
- var curPunc;
11
-
12
- 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;
17
- }
18
- if (ch == '"') {
19
- state.tokenize = tokenString(ch);
20
- return state.tokenize(stream, state);
21
- }
22
- if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
- curPunc = ch;
24
- return null;
25
- }
26
- if (/[\d']/.test(ch)) {
27
- stream.eatWhile(/[\w\.']/);
28
- return "number";
29
- }
30
- if (ch == "/") {
31
- if (stream.eat("*")) {
32
- state.tokenize = tokenComment;
33
- return tokenComment(stream, state);
34
- }
35
- if (stream.eat("/")) {
36
- stream.skipToEnd();
37
- return "comment";
38
- }
39
- }
40
- if (isOperatorChar.test(ch)) {
41
- stream.eatWhile(isOperatorChar);
42
- return "operator";
43
- }
44
- stream.eatWhile(/[\w\$_]/);
45
- var cur = stream.current();
46
- if (keywords.propertyIsEnumerable(cur)) {
47
- if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
48
- return "keyword";
49
- }
50
- if (atoms.propertyIsEnumerable(cur)) return "atom";
51
- return "variable";
52
- }
53
-
54
- function tokenString(quote) {
55
- return function(stream, state) {
56
- var escaped = false, next, end = false;
57
- while ((next = stream.next()) != null) {
58
- if (next == quote && !escaped) {end = true; break;}
59
- escaped = !escaped && next == "\\";
60
- }
61
- if (end || !(escaped || multiLineStrings))
62
- state.tokenize = tokenBase;
63
- return "string";
64
- };
65
- }
66
-
67
- function tokenComment(stream, state) {
68
- var maybeEnd = false, ch;
69
- while (ch = stream.next()) {
70
- if (ch == "/" && maybeEnd) {
71
- state.tokenize = tokenBase;
72
- break;
73
- }
74
- maybeEnd = (ch == "*");
75
- }
76
- return "comment";
77
- }
78
-
79
- function Context(indented, column, type, align, prev) {
80
- this.indented = indented;
81
- this.column = column;
82
- this.type = type;
83
- this.align = align;
84
- this.prev = prev;
85
- }
86
- function pushContext(state, col, type) {
87
- return state.context = new Context(state.indented, col, type, null, state.context);
88
- }
89
- function popContext(state) {
90
- var t = state.context.type;
91
- if (t == ")" || t == "]" || t == "}")
92
- state.indented = state.context.indented;
93
- return state.context = state.context.prev;
94
- }
95
-
96
- // Interface
97
-
98
- return {
99
- startState: function(basecolumn) {
100
- return {
101
- tokenize: null,
102
- context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
103
- indented: 0,
104
- startOfLine: true
105
- };
106
- },
107
-
108
- token: function(stream, state) {
109
- var ctx = state.context;
110
- if (stream.sol()) {
111
- if (ctx.align == null) ctx.align = false;
112
- state.indented = stream.indentation();
113
- state.startOfLine = true;
114
- }
115
- if (stream.eatSpace()) return null;
116
- curPunc = null;
117
- var style = (state.tokenize || tokenBase)(stream, state);
118
- if (style == "comment" || style == "meta") return style;
119
- if (ctx.align == null) ctx.align = true;
120
-
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);
129
- }
130
- else if (curPunc == ctx.type) popContext(state);
131
- else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
132
- pushContext(state, stream.column(), "statement");
133
- state.startOfLine = false;
134
- return style;
135
- },
136
-
137
- 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);
142
- else return ctx.indented + (closing ? 0 : indentUnit);
143
- },
144
-
145
- electricChars: "{}"
146
- };
147
- });
148
-
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, state) {
171
- stream.eatWhile(/[\w\$_]/);
172
- return "meta";
173
- }
174
-
175
- // C#-style strings where "" escapes a quote.
176
- function tokenAtString(stream, state) {
177
- var next;
178
- while ((next = stream.next()) != null) {
179
- if (next == '"' && !stream.eat('"')) {
180
- state.tokenize = null;
181
- break;
182
- }
183
- }
184
- return "string";
185
- }
186
-
187
- CodeMirror.defineMIME("text/x-verilog", {
188
- name: "verilog",
189
- keywords: words(verilogKeywords),
190
- blockKeywords: words(verilogBlockKeywords),
191
- atoms: words("null"),
192
- hooks: {"`": metaHook, "$": metaHook}
193
- });
194
- }());
1
+ CodeMirror.defineMode("verilog", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit,
3
+ keywords = parserConfig.keywords || {},
4
+ blockKeywords = parserConfig.blockKeywords || {},
5
+ atoms = parserConfig.atoms || {},
6
+ hooks = parserConfig.hooks || {},
7
+ multiLineStrings = parserConfig.multiLineStrings;
8
+ var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
9
+
10
+ var curPunc;
11
+
12
+ 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;
17
+ }
18
+ if (ch == '"') {
19
+ state.tokenize = tokenString(ch);
20
+ return state.tokenize(stream, state);
21
+ }
22
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
+ curPunc = ch;
24
+ return null;
25
+ }
26
+ if (/[\d']/.test(ch)) {
27
+ stream.eatWhile(/[\w\.']/);
28
+ return "number";
29
+ }
30
+ if (ch == "/") {
31
+ if (stream.eat("*")) {
32
+ state.tokenize = tokenComment;
33
+ return tokenComment(stream, state);
34
+ }
35
+ if (stream.eat("/")) {
36
+ stream.skipToEnd();
37
+ return "comment";
38
+ }
39
+ }
40
+ if (isOperatorChar.test(ch)) {
41
+ stream.eatWhile(isOperatorChar);
42
+ return "operator";
43
+ }
44
+ stream.eatWhile(/[\w\$_]/);
45
+ var cur = stream.current();
46
+ if (keywords.propertyIsEnumerable(cur)) {
47
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
48
+ return "keyword";
49
+ }
50
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
51
+ return "variable";
52
+ }
53
+
54
+ function tokenString(quote) {
55
+ return function(stream, state) {
56
+ var escaped = false, next, end = false;
57
+ while ((next = stream.next()) != null) {
58
+ if (next == quote && !escaped) {end = true; break;}
59
+ escaped = !escaped && next == "\\";
60
+ }
61
+ if (end || !(escaped || multiLineStrings))
62
+ state.tokenize = tokenBase;
63
+ return "string";
64
+ };
65
+ }
66
+
67
+ function tokenComment(stream, state) {
68
+ var maybeEnd = false, ch;
69
+ while (ch = stream.next()) {
70
+ if (ch == "/" && maybeEnd) {
71
+ state.tokenize = tokenBase;
72
+ break;
73
+ }
74
+ maybeEnd = (ch == "*");
75
+ }
76
+ return "comment";
77
+ }
78
+
79
+ function Context(indented, column, type, align, prev) {
80
+ this.indented = indented;
81
+ this.column = column;
82
+ this.type = type;
83
+ this.align = align;
84
+ this.prev = prev;
85
+ }
86
+ function pushContext(state, col, type) {
87
+ return state.context = new Context(state.indented, col, type, null, state.context);
88
+ }
89
+ function popContext(state) {
90
+ var t = state.context.type;
91
+ if (t == ")" || t == "]" || t == "}")
92
+ state.indented = state.context.indented;
93
+ return state.context = state.context.prev;
94
+ }
95
+
96
+ // Interface
97
+
98
+ return {
99
+ startState: function(basecolumn) {
100
+ return {
101
+ tokenize: null,
102
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
103
+ indented: 0,
104
+ startOfLine: true
105
+ };
106
+ },
107
+
108
+ token: function(stream, state) {
109
+ var ctx = state.context;
110
+ if (stream.sol()) {
111
+ if (ctx.align == null) ctx.align = false;
112
+ state.indented = stream.indentation();
113
+ state.startOfLine = true;
114
+ }
115
+ if (stream.eatSpace()) return null;
116
+ curPunc = null;
117
+ var style = (state.tokenize || tokenBase)(stream, state);
118
+ if (style == "comment" || style == "meta") return style;
119
+ if (ctx.align == null) ctx.align = true;
120
+
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);
129
+ }
130
+ else if (curPunc == ctx.type) popContext(state);
131
+ else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
132
+ pushContext(state, stream.column(), "statement");
133
+ state.startOfLine = false;
134
+ return style;
135
+ },
136
+
137
+ 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);
142
+ else return ctx.indented + (closing ? 0 : indentUnit);
143
+ },
144
+
145
+ electricChars: "{}"
146
+ };
147
+ });
148
+
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
+ }());