codemirror-rails 3.24 → 4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +3001 -1798
  4. data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +24 -4
  5. data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +47 -32
  6. data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +9 -2
  7. data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.js +9 -2
  8. data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +9 -2
  9. data/vendor/assets/javascripts/codemirror/addons/display/rulers.js +9 -2
  10. data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +76 -37
  11. data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +59 -37
  12. data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -17
  13. data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +67 -46
  14. data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +10 -3
  15. data/vendor/assets/javascripts/codemirror/addons/edit/trailingspace.js +23 -14
  16. data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +12 -3
  17. data/vendor/assets/javascripts/codemirror/addons/fold/comment-fold.js +12 -0
  18. data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +28 -3
  19. data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +9 -2
  20. data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +12 -1
  21. data/vendor/assets/javascripts/codemirror/addons/fold/markdown-fold.js +12 -0
  22. data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +9 -4
  23. data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +9 -2
  24. data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +10 -3
  25. data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +11 -3
  26. data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +9 -4
  27. data/vendor/assets/javascripts/codemirror/addons/hint/python-hint.js +11 -3
  28. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +10 -4
  29. data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +9 -2
  30. data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +22 -34
  31. data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +12 -1
  32. data/vendor/assets/javascripts/codemirror/addons/lint/css-lint.js +12 -1
  33. data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +9 -4
  34. data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +12 -1
  35. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +12 -8
  36. data/vendor/assets/javascripts/codemirror/addons/lint/yaml-lint.js +12 -1
  37. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +18 -16
  38. data/vendor/assets/javascripts/codemirror/addons/mode/loadmode.js +9 -2
  39. data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +12 -0
  40. data/vendor/assets/javascripts/codemirror/addons/mode/overlay.js +15 -10
  41. data/vendor/assets/javascripts/codemirror/addons/runmode/colorize.js +11 -3
  42. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +0 -2
  43. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +12 -0
  44. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +4 -0
  45. data/vendor/assets/javascripts/codemirror/addons/scroll/scrollpastend.js +9 -2
  46. data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +12 -3
  47. data/vendor/assets/javascripts/codemirror/addons/search/search.js +24 -16
  48. data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +21 -2
  49. data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +38 -17
  50. data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +16 -9
  51. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +33 -5
  52. data/vendor/assets/javascripts/codemirror/addons/wrap/hardwrap.js +27 -2
  53. data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +12 -5
  54. data/vendor/assets/javascripts/codemirror/keymaps/sublime.js +505 -0
  55. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +138 -179
  56. data/vendor/assets/javascripts/codemirror/modes/apl.js +12 -0
  57. data/vendor/assets/javascripts/codemirror/modes/asterisk.js +12 -0
  58. data/vendor/assets/javascripts/codemirror/modes/clike.js +15 -4
  59. data/vendor/assets/javascripts/codemirror/modes/clojure.js +13 -0
  60. data/vendor/assets/javascripts/codemirror/modes/cobol.js +12 -0
  61. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +12 -0
  62. data/vendor/assets/javascripts/codemirror/modes/commonlisp.js +12 -0
  63. data/vendor/assets/javascripts/codemirror/modes/css.js +18 -27
  64. data/vendor/assets/javascripts/codemirror/modes/d.js +12 -2
  65. data/vendor/assets/javascripts/codemirror/modes/diff.js +12 -0
  66. data/vendor/assets/javascripts/codemirror/modes/dtd.js +12 -0
  67. data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -0
  68. data/vendor/assets/javascripts/codemirror/modes/eiffel.js +12 -0
  69. data/vendor/assets/javascripts/codemirror/modes/erlang.js +13 -1
  70. data/vendor/assets/javascripts/codemirror/modes/fortran.js +12 -0
  71. data/vendor/assets/javascripts/codemirror/modes/gas.js +12 -0
  72. data/vendor/assets/javascripts/codemirror/modes/gfm.js +12 -0
  73. data/vendor/assets/javascripts/codemirror/modes/gherkin.js +12 -0
  74. data/vendor/assets/javascripts/codemirror/modes/go.js +12 -1
  75. data/vendor/assets/javascripts/codemirror/modes/groovy.js +12 -0
  76. data/vendor/assets/javascripts/codemirror/modes/haml.js +12 -0
  77. data/vendor/assets/javascripts/codemirror/modes/haskell.js +12 -0
  78. data/vendor/assets/javascripts/codemirror/modes/haxe.js +18 -9
  79. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +12 -0
  80. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +12 -0
  81. data/vendor/assets/javascripts/codemirror/modes/http.js +12 -0
  82. data/vendor/assets/javascripts/codemirror/modes/jade.js +12 -0
  83. data/vendor/assets/javascripts/codemirror/modes/javascript.js +23 -16
  84. data/vendor/assets/javascripts/codemirror/modes/jinja2.js +53 -118
  85. data/vendor/assets/javascripts/codemirror/modes/julia.js +12 -0
  86. data/vendor/assets/javascripts/codemirror/modes/livescript.js +17 -4
  87. data/vendor/assets/javascripts/codemirror/modes/lua.js +12 -0
  88. data/vendor/assets/javascripts/codemirror/modes/markdown.js +12 -0
  89. data/vendor/assets/javascripts/codemirror/modes/mirc.js +13 -0
  90. data/vendor/assets/javascripts/codemirror/modes/mllike.js +12 -1
  91. data/vendor/assets/javascripts/codemirror/modes/nginx.js +12 -0
  92. data/vendor/assets/javascripts/codemirror/modes/ntriples.js +13 -0
  93. data/vendor/assets/javascripts/codemirror/modes/octave.js +12 -0
  94. data/vendor/assets/javascripts/codemirror/modes/pascal.js +12 -0
  95. data/vendor/assets/javascripts/codemirror/modes/pegjs.js +12 -0
  96. data/vendor/assets/javascripts/codemirror/modes/perl.js +84 -73
  97. data/vendor/assets/javascripts/codemirror/modes/php.js +20 -101
  98. data/vendor/assets/javascripts/codemirror/modes/pig.js +12 -0
  99. data/vendor/assets/javascripts/codemirror/modes/properties.js +12 -0
  100. data/vendor/assets/javascripts/codemirror/modes/puppet.js +13 -0
  101. data/vendor/assets/javascripts/codemirror/modes/python.js +21 -11
  102. data/vendor/assets/javascripts/codemirror/modes/q.js +12 -0
  103. data/vendor/assets/javascripts/codemirror/modes/r.js +13 -3
  104. data/vendor/assets/javascripts/codemirror/modes/{rpm-spec.js → rpm.js} +34 -2
  105. data/vendor/assets/javascripts/codemirror/modes/rst.js +12 -0
  106. data/vendor/assets/javascripts/codemirror/modes/ruby.js +11 -0
  107. data/vendor/assets/javascripts/codemirror/modes/rust.js +12 -0
  108. data/vendor/assets/javascripts/codemirror/modes/sass.js +12 -0
  109. data/vendor/assets/javascripts/codemirror/modes/scheme.js +13 -0
  110. data/vendor/assets/javascripts/codemirror/modes/shell.js +12 -0
  111. data/vendor/assets/javascripts/codemirror/modes/sieve.js +11 -4
  112. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +12 -0
  113. data/vendor/assets/javascripts/codemirror/modes/smarty.js +13 -0
  114. data/vendor/assets/javascripts/codemirror/modes/smartymixed.js +14 -2
  115. data/vendor/assets/javascripts/codemirror/modes/solr.js +12 -0
  116. data/vendor/assets/javascripts/codemirror/modes/sparql.js +12 -0
  117. data/vendor/assets/javascripts/codemirror/modes/sql.js +12 -0
  118. data/vendor/assets/javascripts/codemirror/modes/stex.js +12 -0
  119. data/vendor/assets/javascripts/codemirror/modes/tcl.js +13 -0
  120. data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +13 -0
  121. data/vendor/assets/javascripts/codemirror/modes/tiki.js +12 -0
  122. data/vendor/assets/javascripts/codemirror/modes/toml.js +12 -0
  123. data/vendor/assets/javascripts/codemirror/modes/turtle.js +12 -0
  124. data/vendor/assets/javascripts/codemirror/modes/vb.js +12 -0
  125. data/vendor/assets/javascripts/codemirror/modes/vbscript.js +13 -0
  126. data/vendor/assets/javascripts/codemirror/modes/velocity.js +12 -0
  127. data/vendor/assets/javascripts/codemirror/modes/verilog.js +89 -236
  128. data/vendor/assets/javascripts/codemirror/modes/xml.js +41 -60
  129. data/vendor/assets/javascripts/codemirror/modes/xquery.js +12 -0
  130. data/vendor/assets/javascripts/codemirror/modes/yaml.js +12 -0
  131. data/vendor/assets/javascripts/codemirror/modes/z80.js +12 -0
  132. data/vendor/assets/stylesheets/codemirror.css +15 -10
  133. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +1 -0
  134. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +4 -0
  135. data/vendor/assets/stylesheets/codemirror/themes/mdn-like.css +1 -1
  136. data/vendor/assets/stylesheets/codemirror/themes/pastel-on-dark.css +1 -0
  137. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -0
  138. data/vendor/assets/stylesheets/codemirror/themes/solarized.css +17 -3
  139. metadata +20 -25
  140. data/vendor/assets/javascripts/codemirror/keymaps/extra.js +0 -43
  141. data/vendor/assets/javascripts/codemirror/modes/django.js +0 -55
  142. data/vendor/assets/javascripts/codemirror/modes/dylan.js +0 -284
  143. data/vendor/assets/javascripts/codemirror/modes/less.js +0 -347
  144. data/vendor/assets/javascripts/codemirror/modes/rpm-changes.js +0 -19
  145. data/vendor/assets/stylesheets/codemirror/modes/rpm-spec.css +0 -5
