erp_app 3.0.10 → 3.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/lib/erp_app/version.rb +1 -1
  2. data/public/javascripts/erp_app/codemirror/README.md +1 -1
  3. data/public/javascripts/erp_app/codemirror/doc/compress.html +11 -3
  4. data/public/javascripts/erp_app/codemirror/doc/docs.css +16 -5
  5. data/public/javascripts/erp_app/codemirror/doc/internals.html +6 -3
  6. data/public/javascripts/erp_app/codemirror/doc/manual.html +103 -41
  7. data/public/javascripts/erp_app/codemirror/doc/oldrelease.html +43 -5
  8. data/public/javascripts/erp_app/codemirror/doc/reporting.html +6 -3
  9. data/public/javascripts/erp_app/codemirror/doc/upgrade_v2.2.html +7 -4
  10. data/public/javascripts/erp_app/codemirror/keymap/vim.js +10 -6
  11. data/public/javascripts/erp_app/codemirror/lib/codemirror.css +16 -12
  12. data/public/javascripts/erp_app/codemirror/lib/codemirror.js +699 -787
  13. data/public/javascripts/erp_app/codemirror/lib/util/closetag.js +35 -35
  14. data/public/javascripts/erp_app/codemirror/lib/util/dialog.js +4 -1
  15. data/public/javascripts/erp_app/codemirror/lib/util/formatting.js +147 -253
  16. data/public/javascripts/erp_app/codemirror/lib/util/javascript-hint.js +3 -3
  17. data/public/javascripts/erp_app/codemirror/lib/util/loadmode.js +1 -1
  18. data/public/javascripts/erp_app/codemirror/lib/util/multiplex.js +5 -9
  19. data/public/javascripts/erp_app/codemirror/lib/util/overlay.js +3 -1
  20. data/public/javascripts/erp_app/codemirror/lib/util/pig-hint.js +1 -1
  21. data/public/javascripts/erp_app/codemirror/lib/util/runmode-standalone.js +90 -0
  22. data/public/javascripts/erp_app/codemirror/lib/util/runmode.js +8 -4
  23. data/public/javascripts/erp_app/codemirror/lib/util/search.js +4 -4
  24. data/public/javascripts/erp_app/codemirror/lib/util/searchcursor.js +13 -11
  25. data/public/javascripts/erp_app/codemirror/lib/util/simple-hint.js +89 -68
  26. data/public/javascripts/erp_app/codemirror/lib/util/xml-hint.js +8 -8
  27. data/public/javascripts/erp_app/codemirror/mode/clike/clike.js +6 -2
  28. data/public/javascripts/erp_app/codemirror/mode/clike/index.html +1 -0
  29. data/public/javascripts/erp_app/codemirror/mode/clike/scala.html +1 -0
  30. data/public/javascripts/erp_app/codemirror/mode/clojure/clojure.js +8 -9
  31. data/public/javascripts/erp_app/codemirror/mode/clojure/index.html +1 -0
  32. data/public/javascripts/erp_app/codemirror/mode/coffeescript/coffeescript.js +3 -3
  33. data/public/javascripts/erp_app/codemirror/mode/coffeescript/index.html +1 -0
  34. data/public/javascripts/erp_app/codemirror/mode/commonlisp/commonlisp.js +101 -0
  35. data/public/javascripts/erp_app/codemirror/mode/commonlisp/index.html +165 -0
  36. data/public/javascripts/erp_app/codemirror/mode/css/css.js +339 -15
  37. data/public/javascripts/erp_app/codemirror/mode/css/index.html +3 -0
  38. data/public/javascripts/erp_app/codemirror/mode/css/test.js +501 -0
  39. data/public/javascripts/erp_app/codemirror/mode/diff/index.html +1 -0
  40. data/public/javascripts/erp_app/codemirror/mode/ecl/ecl.js +1 -1
  41. data/public/javascripts/erp_app/codemirror/mode/erlang/index.html +1 -0
  42. data/public/javascripts/erp_app/codemirror/mode/gfm/gfm.js +10 -4
  43. data/public/javascripts/erp_app/codemirror/mode/gfm/index.html +1 -0
  44. data/public/javascripts/erp_app/codemirror/mode/go/go.js +2 -2
  45. data/public/javascripts/erp_app/codemirror/mode/go/index.html +1 -0
  46. data/public/javascripts/erp_app/codemirror/mode/groovy/groovy.js +1 -1
  47. data/public/javascripts/erp_app/codemirror/mode/groovy/index.html +1 -0
  48. data/public/javascripts/erp_app/codemirror/mode/haskell/haskell.js +2 -2
  49. data/public/javascripts/erp_app/codemirror/mode/haskell/index.html +1 -0
  50. data/public/javascripts/erp_app/codemirror/mode/haxe/haxe.js +4 -7
  51. data/public/javascripts/erp_app/codemirror/mode/haxe/index.html +1 -0
  52. data/public/javascripts/erp_app/codemirror/mode/htmlembedded/htmlembedded.js +8 -4
  53. data/public/javascripts/erp_app/codemirror/mode/htmlembedded/index.html +1 -0
  54. data/public/javascripts/erp_app/codemirror/mode/htmlmixed/htmlmixed.js +12 -13
  55. data/public/javascripts/erp_app/codemirror/mode/htmlmixed/index.html +1 -0
  56. data/public/javascripts/erp_app/codemirror/mode/javascript/index.html +1 -0
  57. data/public/javascripts/erp_app/codemirror/mode/javascript/javascript.js +3 -3
  58. data/public/javascripts/erp_app/codemirror/mode/jinja2/index.html +1 -0
  59. data/public/javascripts/erp_app/codemirror/mode/less/index.html +124 -2
  60. data/public/javascripts/erp_app/codemirror/mode/less/less.js +94 -60
  61. data/public/javascripts/erp_app/codemirror/mode/lua/index.html +1 -0
  62. data/public/javascripts/erp_app/codemirror/mode/markdown/index.html +3 -0
  63. data/public/javascripts/erp_app/codemirror/mode/markdown/markdown.js +134 -20
  64. data/public/javascripts/erp_app/codemirror/mode/markdown/test.js +1084 -0
  65. data/public/javascripts/erp_app/codemirror/mode/mysql/index.html +1 -0
  66. data/public/javascripts/erp_app/codemirror/mode/ntriples/index.html +1 -0
  67. data/public/javascripts/erp_app/codemirror/mode/ntriples/ntriples.js +4 -4
  68. data/public/javascripts/erp_app/codemirror/mode/ocaml/ocaml.js +1 -1
  69. data/public/javascripts/erp_app/codemirror/mode/pascal/index.html +1 -0
  70. data/public/javascripts/erp_app/codemirror/mode/pascal/pascal.js +1 -1
  71. data/public/javascripts/erp_app/codemirror/mode/perl/index.html +1 -0
  72. data/public/javascripts/erp_app/codemirror/mode/perl/perl.js +71 -71
  73. data/public/javascripts/erp_app/codemirror/mode/php/index.html +1 -0
  74. data/public/javascripts/erp_app/codemirror/mode/php/php.js +7 -9
  75. data/public/javascripts/erp_app/codemirror/mode/pig/index.html +1 -0
  76. data/public/javascripts/erp_app/codemirror/mode/pig/pig.js +3 -3
  77. data/public/javascripts/erp_app/codemirror/mode/plsql/index.html +1 -0
  78. data/public/javascripts/erp_app/codemirror/mode/properties/index.html +1 -0
  79. data/public/javascripts/erp_app/codemirror/mode/python/index.html +1 -0
  80. data/public/javascripts/erp_app/codemirror/mode/python/python.js +1 -1
  81. data/public/javascripts/erp_app/codemirror/mode/r/index.html +1 -0
  82. data/public/javascripts/erp_app/codemirror/mode/rpm/changes/index.html +1 -0
  83. data/public/javascripts/erp_app/codemirror/mode/rpm/spec/index.html +1 -0
  84. data/public/javascripts/erp_app/codemirror/mode/rst/index.html +1 -0
  85. data/public/javascripts/erp_app/codemirror/mode/ruby/index.html +1 -0
  86. data/public/javascripts/erp_app/codemirror/mode/rust/index.html +1 -0
  87. data/public/javascripts/erp_app/codemirror/mode/scheme/index.html +1 -0
  88. data/public/javascripts/erp_app/codemirror/mode/scheme/scheme.js +1 -1
  89. data/public/javascripts/erp_app/codemirror/mode/shell/shell.js +2 -2
  90. data/public/javascripts/erp_app/codemirror/mode/sieve/LICENSE +23 -0
  91. data/public/javascripts/erp_app/codemirror/mode/sieve/index.html +81 -0
  92. data/public/javascripts/erp_app/codemirror/mode/sieve/sieve.js +156 -0
  93. data/public/javascripts/erp_app/codemirror/mode/smalltalk/index.html +1 -0
  94. data/public/javascripts/erp_app/codemirror/mode/smalltalk/smalltalk.js +2 -2
  95. data/public/javascripts/erp_app/codemirror/mode/smarty/index.html +1 -0
  96. data/public/javascripts/erp_app/codemirror/mode/smarty/smarty.js +2 -2
  97. data/public/javascripts/erp_app/codemirror/mode/sparql/index.html +1 -0
  98. data/public/javascripts/erp_app/codemirror/mode/stex/index.html +3 -0
  99. data/public/javascripts/erp_app/codemirror/mode/stex/stex.js +1 -1
  100. data/public/javascripts/erp_app/codemirror/mode/stex/test.js +343 -0
  101. data/public/javascripts/erp_app/codemirror/mode/tiddlywiki/index.html +1 -0
  102. data/public/javascripts/erp_app/codemirror/mode/tiki/index.html +1 -0
  103. data/public/javascripts/erp_app/codemirror/mode/tiki/tiki.js +4 -11
  104. data/public/javascripts/erp_app/codemirror/mode/vb/index.html +1 -0
  105. data/public/javascripts/erp_app/codemirror/mode/vb/vb.js +2 -2
  106. data/public/javascripts/erp_app/codemirror/mode/vbscript/index.html +1 -0
  107. data/public/javascripts/erp_app/codemirror/mode/velocity/index.html +1 -0
  108. data/public/javascripts/erp_app/codemirror/mode/velocity/velocity.js +1 -1
  109. data/public/javascripts/erp_app/codemirror/mode/verilog/index.html +1 -0
  110. data/public/javascripts/erp_app/codemirror/mode/verilog/verilog.js +1 -1
  111. data/public/javascripts/erp_app/codemirror/mode/xml/index.html +2 -1
  112. data/public/javascripts/erp_app/codemirror/mode/xml/xml.js +2 -10
  113. data/public/javascripts/erp_app/codemirror/mode/xquery/index.html +3 -2
  114. data/public/javascripts/erp_app/codemirror/mode/xquery/xquery.js +7 -4
  115. data/public/javascripts/erp_app/codemirror/mode/yaml/index.html +1 -0
  116. data/public/javascripts/erp_app/codemirror/package.json +15 -23
  117. data/public/javascripts/erp_app/codemirror/test/driver.js +109 -22
  118. data/public/javascripts/erp_app/codemirror/test/index.html +129 -16
  119. data/public/javascripts/erp_app/codemirror/test/lint/lint.js +120 -0
  120. data/public/javascripts/erp_app/codemirror/test/lint/parse-js.js +1372 -0
  121. data/public/javascripts/erp_app/codemirror/test/mode_test.css +0 -12
  122. data/public/javascripts/erp_app/codemirror/test/mode_test.js +66 -27
  123. data/public/javascripts/erp_app/codemirror/test/phantom_driver.js +30 -0
  124. data/public/javascripts/erp_app/codemirror/test/run.js +32 -0
  125. data/public/javascripts/erp_app/codemirror/test/test.js +213 -8
  126. data/public/javascripts/erp_app/shared/dynamic_editable_grid.js +33 -27
  127. data/public/javascripts/erp_app/shared/dynamic_editable_grid_loader_panel.js +2 -1
  128. metadata +15 -3
  129. data/public/javascripts/erp_app/codemirror/mode/stex/test.html +0 -263
