codemirror-rails 2.32 → 2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/codemirror-rails.gemspec +1 -1
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +355 -349
  4. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +6 -5
  5. data/vendor/assets/javascripts/codemirror/modes/clike.js +6 -2
  6. data/vendor/assets/javascripts/codemirror/modes/clojure.js +1 -1
  7. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +3 -3
  8. data/vendor/assets/javascripts/codemirror/modes/css.js +52 -2
  9. data/vendor/assets/javascripts/codemirror/modes/ecl.js +1 -1
  10. data/vendor/assets/javascripts/codemirror/modes/gfm.js +4 -3
  11. data/vendor/assets/javascripts/codemirror/modes/go.js +2 -2
  12. data/vendor/assets/javascripts/codemirror/modes/groovy.js +1 -1
  13. data/vendor/assets/javascripts/codemirror/modes/haskell.js +2 -2
  14. data/vendor/assets/javascripts/codemirror/modes/haxe.js +4 -4
  15. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +3 -3
  16. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +1 -1
  17. data/vendor/assets/javascripts/codemirror/modes/javascript.js +2 -2
  18. data/vendor/assets/javascripts/codemirror/modes/less.js +94 -60
  19. data/vendor/assets/javascripts/codemirror/modes/markdown.js +4 -4
  20. data/vendor/assets/javascripts/codemirror/modes/ntriples.js +4 -4
  21. data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -1
  22. data/vendor/assets/javascripts/codemirror/modes/pascal.js +1 -1
  23. data/vendor/assets/javascripts/codemirror/modes/perl.js +71 -71
  24. data/vendor/assets/javascripts/codemirror/modes/php.js +3 -3
  25. data/vendor/assets/javascripts/codemirror/modes/pig.js +3 -3
  26. data/vendor/assets/javascripts/codemirror/modes/python.js +1 -1
  27. data/vendor/assets/javascripts/codemirror/modes/scheme.js +1 -1
  28. data/vendor/assets/javascripts/codemirror/modes/shell.js +1 -1
  29. data/vendor/assets/javascripts/codemirror/modes/sieve.js +156 -0
  30. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +2 -2
  31. data/vendor/assets/javascripts/codemirror/modes/smarty.js +2 -2
  32. data/vendor/assets/javascripts/codemirror/modes/stex.js +1 -1
  33. data/vendor/assets/javascripts/codemirror/modes/tiki.js +4 -4
  34. data/vendor/assets/javascripts/codemirror/modes/velocity.js +1 -1
  35. data/vendor/assets/javascripts/codemirror/modes/verilog.js +1 -1
  36. data/vendor/assets/javascripts/codemirror/modes/xml.js +2 -2
  37. data/vendor/assets/javascripts/codemirror/modes/xquery.js +7 -4
  38. data/vendor/assets/javascripts/codemirror/utils/dialog.js +4 -1
  39. data/vendor/assets/javascripts/codemirror/utils/formatting.js +1 -1
  40. data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +3 -3
  41. data/vendor/assets/javascripts/codemirror/utils/loadmode.js +1 -1
  42. data/vendor/assets/javascripts/codemirror/utils/multiplex.js +1 -1
  43. data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +1 -1
  44. data/vendor/assets/javascripts/codemirror/utils/runmode.js +8 -4
  45. data/vendor/assets/javascripts/codemirror/utils/search.js +4 -4
  46. data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +13 -11
  47. data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +89 -68
  48. data/vendor/assets/javascripts/codemirror/utils/xml-hint.js +8 -8
  49. data/vendor/assets/stylesheets/codemirror.css +15 -11
  50. metadata +13 -13
@@ -107,11 +107,11 @@ CodeMirror.defineMode("pig", function(config, parserConfig) {
107
107
  // is it one of the builtin functions?
108
108
  if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase()))
109
109
  {
110
- return ("keyword", "variable-2")
110
+ return ("keyword", "variable-2");
111
111
  }
112
112
  // is it one of the listed types?