@@ -1,27 +1,35 @@
1
- (function() {
2
- 'use strict';
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
9
+ "use strict";
3
10
 
4
11
  var listRE = /^(\s*)([*+-]|(\d+)\.)(\s*)/,
5
- unorderedBullets = '*+-';
12
+ unorderedBullets = "*+-";
6
13
 
7
14
  CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
8
15
  if (cm.getOption("disableInput")) return CodeMirror.Pass;
16
+ var ranges = cm.listSelections(), replacements = [];
17
+ for (var i = 0; i < ranges.length; i++) {
18
+ var pos = ranges[i].head, match;
19
+ var inList = cm.getStateAfter(pos.line).list !== false;
9
20
 
10
- var pos = cm.getCursor(),
11
- inList = cm.getStateAfter(pos.line).list !== false,
12
- match;
21
+ if (!ranges[i].empty() || !inList || !(match = cm.getLine(pos.line).match(listRE))) {
22
+ cm.execCommand("newlineAndIndent");
23
+ return;
24
+ }
25
+ var indent = match[1], after = match[4];
26
+ var bullet = unorderedBullets.indexOf(match[2]) >= 0
27
+ ? match[2]
28
+ : (parseInt(match[3], 10) + 1) + ".";
13
29
 
14
- if (!inList || !(match = cm.getLine(pos.line).match(listRE))) {
15
- cm.execCommand('newlineAndIndent');
16
- return;
30
+ replacements[i] = "\n" + indent + bullet + after;
17
31
  }
18
32
 
19
- var indent = match[1], after = match[4];
20
- var bullet = unorderedBullets.indexOf(match[2]) >= 0
21
- ? match[2]
22
- : (parseInt(match[3], 10) + 1) + '.';
23
-
24
- cm.replaceSelection('\n' + indent + bullet + after, 'end');
33
+ cm.replaceSelections(replacements);
25
34
  };
26
-
27
- }());
35
+ });
@@ -1,73 +1,91 @@
1
- (function() {
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
2
9
  var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
3
10
  (document.documentMode == null || document.documentMode < 8);
4
11
 
5
12
  var Pos = CodeMirror.Pos;
6
13
 
7
14
  var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
8
- function findMatchingBracket(cm, where, strict) {
9
- var state = cm.state.matchBrackets;
10
- var maxScanLen = (state && state.maxScanLineLength) || 10000;
11
- var maxScanLines = (state && state.maxScanLines) || 100;
12
15
 
13
- var cur = where || cm.getCursor(), line = cm.getLineHandle(cur.line), pos = cur.ch - 1;
16
+ function findMatchingBracket(cm, where, strict, config) {
17
+ var line = cm.getLineHandle(where.line), pos = where.ch - 1;
14
18
  var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
15
19
  if (!match) return null;
16
- var forward = match.charAt(1) == ">", d = forward ? 1 : -1;
17
- if (strict && forward != (pos == cur.ch)) return null;
18
- var style = cm.getTokenTypeAt(Pos(cur.line, pos + 1));
20
+ var dir = match.charAt(1) == ">" ? 1 : -1;
21
+ if (strict && (dir > 0) != (pos == where.ch)) return null;
22
+ var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
19
23
 
20
- var stack = [line.text.charAt(pos)], re = /[(){}[\]]/;
21
- function scan(line, lineNo, start) {
22
- if (!line.text) return;
23
- var pos = forward ? 0 : line.text.length - 1, end = forward ? line.text.length : -1;
24
- if (line.text.length > maxScanLen) return null;
25
- if (start != null) pos = start + d;
26
- for (; pos != end; pos += d) {
27
- var ch = line.text.charAt(pos);
28
- if (re.test(ch) && cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style) {
24
+ var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
25
+ return {from: Pos(where.line, pos), to: found && found.pos,
26
+ match: found && found.ch == match.charAt(0), forward: dir > 0};
27
+ }
28
+
29
+ function scanForBracket(cm, where, dir, style, config) {
30
+ var maxScanLen = (config && config.maxScanLineLength) || 10000;
31
+ var maxScanLines = (config && config.maxScanLines) || 500;
32
+
33
+ var stack = [], re = /[(){}[\]]/;
34
+ var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
35
+ : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
36
+ for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
37
+ var line = cm.getLine(lineNo);
38
+ if (!line) continue;
39
+ var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
40
+ if (line.length > maxScanLen) continue;
41
+ if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
42
+ for (; pos != end; pos += dir) {
43
+ var ch = line.charAt(pos);
44
+ if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
29
45
  var match = matching[ch];
30
- if (match.charAt(1) == ">" == forward) stack.push(ch);
31
- else if (stack.pop() != match.charAt(0)) return {pos: pos, match: false};
32
- else if (!stack.length) return {pos: pos, match: true};
46
+ if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
47
+ else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
48
+ else stack.pop();
33
49
  }
34
50
  }
35
51
  }
36
- for (var i = cur.line, found, e = forward ? Math.min(i + maxScanLines, cm.lineCount()) : Math.max(-1, i - maxScanLines); i != e; i+=d) {
37
- if (i == cur.line) found = scan(line, i, pos);
38
- else found = scan(cm.getLineHandle(i), i);
39
- if (found) break;
40
- }
41
- return {from: Pos(cur.line, pos), to: found && Pos(i, found.pos),
42
- match: found && found.match, forward: forward};
43
52
  }
44
53
 
45
- function matchBrackets(cm, autoclear) {
54
+ function matchBrackets(cm, autoclear, config) {
46
55
  // Disable brace matching in long lines, since it'll cause hugely slow updates
47
56
  var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
48
- var found = findMatchingBracket(cm);
49
- if (!found || cm.getLine(found.from.line).length > maxHighlightLen ||
50
- found.to && cm.getLine(found.to.line).length > maxHighlightLen)
51
- return;
57
+ var marks = [], ranges = cm.listSelections();
58
+ for (var i = 0; i < ranges.length; i++) {
59
+ var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config);
60
+ if (match && cm.getLine(match.from.line).length <= maxHighlightLen &&
61
+ match.to && cm.getLine(match.to.line).length <= maxHighlightLen) {
62
+ var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
63
+ marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
64
+ if (match.to)
65
+ marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
66
+ }
67
+ }
68
+
69
+ if (marks.length) {
70
+ // Kludge to work around the IE bug from issue #1193, where text
71
+ // input stops going to the textare whever this fires.
72
+ if (ie_lt8 && cm.state.focused) cm.display.input.focus();
52
73
 
53
- var style = found.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
54
- var one = cm.markText(found.from, Pos(found.from.line, found.from.ch + 1), {className: style});
55
- var two = found.to && cm.markText(found.to, Pos(found.to.line, found.to.ch + 1), {className: style});
56
- // Kludge to work around the IE bug from issue #1193, where text
57
- // input stops going to the textarea whenever this fires.
58
- if (ie_lt8 && cm.state.focused) cm.display.input.focus();
59
- var clear = function() {
60
- cm.operation(function() { one.clear(); two && two.clear(); });
61
- };
62
- if (autoclear) setTimeout(clear, 800);
63
- else return clear;
74
+ var clear = function() {
75
+ cm.operation(function() {
76
+ for (var i = 0; i < marks.length; i++) marks[i].clear();
77
+ });
78
+ };
79
+ if (autoclear) setTimeout(clear, 800);
80
+ else return clear;
81
+ }
64
82
  }
65
83
 
66
84
  var currentlyHighlighted = null;
67
85
  function doMatchBrackets(cm) {
68
86
  cm.operation(function() {
69
87
  if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
70
- if (!cm.somethingSelected()) currentlyHighlighted = matchBrackets(cm, false);
88
+ currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
71
89
  });
72
90
  }
73
91
 
@@ -84,4 +102,7 @@
84
102
  CodeMirror.defineExtension("findMatchingBracket", function(pos, strict){
85
103
  return findMatchingBracket(this, pos, strict);
86
104
  });
87
- })();
105
+ CodeMirror.defineExtension("scanForBracket", function(pos, dir, style){
106
+ return scanForBracket(this, pos, dir, style);
107
+ });
108
+ });
@@ -1,4 +1,11 @@
1
- (function() {
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror", "../fold/xml-fold"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
2
9
  "use strict";
3
10
 
4
11
  CodeMirror.defineOption("matchTags", false, function(cm, val, old) {
@@ -50,7 +57,7 @@
50
57
  var found = CodeMirror.findMatchingTag(cm, cm.getCursor());
51
58
  if (found) {
52
59
  var other = found.at == "close" ? found.open : found.close;
53
- if (other) cm.setSelection(other.to, other.from);
60
+ if (other) cm.extendSelection(other.to, other.from);
54
61
  }
55
62
  };
56
- })();
63
+ });
@@ -1,15 +1,24 @@
1
- CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
2
- if (prev == CodeMirror.Init) prev = false;
3
- if (prev && !val)
4
- cm.removeOverlay("trailingspace");
5
- else if (!prev && val)
6
- cm.addOverlay({
7
- token: function(stream) {
8
- for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
9
- if (i > stream.pos) { stream.pos = i; return null; }
10
- stream.pos = l;
11
- return "trailingspace";
12
- },
13
- name: "trailingspace"
14
- });
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
9
+ CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
10
+ if (prev == CodeMirror.Init) prev = false;
11
+ if (prev && !val)
12
+ cm.removeOverlay("trailingspace");
13
+ else if (!prev && val)
14
+ cm.addOverlay({
15
+ token: function(stream) {
16
+ for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
17
+ if (i > stream.pos) { stream.pos = i; return null; }
18
+ stream.pos = l;
19
+ return "trailingspace";
20
+ },
21
+ name: "trailingspace"
22
+ });
23
+ });
15
24
  });