@@ -0,0 +1,90 @@
1
+ /* Just enough of CodeMirror to run runMode under node.js */
2
+
3
+ function splitLines(string){ return string.split(/\r?\n|\r/); };
4
+
5
+ function StringStream(string) {
6
+ this.pos = this.start = 0;
7
+ this.string = string;
8
+ }
9
+ StringStream.prototype = {
10
+ eol: function() {return this.pos >= this.string.length;},
11
+ sol: function() {return this.pos == 0;},
12
+ peek: function() {return this.string.charAt(this.pos) || null;},
13
+ next: function() {
14
+ if (this.pos < this.string.length)
15
+ return this.string.charAt(this.pos++);
16
+ },
17
+ eat: function(match) {
18
+ var ch = this.string.charAt(this.pos);
19
+ if (typeof match == "string") var ok = ch == match;
20
+ else var ok = ch && (match.test ? match.test(ch) : match(ch));
21
+ if (ok) {++this.pos; return ch;}
22
+ },
23
+ eatWhile: function(match) {
24
+ var start = this.pos;
25
+ while (this.eat(match)){}
26
+ return this.pos > start;
27
+ },
28
+ eatSpace: function() {
29
+ var start = this.pos;
30
+ while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
31
+ return this.pos > start;
32
+ },
33
+ skipToEnd: function() {this.pos = this.string.length;},
34
+ skipTo: function(ch) {
35
+ var found = this.string.indexOf(ch, this.pos);
36
+ if (found > -1) {this.pos = found; return true;}
37
+ },
38
+ backUp: function(n) {this.pos -= n;},
39
+ column: function() {return this.start;},
40
+ indentation: function() {return 0;},
41
+ match: function(pattern, consume, caseInsensitive) {
42
+ if (typeof pattern == "string") {
43
+ function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
44
+ if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
45
+ if (consume !== false) this.pos += pattern.length;
46
+ return true;
47
+ }
48
+ }
49
+ else {
50
+ var match = this.string.slice(this.pos).match(pattern);
51
+ if (match && consume !== false) this.pos += match[0].length;
52
+ return match;
53
+ }
54
+ },
55
+ current: function(){return this.string.slice(this.start, this.pos);}
56
+ };
57
+ exports.StringStream = StringStream;
58
+
59
+ exports.startState = function(mode, a1, a2) {
60
+ return mode.startState ? mode.startState(a1, a2) : true;
61
+ };
62
+
63
+ var modes = exports.modes = {}, mimeModes = exports.mimeModes = {};
64
+ exports.defineMode = function(name, mode) { modes[name] = mode; };
65
+ exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; };
66
+ exports.getMode = function(options, spec) {
67
+ if (typeof spec == "string" && mimeModes.hasOwnProperty(spec))
68
+ spec = mimeModes[spec];
69
+ if (typeof spec == "string")
70
+ var mname = spec, config = {};
71
+ else if (spec != null)
72
+ var mname = spec.name, config = spec;
73
+ var mfactory = modes[mname];
74
+ if (!mfactory) throw new Error("Unknown mode: " + spec);
75
+ return mfactory(options, config || {});
76
+ };
77
+
78
+ exports.runMode = function(string, modespec, callback) {
79
+ var mode = exports.getMode({indentUnit: 2}, modespec);
80
+ var lines = splitLines(string), state = exports.startState(mode);
81
+ for (var i = 0, e = lines.length; i < e; ++i) {
82
+ if (i) callback("\n");
83
+ var stream = new exports.StringStream(lines[i]);
84
+ while (!stream.eol()) {
85
+ var style = mode.token(stream, state);
86
+ callback(stream.current(), style, i, stream.start);
87
+ stream.start = stream.pos;
88
+ }
89
+ }
90
+ };
@@ -1,4 +1,8 @@
1
1
  CodeMirror.runMode = function(string, modespec, callback, options) {
2
+ function esc(str) {
3
+ return str.replace(/[<&]/, function(ch) { return ch == "<" ? "&lt;" : "&amp;"; });
4
+ }
5
+
2
6
  var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
3
7
  var isNode = callback.nodeType == 1;
4
8
  var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
@@ -15,12 +19,12 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
15
19
  for (var pos = 0;;) {
16
20
  var idx = text.indexOf("\t", pos);
17
21
  if (idx == -1) {
18
- escaped += CodeMirror.htmlEscape(text.slice(pos));
22
+ escaped += esc(text.slice(pos));
19
23
  col += text.length - pos;
20
24
  break;
21
25
  } else {
22
26
  col += idx - pos;
23
- escaped += CodeMirror.htmlEscape(text.slice(pos, idx));
27
+ escaped += esc(text.slice(pos, idx));
24
28
  var size = tabSize - col % tabSize;
25
29
  col += size;
26
30
  for (var i = 0; i < size; ++i) escaped += " ";
@@ -29,10 +33,10 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
29
33
  }
30
34
 
31
35
  if (style)
32
- accum.push("<span class=\"cm-" + CodeMirror.htmlEscape(style) + "\">" + escaped + "</span>");
36
+ accum.push("<span class=\"cm-" + esc(style) + "\">" + escaped + "</span>");
33
37
  else
34
38
  accum.push(escaped);
35
- }
39
+ };
36
40
  }