113
113
  if (types && types.propertyIsEnumerable(stream.current().toUpperCase()))
114
- return ("keyword", "variable-3")
114
+ return ("keyword", "variable-3");
115
115
  // default is a 'variable'
116
116
  return ret("variable", "pig-word");
117
117
  }
@@ -161,7 +161,7 @@ CodeMirror.defineMode("pig", function(config, parserConfig) {
161
161
  + "NEQ MATCHES TRUE FALSE ";
162
162
 
163
163
  // data types
164
- var pTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP "
164
+ var pTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP ";
165
165
 
166
166
  CodeMirror.defineMIME("text/x-pig", {
167
167
  name: "pig",
@@ -227,7 +227,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
227
227
  while (state.scopes[0].offset !== _indent) {
228
228
  state.scopes.shift();
229
229
  }
230
- return false
230
+ return false;
231
231
  } else {
232
232
  if (type === 'py') {
233
233
  state.scopes[0].offset = stream.indentation();
@@ -166,7 +166,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
166
166
  stream.skipToEnd(); // rest of the line is a comment
167
167
  returnType = COMMENT;
168
168
  } else if (ch == "(" || ch == "[") {
169
- var keyWord = ''; var indentTemp = stream.column();
169
+ var keyWord = ''; var indentTemp = stream.column(), letter;
170
170
  /**
171
171
  Either
172
172
  (indent-word ..
@@ -107,7 +107,7 @@ CodeMirror.defineMode('shell', function(config) {
107
107
  };
108
108
 
109
109
  return {
110
- startState: function() {return {tokens:[]}},
110
+ startState: function() {return {tokens:[]};},
111
111
  token: function(stream, state) {
112
112
  if (stream.eatSpace()) return null;
113
113
  return tokenize(stream, state);
@@ -0,0 +1,156 @@
1
+ /*
2
+ * See LICENSE in this directory for the license under which this code
3
+ * is released.
4
+ */
5
+
6
+ CodeMirror.defineMode("sieve", function(config) {
7
+ function words(str) {
8
+ var obj = {}, words = str.split(" ");
9
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
10
+ return obj;
11
+ }
12
+
13
+ var keywords = words("if elsif else stop require");
14
+ var atoms = words("true false not");
15
+ var indentUnit = config.indentUnit;
16
+
17
+ function tokenBase(stream, state) {
18
+
19
+ var ch = stream.next();
20
+ if (ch == "/" && stream.eat("*")) {
21
+ state.tokenize = tokenCComment;
22
+ return tokenCComment(stream, state);
23
+ }
24
+
25
+ if (ch === '#') {
26
+ stream.skipToEnd();
27
+ return "comment";
28
+ }
29
+
30
+ if (ch == "\"") {
31
+ state.tokenize = tokenString(ch);
32
+ return state.tokenize(stream, state);
33
+ }
34
+
35
+ if (ch === "{")
36
+ {
37
+ state._indent++;
38
+ return null;
39
+ }
40
+
41
+ if (ch === "}")
42
+ {
43
+ state._indent--;
44
+ return null;
45
+ }
46
+
47
+ if (/[{}\(\),;]/.test(ch))
48
+ return null;
49
+
50
+ // 1*DIGIT "K" / "M" / "G"
51
+ if (/\d/.test(ch)) {
52
+ stream.eatWhile(/[\d]/);
53
+ stream.eat(/[KkMmGg]/);
54
+ return "number";
55
+ }
56
+
57
+ // ":" (ALPHA / "_") *(ALPHA / DIGIT / "_")
58
+ if (ch == ":") {
59
+ stream.eatWhile(/[a-zA-Z_]/);
60
+ stream.eatWhile(/[a-zA-Z0-9_]/);
61
+
62
+ return "operator";
63
+ }
64
+
65
+ stream.eatWhile(/[\w\$_]/);
66
+ var cur = stream.current();
67
+
68
+ // "text:" *(SP / HTAB) (hash-comment / CRLF)
69
+ // *(multiline-literal / multiline-dotstart)
70
+ // "." CRLF
71
+ if ((cur == "text") && stream.eat(":"))
72
+ {
73
+ state.tokenize = tokenMultiLineString;
74
+ return "string";
75
+ }
76
+
77
+ if (keywords.propertyIsEnumerable(cur))
78
+ return "keyword";
79
+
80
+ if (atoms.propertyIsEnumerable(cur))
81
+ return "atom";
82
+ }
83
+
84
+ function tokenMultiLineString(stream, state)
85
+ {
86
+ state._multiLineString = true;
87
+ // the first line is special it may contain a comment
88
+ if (!stream.sol()) {
89
+ stream.eatSpace();
90
+
91
+ if (stream.peek() == "#") {
92
+ stream.skipToEnd();
93
+ return "comment";
94
+ }
95
+
96
+ stream.skipToEnd();
97
+ return "string";
98
+ }
99
+
100
+ if ((stream.next() == ".") && (stream.eol()))
101
+ {
102
+ state._multiLineString = false;
103
+ state.tokenize = tokenBase;
104
+ }
105
+
106
+ return "string";
107
+ }
108
+
109
+ function tokenCComment(stream, state) {
110
+ var maybeEnd = false, ch;
111
+ while ((ch = stream.next()) != null) {
112
+ if (maybeEnd && ch == "/") {
113
+ state.tokenize = tokenBase;
114
+ break;
115
+ }
116
+ maybeEnd = (ch == "*");
117
+ }
118
+ return "comment";
119
+ }
120
+
121
+ function tokenString(quote) {
122
+ return function(stream, state) {
123
+ var escaped = false, ch;
124
+ while ((ch = stream.next()) != null) {
125
+ if (ch == quote && !escaped)
126
+ break;
127
+ escaped = !escaped && ch == "\\";
128
+ }
129
+ if (!escaped) state.tokenize = tokenBase;
130
+ return "string";
131
+ };
132
+ }
133
+
134
+ return {
135
+ startState: function(base) {
136
+ return {tokenize: tokenBase,
137
+ baseIndent: base || 0,
138
+ _indent: 0};
139
+ },
140
+
141
+ token: function(stream, state) {
142
+ if (stream.eatSpace())
143
+ return null;
144
+
145
+ return (state.tokenize || tokenBase)(stream, state);;
146
+ },
147
+
148
+ indent: function(state, textAfter) {
149
+ return state.baseIndent + state._indent * indentUnit;
150
+ },
151
+
152
+ electricChars: "}"
153
+ };
154
+ });
155
+
156
+ CodeMirror.defineMIME("application/sieve", "sieve");
@@ -63,7 +63,7 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
63
63
 
64
64
  } else if (/\d/.test(aChar)) {
65
65
  stream.eatWhile(/[\w\d]/);
66
- token.name = 'number'
66
+ token.name = 'number';
67
67
 
68
68
  } else if (/[\w_]/.test(aChar)) {
69
69
  stream.eatWhile(/[\w\d_]/);
@@ -100,7 +100,7 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
100
100
  }
101
101
 
102
102
  return token;
103
- }
103
+ };
104
104
 
105
105
  return {
106
106
  startState: function() {
@@ -5,7 +5,7 @@ CodeMirror.defineMode("smarty", function(config, parserConfig) {
5
5
  operatorChars: /[+\-*&%=<>!?]/,
6
6
  validIdentifier: /[a-zA-Z0-9\_]/,
7
7
  stringChar: /[\'\"]/
8
- }
8
+ };
9
9
  var leftDelim = (typeof config.mode.leftDelimiter != 'undefined') ? config.mode.leftDelimiter : "{";
10
10
  var rightDelim = (typeof config.mode.rightDelimiter != 'undefined') ? config.mode.rightDelimiter : "}";
11
11
  function ret(style, lst) { last = lst; return style; }
@@ -142,7 +142,7 @@ CodeMirror.defineMode("smarty", function(config, parserConfig) {
142
142
  return style;
143
143
  },
144
144
  electricChars: ""
145
- }
145
+ };
146
146
  });
147
147
 
148
148
  CodeMirror.defineMIME("text/x-smarty", "smarty");
@@ -54,7 +54,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
54
54
  };
55
55
  this.closeBracket = function(content) {
56
56
  };
57
- }
57
+ };
58
58
  }