@@ -1,3 +1,13 @@
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
9
+ "use strict";
10
+
1
11
  CodeMirror.registerHelper("fold", "brace", function(cm, start) {
2
12
  var line = start.line, lineText = cm.getLine(line);
3
13
  var startCh, tokenType;
@@ -45,7 +55,6 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) {
45
55
  return {from: CodeMirror.Pos(line, startCh),
46
56
  to: CodeMirror.Pos(end, endCh)};
47
57
  });
48
- CodeMirror.braceRangeFinder = CodeMirror.fold.brace; // deprecated
49
58
 
50
59
  CodeMirror.registerHelper("fold", "import", function(cm, start) {
51
60
  function hasImport(line) {
@@ -70,7 +79,6 @@ CodeMirror.registerHelper("fold", "import", function(cm, start) {
70
79
  }
71
80
  return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
72
81
  });
73
- CodeMirror.importRangeFinder = CodeMirror.fold["import"]; // deprecated
74
82
 
75
83
  CodeMirror.registerHelper("fold", "include", function(cm, start) {
76
84
  function hasInclude(line) {
@@ -90,4 +98,5 @@ CodeMirror.registerHelper("fold", "include", function(cm, start) {
90
98
  return {from: CodeMirror.Pos(start, has + 1),
91
99
  to: cm.clipPos(CodeMirror.Pos(end))};
92
100
  });
93
- CodeMirror.includeRangeFinder = CodeMirror.fold.include; // deprecated
101
+
102
+ });
@@ -1,3 +1,13 @@
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
9
+ "use strict";
10
+
1
11
  CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
2
12
  return mode.blockCommentStart && mode.blockCommentEnd;
3
13
  }, function(cm, start) {
@@ -40,3 +50,5 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
40
50
  return {from: CodeMirror.Pos(line, startCh),
41
51
  to: CodeMirror.Pos(end, endCh)};
42
52
  });
53
+
54
+ });
@@ -1,4 +1,11 @@
1
- (function() {
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
2
9
  "use strict";
3
10
 
4
11
  function doFold(cm, pos, options, force) {
@@ -68,9 +75,27 @@
68
75
  if (marks[i].__isFold) return true;
69
76
  });
70
77
 
71
- CodeMirror.commands.fold = function(cm) {
78
+ CodeMirror.commands.toggleFold = function(cm) {
72
79
  cm.foldCode(cm.getCursor());
73
80
  };
81
+ CodeMirror.commands.fold = function(cm) {
82
+ cm.foldCode(cm.getCursor(), null, "fold");
83
+ };
84
+ CodeMirror.commands.unfold = function(cm) {
85
+ cm.foldCode(cm.getCursor(), null, "unfold");
86
+ };
87
+ CodeMirror.commands.foldAll = function(cm) {
88
+ cm.operation(function() {
89
+ for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
90
+ cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
91
+ });
92
+ };
93
+ CodeMirror.commands.unfoldAll = function(cm) {
94
+ cm.operation(function() {
95
+ for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
96
+ cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
97
+ });
98
+ };
74
99
 
75
100
  CodeMirror.registerHelper("fold", "combine", function() {
76
101
  var funcs = Array.prototype.slice.call(arguments, 0);
@@ -89,4 +114,4 @@
89
114
  if (cur) return cur;
90
115
  }
91
116
  });
92
- })();
117
+ });
@@ -1,4 +1,11 @@
1
- (function() {
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"), require("./foldcode"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror", "./foldcode"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
2
9
  "use strict";
3
10
 
4
11
  CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
@@ -121,4 +128,4 @@
121
128
  if (line >= state.from && line < state.to)
122
129
  updateFoldInfo(cm, line, line + 1);
123
130
  }
124
- })();
131
+ });
@@ -1,3 +1,13 @@
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
9
+ "use strict";
10
+
1
11
  CodeMirror.registerHelper("fold", "indent", function(cm, start) {
2
12
  var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
3
13
  if (!/\S/.test(firstLine)) return;
@@ -27,4 +37,5 @@ CodeMirror.registerHelper("fold", "indent", function(cm, start) {
27
37
  to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
28
38
  };
29
39
  });
30
- CodeMirror.indentRangeFinder = CodeMirror.fold.indent; // deprecated
40
+
41
+ });
@@ -1,3 +1,13 @@
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
9
+ "use strict";
10
+
1
11
  CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
2
12
  var maxDepth = 100;
3
13
 
@@ -32,3 +42,5 @@ CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
32
42
  to: CodeMirror.Pos(end, cm.getLine(end).length)
33
43
  };
34
44
  });
45
+
46
+ });
@@ -1,4 +1,11 @@
1
- (function() {
1
+ (function(mod) {
2
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
3
+ mod(require("../../lib/codemirror"));
4
+ else if (typeof define == "function" && define.amd) // AMD
5
+ define(["../../lib/codemirror"], mod);
6
+ else // Plain browser env
7
+ mod(CodeMirror);
8
+ })(function(CodeMirror) {
2
9
  "use strict";
3
10
 
4
11
  var Pos = CodeMirror.Pos;
@@ -136,8 +143,6 @@
136
143
  }
137
144
  }
138
145
  });
139
- CodeMirror.tagRangeFinder = CodeMirror.fold.xml; // deprecated
140
-
141
146
  CodeMirror.findMatchingTag = function(cm, pos, range) {
142
147
  var iter = new Iter(cm, pos.line, pos.ch, range);
143
148
  if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
@@ -170,4 +175,4 @@
170
175
  var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null);
171
176
  return !!findMatchingClose(iter, name);
172
177
  };
173
- })();
178
+ });