37
41
  var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
38
42
  for (var i = 0, e = lines.length; i < e; ++i) {
@@ -40,7 +40,7 @@
40
40
  if (!query || state.query) return;
41
41
  state.query = parseQuery(query);
42
42
  if (cm.lineCount() < 2000) { // This is too expensive on big documents.
43
- for (var cursor = getSearchCursor(cm, query); cursor.findNext();)
43
+ for (var cursor = getSearchCursor(cm, state.query); cursor.findNext();)
44
44
  state.marked.push(cm.markText(cursor.from(), cursor.to(), "CodeMirror-searching"));
45
45
  }
46
46
  state.posFrom = state.posTo = cm.getCursor();
@@ -57,14 +57,14 @@
57
57
  }
58
58
  cm.setSelection(cursor.from(), cursor.to());
59
59
  state.posFrom = cursor.from(); state.posTo = cursor.to();
60
- })}
60
+ });}
61
61
  function clearSearch(cm) {cm.operation(function() {
62
62
  var state = getSearchState(cm);
63
63
  if (!state.query) return;
64
64
  state.query = null;
65
65
  for (var i = 0; i < state.marked.length; ++i) state.marked[i].clear();
66
66
  state.marked.length = 0;
67
- })}
67
+ });}
68
68
 
69
69
  var replaceQueryDialog =