59
59
 
60
60
  var plugins = new Array();
@@ -18,7 +18,7 @@ CodeMirror.defineMode('tiki', function(config, parserConfig) {
18
18
  function inLine(style, terminator) {
19
19
  return function(stream, state) {
20
20
  while(!stream.eol()) {
21
- stream.next()
21
+ stream.next();
22
22
  }
23
23
  state.tokenize = inText;
24
24
  return style;
@@ -37,9 +37,9 @@ 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
- type = stream.eat("/") ? "closeTag" : "openTag";
40
+ var type = stream.eat("/") ? "closeTag" : "openTag";
41
41
  stream.eatSpace();
42
- tagName = "";
42
+ var tagName = "";
43
43
  var c;
44
44
  while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
45
45
  state.tokenize = inPlugin;
@@ -251,7 +251,7 @@ CodeMirror.defineMode('tiki', function(config, parserConfig) {
251
251
  if (err) setStyle = "error";
252
252
  if (type == "endPlugin") return cont();
253
253
  return pass();
254
- }
254
+ };
255
255
  }
256
256
 
257
257
  function attributes(type) {
@@ -5,7 +5,7 @@ CodeMirror.defineMode("velocity", function(config) {
5
5
  return obj;
6
6
  }
7
7
 
8
- var indentUnit = config.indentUnit
8
+ var indentUnit = config.indentUnit;
9
9
  var keywords = parseWords("#end #else #break #stop #[[ #]] " +
10
10
  "#{end} #{else} #{break} #{stop}");
11
11
  var functions = parseWords("#if #elseif #foreach #set #include #parse #macro #define #evaluate " +
@@ -21,7 +21,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
21
21
  }
22
22
  if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
23
  curPunc = ch;
24
- return null
24
+ return null;
25
25
  }
26
26
  if (/[\d']/.test(ch)) {
27
27
  stream.eatWhile(/[\w\.']/);
@@ -30,7 +30,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
30
30
  },
31
31
  doNotIndent: {"pre": true},
32
32
  allowUnquoted: true,
33
- allowMissing: false
33
+ allowMissing: true
34
34
  } : {
35
35
  autoSelfClosers: {},
36
36
  implicitlyClosed: {},
@@ -229,7 +229,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
229
229
  if (type == "endTag") { popContext(); return cont(); }
230
230
  setStyle = "error";
231
231
  return cont(arguments.callee);
232
- }
232
+ };
233
233
  }
234
234
  function maybePopContext(nextTagName) {
235
235
  var parentTagName;
@@ -56,7 +56,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
56
56
  'preceding-sibling','processing-instruction','ref','return','returns','satisfies','schema','schema-element',
57
57
  'self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where',
58
58
  'xquery', 'empty-sequence'];
59
- for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i])};
59
+ for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
60
60
 
61
61
  // a list of types. For each add a property to kwObj with the value of
62
62
  // {type: "atom", style: "atom"}
@@ -191,7 +191,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
191
191
  if(!known) stream.eatWhile(/[\w\$_-]/);
192
192
 
193
193
  // gobble a colon in the case that is a lib func type call fn:doc
194
- var foundColon = stream.eat(":")
194
+ var foundColon = stream.eat(":");
195
195
 
196
196
  // if there's not a second colon, gobble another word. Otherwise, it's probably an axis specifier
197
197
  // which should get matched as a keyword
@@ -325,7 +325,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
325
325
  state.tokenize = tokenBase;
326
326
  }
327
327
  return ret("tag", "tag");
328
- }
328
+ };
329
329
  }
330
330
 
331
331
  // tokenizer for XML attributes
@@ -365,6 +365,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
365
365
 
366
366
  // handle comments, including nested
367
367
  function tokenXMLComment(stream, state) {
368
+ var ch;
368
369
  while (ch = stream.next()) {
369
370
  if (ch == "-" && stream.match("->", true)) {
370
371
  state.tokenize = tokenBase;
@@ -376,6 +377,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
376
377
 
377
378
  // handle CDATA
378
379
  function tokenCDATA(stream, state) {
380
+ var ch;
379
381
  while (ch = stream.next()) {
380
382
  if (ch == "]" && stream.match("]", true)) {
381
383
  state.tokenize = tokenBase;
@@ -386,6 +388,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
386
388
 
387
389
  // handle preprocessing instructions
388
390
  function tokenPreProcessing(stream, state) {
391
+ var ch;
389
392
  while (ch = stream.next()) {
390
393
  if (ch == "?" && stream.match(">", true)) {
391
394
  state.tokenize = tokenBase;
@@ -422,7 +425,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
422
425
 
423
426
  function popStateStack(state) {
424
427
  var popped = state.stack.pop();
425
- var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize
428
+ var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize;
426
429
  state.tokenize = reinstateTokenize || tokenBase;
427
430
  }
428
431
 
@@ -30,7 +30,10 @@
30
30
  inp.focus();
31
31
  CodeMirror.connect(inp, "blur", close);
32
32
  } else if (button = dialog.getElementsByTagName("button")[0]) {
33
- CodeMirror.connect(button, "click", close);
33
+ CodeMirror.connect(button, "click", function() {
34
+ close();
35
+ me.focus();
36
+ });
34
37
  button.focus();
35
38
  CodeMirror.connect(button, "blur", close);
36
39
  }
@@ -131,7 +131,7 @@ CodeMirror.modeExtensions["javascript"] = {
131
131
  autoFormatLineBreaks: function (text, startPos, endPos) {
132
132
  text = text.substring(startPos, endPos);
133
133
  var curPos = 0;
134
- var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n])", "g");
134
+ var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n;])", "g");
135
135
  var nonBreakableBlocks = this.getNonBreakableBlocks(text);
136
136
  if (nonBreakableBlocks != null) {
137
137
  var res = "";
@@ -38,7 +38,7 @@
38
38
  case '(': level--; break;
39
39
  default: break;
40
40
  }
41
- } while (level > 0)
41
+ } while (level > 0);
42
42
  tprop = getToken(editor, {line: cur.line, ch: tprop.start});
43
43
  if (tprop.className == 'variable')
44
44
  tprop.className = 'function';
@@ -55,7 +55,7 @@
55
55
  CodeMirror.javascriptHint = function(editor) {
56
56
  return scriptHint(editor, javascriptKeywords,
57
57
  function (e, cur) {return e.getTokenAt(cur);});
58
- }
58
+ };
59
59
 
60
60
  function getCoffeeScriptToken(editor, cur) {
61
61
  // This getToken, it is for coffeescript, imitates the behavior of
@@ -77,7 +77,7 @@
77
77
 
78
78
  CodeMirror.coffeescriptHint = function(editor) {
79
79
  return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken);
80
- }
80
+ };
81
81
 
82
82
  var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
83
83
  "toUpperCase toLowerCase split concat match replace search").split(" ");
@@ -4,7 +4,7 @@
4
4
  var loading = {};
5
5
  function splitCallback(cont, n) {
6
6
  var countDown = n;
7
- return function() { if (--countDown == 0) cont(); }
7
+ return function() { if (--countDown == 0) cont(); };
8
8
  }
9
9
  function ensureDeps(mode, cont) {
10
10
  var deps = CodeMirror.modes[mode].dependencies;
@@ -35,7 +35,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
35
35
  if (found == stream.pos) {
36
36
  stream.match(other.open);
37
37
  state.innerActive = other;
38
- state.inner = CodeMirror.startState(other.mode, outer.indent(state.outer, ""));
38
+ state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
39
39
  return other.delimStyle;
40
40
  } else if (found != -1 && found < cutOff) {
41
41
  cutOff = found;