70
70
  'Replace: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)</span>';
@@ -83,7 +83,7 @@
83
83
  cursor.replace(text.replace(/\$(\d)/, function(w, i) {return match[i];}));
84
84
  } else cursor.replace(text);
85
85
  }
86
- })});
86
+ });});
87
87
  } else {
88
88
  clearSearch(cm);
89
89
  var cursor = getSearchCursor(cm, query, cm.getCursor());
@@ -10,30 +10,32 @@
10
10
  // It takes a position and a direction, and returns an object
11
11
  // describing the next occurrence of the query, or null if no
12
12
  // more matches were found.
13
- if (typeof query != "string") // Regexp match
13
+ if (typeof query != "string") { // Regexp match
14
+ if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
14
15
  this.matches = function(reverse, pos) {
15
16
  if (reverse) {
16
- var line = cm.getLine(pos.line).slice(0, pos.ch), match = line.match(query), start = 0;
17
+ query.lastIndex = 0;
18
+ var line = cm.getLine(pos.line).slice(0, pos.ch), match = query.exec(line), start = 0;
17
19
  while (match) {
18
- var ind = line.indexOf(match[0]);
19
- start += ind;
20
- line = line.slice(ind + 1);
21
- var newmatch = line.match(query);
20
+ start += match.index;
21
+ line = line.slice(match.index);
22
+ query.lastIndex = 0;
23
+ var newmatch = query.exec(line);
22
24
  if (newmatch) match = newmatch;
23
25
  else break;
24
26
  start++;
25
27
  }
26
- }
27
- else {
28
- var line = cm.getLine(pos.line).slice(pos.ch), match = line.match(query),
29
- start = match && pos.ch + line.indexOf(match[0]);
28
+ } else {
29
+ query.lastIndex = pos.ch;
30
+ var line = cm.getLine(pos.line), match = query.exec(line),
31
+ start = match && match.index;
30
32
  }
31
33
  if (match)
32
34
  return {from: {line: pos.line, ch: start},
33
35
  to: {line: pos.line, ch: start + match[0].length},
34
36
  match: match};
35
37
  };
36
- else { // String query
38
+ } else { // String query
37
39
  if (caseFold) query = query.toLowerCase();
38
40
  var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
39
41
  var target = query.split("\n");
@@ -1,76 +1,97 @@
1
1
  (function() {
2
- CodeMirror.simpleHint = function(editor, getHints) {
3
- // We want a single cursor position.
4
- if (editor.somethingSelected()) return;
5
- //don't show completion if the token is empty
6
- var tempToken = editor.getTokenAt(editor.getCursor());
7
- if(!(/[\S]/gi.test(tempToken.string))) return;
2
+ CodeMirror.simpleHint = function(editor, getHints, givenOptions) {
3
+ // Determine effective options based on given values and defaults.
4
+ var options = {}, defaults = CodeMirror.simpleHint.defaults;
5
+ for (var opt in defaults)
6
+ if (defaults.hasOwnProperty(opt))
7
+ options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
8
+
9
+ function collectHints(previousToken) {
10
+ // We want a single cursor position.
11
+ if (editor.somethingSelected()) return;
8
12
 
9
- var result = getHints(editor);
10
- if (!result || !result.list.length) return;
11
- var completions = result.list;
12
- function insert(str) {
13
- editor.replaceRange(str, result.from, result.to);
14
- }
15
- // When there is only one completion, use it directly.
16
- if (completions.length == 1) {insert(completions[0]); return true;}
13
+ var tempToken = editor.getTokenAt(editor.getCursor());
17
14
 
18
- // Build the select widget
19
- var complete = document.createElement("div");
20
- complete.className = "CodeMirror-completions";
21
- var sel = complete.appendChild(document.createElement("select"));
22
- // Opera doesn't move the selection when pressing up/down in a
23
- // multi-select, but it does properly support the size property on
24
- // single-selects, so no multi-select is necessary.
25
- if (!window.opera) sel.multiple = true;
26
- for (var i = 0; i < completions.length; ++i) {
27
- var opt = sel.appendChild(document.createElement("option"));
28
- opt.appendChild(document.createTextNode(completions[i]));
29
- }
30
- sel.firstChild.selected = true;
31
- sel.size = Math.min(10, completions.length);
32
- var pos = editor.cursorCoords();
33
- complete.style.left = pos.x + "px";
34
- complete.style.top = pos.yBot + "px";
35
- document.body.appendChild(complete);
36
- // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
37
- var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
38
- if(winW - pos.x < sel.clientWidth)
39
- complete.style.left = (pos.x - sel.clientWidth) + "px";
40
- // Hack to hide the scrollbar.
41
- if (completions.length <= 10)
42
- complete.style.width = (sel.clientWidth - 1) + "px";
15
+ // Don't show completions if token has changed and the option is set.
16
+ if (options.closeOnTokenChange && previousToken != null &&
17
+ (tempToken.start != previousToken.start || tempToken.className != previousToken.className)) {
18
+ return;
19
+ }
43
20
 
44
- var done = false;
45
- function close() {
46
- if (done) return;
47
- done = true;
48
- complete.parentNode.removeChild(complete);
49
- }
50
- function pick() {
51
- insert(completions[sel.selectedIndex]);
52
- close();
53
- setTimeout(function(){editor.focus();}, 50);
54
- }
55
- CodeMirror.connect(sel, "blur", close);
56
- CodeMirror.connect(sel, "keydown", function(event) {
57
- var code = event.keyCode;
58
- // Enter
59
- if (code == 13) {CodeMirror.e_stop(event); pick();}
60
- // Escape
61
- else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
62
- else if (code != 38 && code != 40) {
63
- close(); editor.focus();
64
- // Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
65
- editor.triggerOnKeyDown(event);
66
- setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50);
21
+ var result = getHints(editor);
22
+ if (!result || !result.list.length) return;
23
+ var completions = result.list;
24
+ function insert(str) {
25
+ editor.replaceRange(str, result.from, result.to);
26
+ }
27
+ // When there is only one completion, use it directly.
28
+ if (completions.length == 1) {insert(completions[0]); return true;}
29
+
30
+ // Build the select widget
31
+ var complete = document.createElement("div");
32
+ complete.className = "CodeMirror-completions";
33
+ var sel = complete.appendChild(document.createElement("select"));
34
+ // Opera doesn't move the selection when pressing up/down in a
35
+ // multi-select, but it does properly support the size property on
36
+ // single-selects, so no multi-select is necessary.
37
+ if (!window.opera) sel.multiple = true;
38
+ for (var i = 0; i < completions.length; ++i) {
39
+ var opt = sel.appendChild(document.createElement("option"));
40
+ opt.appendChild(document.createTextNode(completions[i]));
41
+ }
42
+ sel.firstChild.selected = true;
43
+ sel.size = Math.min(10, completions.length);
44
+ var pos = editor.cursorCoords();
45
+ complete.style.left = pos.x + "px";
46
+ complete.style.top = pos.yBot + "px";
47
+ document.body.appendChild(complete);
48
+ // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
49
+ var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
50
+ if(winW - pos.x < sel.clientWidth)
51
+ complete.style.left = (pos.x - sel.clientWidth) + "px";
52
+ // Hack to hide the scrollbar.
53
+ if (completions.length <= 10)
54
+ complete.style.width = (sel.clientWidth - 1) + "px";
55
+
56
+ var done = false;
57
+ function close() {
58
+ if (done) return;
59
+ done = true;
60
+ complete.parentNode.removeChild(complete);
67
61
  }
68
- });
69
- CodeMirror.connect(sel, "dblclick", pick);
62
+ function pick() {
63
+ insert(completions[sel.selectedIndex]);
64
+ close();
65
+ setTimeout(function(){editor.focus();}, 50);
66
+ }
67
+ CodeMirror.connect(sel, "blur", close);
68
+ CodeMirror.connect(sel, "keydown", function(event) {
69
+ var code = event.keyCode;
70
+ // Enter
71
+ if (code == 13) {CodeMirror.e_stop(event); pick();}
72
+ // Escape
73
+ else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
74
+ else if (code != 38 && code != 40 && code != 33 && code != 34) {
75
+ close(); editor.focus();
76
+ // Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
77
+ editor.triggerOnKeyDown(event);
78
+ // Don't show completions if the code is backspace and the option is set.
79
+ if (!options.closeOnBackspace || code != 8) {
80
+ setTimeout(function(){collectHints(tempToken);}, 50);
81
+ }
82
+ }
83
+ });
84
+ CodeMirror.connect(sel, "dblclick", pick);
70
85
 
71
- sel.focus();
72
- // Opera sometimes ignores focusing a freshly created node
73
- if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
74
- return true;
86
+ sel.focus();
87
+ // Opera sometimes ignores focusing a freshly created node
88
+ if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
89
+ return true;
90
+ }
91
+ return collectHints();
92
+ };
93
+ CodeMirror.simpleHint.defaults = {
94
+ closeOnBackspace: true,
95
+ closeOnTokenChange: false
75
96
  };
76
97
  })();
@@ -1,4 +1,4 @@
1
- 
1
+
2
2
  (function() {
3
3
 
4
4
  CodeMirror.xmlHints = [];
@@ -15,7 +15,7 @@
15
15
  // dirty hack for simple-hint to receive getHint event on space
16
16
  var getTokenAt = editor.getTokenAt;
17
17
 
18
- editor.getTokenAt = function() { return 'disabled'; }
18
+ editor.getTokenAt = function() { return 'disabled'; };
19
19
  CodeMirror.simpleHint(cm, getHint);
20
20
 
21
21
  editor.getTokenAt = getTokenAt;
@@ -40,7 +40,7 @@
40
40
  }
41
41
  }
42
42
 
43
- text = text.substr(0, text.length - typed.length);
43
+ text = text.slice(0, text.length - typed.length);
44
44
 
45
45
  var path = getActiveElement(cm, text) + simbol;
46
46
  var hints = CodeMirror.xmlHints[path];
@@ -58,10 +58,10 @@
58
58
  return {
59
59
  list: hints,
60
60
  from: { line: cursor.line, ch: cursor.ch - typed.length },
61
- to: cursor,
61
+ to: cursor
62
62
  };
63
63
  };
64
- }
64
+ };
65
65
 
66
66
  var getActiveElement = function(codeMirror, text) {
67
67
 
@@ -76,7 +76,7 @@
76
76
  while ((match = regex.exec(text)) != null) {
77
77
  matches.push({
78
78
  tag: match[1],
79
- selfclose: (match[0].substr(-1) === '/>')
79
+ selfclose: (match[0].slice(match[0].length - 2) === '/>')
80
80
  });
81
81
  }
82
82
 
@@ -114,7 +114,7 @@
114
114
 
115
115
  if (close < open)
116
116
  {
117
- text = text.substr(open);
117
+ text = text.slice(open);
118
118
 
119
119
  if(text != '<') {
120
120
 
@@ -127,7 +127,7 @@
127
127
  if (space < 0)
128
128
  space = text.length;
129
129
 
130
- return text.substr(0, space);
130
+ return text.slice(0, space);
131
131
  }
132
132
  }
133
133
 
@@ -181,14 +181,18 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
181
181
  return "string";
182
182
  }
183
183
 
184
- CodeMirror.defineMIME("text/x-csrc", {
184
+ function mimes(ms, mode) {
185
+ for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
186
+ }
187
+
188
+ mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
185
189
  name: "clike",
186
190
  keywords: words(cKeywords),
187
191
  blockKeywords: words("case do else for if switch while struct"),
188
192
  atoms: words("null"),
189
193
  hooks: {"#": cppHook}
190
194
  });
191
- CodeMirror.defineMIME("text/x-c++src", {
195
+ mimes(["text/x-c++src", "text/x-c++hdr"], {
192
196
  name: "clike",
193
197
  keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
194
198
  "static_cast typeid catch operator template typename class friend private " +
@@ -1,6 +1,7 @@
1
1
  <!doctype html>
2
2
  <html>
3
3
  <head>
4
+ <meta charset="utf-8">
4
5
  <title>CodeMirror: C-like mode</title>
5
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
7
  <script src="../../lib/codemirror.js"></script>
@@ -1,6 +1,7 @@
1
1
  <!doctype html>
2
2
  <html>
3
3
  <head>
4
+ <meta charset="utf-8">
4
5
  <title>CodeMirror: C-like mode</title>
5
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
7
  <link rel="stylesheet" href="../../theme/ambiance.css">
@@ -40,9 +40,9 @@ CodeMirror.defineMode("clojure", function (config, mode) {
40
40
  var tests = {
41
41
  digit: /\d/,
42
42
  digit_or_colon: /[\d:]/,
43
- hex: /[0-9a-fA-F]/,
43
+ hex: /[0-9a-f]/i,
44
44
  sign: /[+-]/,
45
- exponent: /[eE]/,
45
+ exponent: /e/i,
46
46
  keyword_char: /[^\s\(\[\;\)\]]/,
47
47
  basic: /[\w\$_\-]/,
48
48
  lang_keyword: /[\w*+!\-_?:\/]/
@@ -64,14 +64,13 @@ CodeMirror.defineMode("clojure", function (config, mode) {
64
64
 
65
65
  function isNumber(ch, stream){
66
66
  // hex
67
- if ( ch === '0' && 'x' == stream.peek().toLowerCase() ) {
68
- stream.eat('x');
67
+ if ( ch === '0' && stream.eat(/x/i) ) {
69
68
  stream.eatWhile(tests.hex);
70
69
  return true;
71
70
  }
72
71
 
73
72
  // leading sign
74
- if ( ch == '+' || ch == '-' ) {
73
+ if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
75
74
  stream.eat(tests.sign);
76
75
  ch = stream.next();
77
76
  }
@@ -85,8 +84,7 @@ CodeMirror.defineMode("clojure", function (config, mode) {
85
84
  stream.eatWhile(tests.digit);
86
85
  }
87
86
 
88
- if ( 'e' == stream.peek().toLowerCase() ) {
89
- stream.eat(tests.exponent);
87
+ if ( stream.eat(tests.exponent) ) {
90
88
  stream.eat(tests.sign);
91
89
  stream.eatWhile(tests.digit);
92
90
  }
@@ -145,7 +143,7 @@ CodeMirror.defineMode("clojure", function (config, mode) {
145
143
  } else if (isNumber(ch,stream)){
146
144
  returnType = NUMBER;
147
145
  } else if (ch == "(" || ch == "[") {
148
- var keyWord = ''; var indentTemp = stream.column();
146
+ var keyWord = '', indentTemp = stream.column(), letter;
149
147
  /**
150
148
  Either
151
149
  (indent-word ..
@@ -157,7 +155,8 @@ CodeMirror.defineMode("clojure", function (config, mode) {
157
155
  keyWord += letter;
158
156
  }
159
157
 
160
- if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
158
+ if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) ||
159
+ /^(?:def|with)/.test(keyWord))) { // indent-word
161
160
  pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
162
161
  } else { // non-indent word
163
162
  // we continue eating the spaces
@@ -1,6 +1,7 @@
1
1
  <!doctype html>
2
2
  <html>
3
3
  <head>
4
+ <meta charset="utf-8">
4
5
  <title>CodeMirror: Clojure mode</title>
5
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
7
  <script src="../../lib/codemirror.js"></script>
@@ -187,7 +187,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
187
187
  }
188
188
  if (singleline) {
189
189
  if (conf.mode.singleLineStringErrors) {
190
- outclass = ERRORCLASS
190
+ outclass = ERRORCLASS;
191
191
  } else {
192
192
  state.tokenize = tokenBase;
193
193
  }
@@ -205,7 +205,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
205
205
  }
206
206
  stream.eatWhile("#");
207
207
  }
208
- return "comment"
208
+ return "comment";
209
209
  }
210
210
 
211
211
  function indent(stream, state, type) {
@@ -244,7 +244,7 @@ CodeMirror.defineMode('coffeescript', function(conf) {
244
244
  while (state.scopes[0].offset !== _indent) {
245
245
  state.scopes.shift();
246
246
  }
247
- return false
247
+ return false;
248
248
  } else {
249
249
  state.scopes.shift();
250
250
  return false;
@@ -1,6 +1,7 @@
1
1
  <!doctype html>
2
2
  <html>
3
3
  <head>
4
+ <meta charset="utf-8">
4
5
  <title>CodeMirror: CoffeeScript mode</title>
5
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
7
  <script src="../../lib/codemirror.js"></script>