ace-rails-ap 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -1
  3. data/lib/ace/rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/ace/ace.js +6911 -5290
  5. data/vendor/assets/javascripts/ace/ext-chromevox.js +537 -0
  6. data/vendor/assets/javascripts/ace/ext-elastic_tabstops_lite.js +301 -0
  7. data/vendor/assets/javascripts/ace/ext-emmet.js +1109 -0
  8. data/vendor/assets/javascripts/ace/ext-keybinding_menu.js +207 -0
  9. data/vendor/assets/javascripts/ace/ext-language_tools.js +1665 -0
  10. data/vendor/assets/javascripts/ace/ext-modelist.js +168 -0
  11. data/vendor/assets/javascripts/ace/ext-old_ie.js +500 -0
  12. data/vendor/assets/javascripts/ace/ext-options.js +252 -0
  13. data/vendor/assets/javascripts/ace/ext-searchbox.js +421 -0
  14. data/vendor/assets/javascripts/ace/ext-settings_menu.js +632 -0
  15. data/vendor/assets/javascripts/ace/ext-spellcheck.js +68 -0
  16. data/vendor/assets/javascripts/ace/ext-split.js +271 -0
  17. data/vendor/assets/javascripts/ace/ext-static_highlight.js +178 -0
  18. data/vendor/assets/javascripts/ace/ext-statusbar.js +47 -0
  19. data/vendor/assets/javascripts/ace/ext-textarea.js +478 -0
  20. data/vendor/assets/javascripts/ace/ext-themelist.js +86 -0
  21. data/vendor/assets/javascripts/ace/ext-whitespace.js +206 -0
  22. data/vendor/assets/javascripts/ace/keybinding-emacs.js +822 -131
  23. data/vendor/assets/javascripts/ace/keybinding-vim.js +382 -258
  24. data/vendor/assets/javascripts/ace/mode-abap.js +261 -0
  25. data/vendor/assets/javascripts/ace/mode-actionscript.js +257 -0
  26. data/vendor/assets/javascripts/ace/mode-ada.js +118 -0
  27. data/vendor/assets/javascripts/ace/mode-asciidoc.js +373 -0
  28. data/vendor/assets/javascripts/ace/mode-assembly_x86.js +217 -0
  29. data/vendor/assets/javascripts/ace/mode-autohotkey.js +225 -0
  30. data/vendor/assets/javascripts/ace/mode-batchfile.js +213 -0
  31. data/vendor/assets/javascripts/ace/mode-c9search.js +144 -124
  32. data/vendor/assets/javascripts/ace/mode-c_cpp.js +296 -254
  33. data/vendor/assets/javascripts/ace/mode-clojure.js +113 -177
  34. data/vendor/assets/javascripts/ace/mode-cobol.js +125 -0
  35. data/vendor/assets/javascripts/ace/mode-coffee.js +152 -235
  36. data/vendor/assets/javascripts/ace/mode-coldfusion.js +823 -835
  37. data/vendor/assets/javascripts/ace/mode-csharp.js +325 -187
  38. data/vendor/assets/javascripts/ace/mode-css.js +583 -297
  39. data/vendor/assets/javascripts/ace/mode-curly.js +2423 -0
  40. data/vendor/assets/javascripts/ace/mode-d.js +492 -0
  41. data/vendor/assets/javascripts/ace/mode-dart.js +993 -0
  42. data/vendor/assets/javascripts/ace/mode-diff.js +124 -204
  43. data/vendor/assets/javascripts/ace/mode-django.js +2448 -0
  44. data/vendor/assets/javascripts/ace/mode-dot.js +361 -0
  45. data/vendor/assets/javascripts/ace/mode-ejs.js +2817 -0
  46. data/vendor/assets/javascripts/ace/mode-erlang.js +987 -0
  47. data/vendor/assets/javascripts/ace/mode-forth.js +280 -0
  48. data/vendor/assets/javascripts/ace/mode-ftl.js +1061 -0
  49. data/vendor/assets/javascripts/ace/mode-glsl.js +313 -275
  50. data/vendor/assets/javascripts/ace/mode-golang.js +268 -275
  51. data/vendor/assets/javascripts/ace/mode-groovy.js +347 -492
  52. data/vendor/assets/javascripts/ace/mode-haml.js +498 -0
  53. data/vendor/assets/javascripts/ace/mode-handlebars.js +2433 -0
  54. data/vendor/assets/javascripts/ace/mode-haskell.js +362 -0
  55. data/vendor/assets/javascripts/ace/mode-haxe.js +226 -202
  56. data/vendor/assets/javascripts/ace/mode-html.js +1099 -802
  57. data/vendor/assets/javascripts/ace/mode-html_completions.js +309 -0
  58. data/vendor/assets/javascripts/ace/mode-html_ruby.js +2822 -0
  59. data/vendor/assets/javascripts/ace/mode-ini.js +185 -0
  60. data/vendor/assets/javascripts/ace/mode-jack.js +653 -0
  61. data/vendor/assets/javascripts/ace/mode-jade.js +2081 -0
  62. data/vendor/assets/javascripts/ace/mode-java.js +339 -488
  63. data/vendor/assets/javascripts/ace/mode-javascript.js +342 -478
  64. data/vendor/assets/javascripts/ace/mode-json.js +215 -178
  65. data/vendor/assets/javascripts/ace/mode-jsoniq.js +2761 -0
  66. data/vendor/assets/javascripts/ace/mode-jsp.js +1553 -0
  67. data/vendor/assets/javascripts/ace/mode-jsx.js +325 -289
  68. data/vendor/assets/javascripts/ace/mode-julia.js +286 -0
  69. data/vendor/assets/javascripts/ace/mode-latex.js +141 -46
  70. data/vendor/assets/javascripts/ace/mode-less.js +493 -151
  71. data/vendor/assets/javascripts/ace/mode-liquid.js +594 -656
  72. data/vendor/assets/javascripts/ace/mode-lisp.js +137 -0
  73. data/vendor/assets/javascripts/ace/mode-livescript.js +288 -0
  74. data/vendor/assets/javascripts/ace/mode-logiql.js +669 -0
  75. data/vendor/assets/javascripts/ace/mode-lsl.js +890 -0
  76. data/vendor/assets/javascripts/ace/mode-lua.js +274 -368
  77. data/vendor/assets/javascripts/ace/mode-luapage.js +1331 -1107
  78. data/vendor/assets/javascripts/ace/mode-lucene.js +64 -0
  79. data/vendor/assets/javascripts/ace/mode-makefile.js +332 -0
  80. data/vendor/assets/javascripts/ace/mode-markdown.js +1303 -948
  81. data/vendor/assets/javascripts/ace/mode-matlab.js +230 -0
  82. data/vendor/assets/javascripts/ace/mode-mushcode.js +705 -0
  83. data/vendor/assets/javascripts/ace/mode-mushcode_high_rules.js +569 -0
  84. data/vendor/assets/javascripts/ace/mode-mysql.js +185 -0
  85. data/vendor/assets/javascripts/ace/mode-nix.js +935 -0
  86. data/vendor/assets/javascripts/ace/mode-objectivec.js +699 -0
  87. data/vendor/assets/javascripts/ace/mode-ocaml.js +44 -63
  88. data/vendor/assets/javascripts/ace/mode-pascal.js +233 -0
  89. data/vendor/assets/javascripts/ace/mode-perl.js +116 -189
  90. data/vendor/assets/javascripts/ace/mode-pgsql.js +886 -500
  91. data/vendor/assets/javascripts/ace/mode-php.js +1158 -380
  92. data/vendor/assets/javascripts/ace/mode-plain_text.js +56 -0
  93. data/vendor/assets/javascripts/ace/mode-powershell.js +222 -167
  94. data/vendor/assets/javascripts/ace/mode-prolog.js +354 -0
  95. data/vendor/assets/javascripts/ace/mode-properties.js +100 -0
  96. data/vendor/assets/javascripts/ace/mode-protobuf.js +885 -0
  97. data/vendor/assets/javascripts/ace/mode-python.js +99 -201
  98. data/vendor/assets/javascripts/ace/mode-r.js +337 -0
  99. data/vendor/assets/javascripts/ace/mode-rdoc.js +210 -0
  100. data/vendor/assets/javascripts/ace/mode-rhtml.js +2663 -0
  101. data/vendor/assets/javascripts/ace/mode-ruby.js +262 -136
  102. data/vendor/assets/javascripts/ace/mode-rust.js +245 -0
  103. data/vendor/assets/javascripts/ace/mode-sass.js +443 -0
  104. data/vendor/assets/javascripts/ace/mode-scad.js +225 -240
  105. data/vendor/assets/javascripts/ace/mode-scala.js +340 -494
  106. data/vendor/assets/javascripts/ace/mode-scheme.js +143 -0
  107. data/vendor/assets/javascripts/ace/mode-scss.js +499 -157
  108. data/vendor/assets/javascripts/ace/mode-sh.js +180 -110
  109. data/vendor/assets/javascripts/ace/mode-sjs.js +1154 -0
  110. data/vendor/assets/javascripts/ace/mode-snippets.js +198 -0
  111. data/vendor/assets/javascripts/ace/mode-soy_template.js +2707 -0
  112. data/vendor/assets/javascripts/ace/mode-space.js +160 -0
  113. data/vendor/assets/javascripts/ace/mode-sql.js +48 -69
  114. data/vendor/assets/javascripts/ace/mode-stylus.js +447 -0
  115. data/vendor/assets/javascripts/ace/mode-svg.js +552 -605
  116. data/vendor/assets/javascripts/ace/mode-tcl.js +139 -98
  117. data/vendor/assets/javascripts/ace/mode-tex.js +187 -0
  118. data/vendor/assets/javascripts/ace/mode-textile.js +29 -40
  119. data/vendor/assets/javascripts/ace/mode-tmsnippet.js +200 -0
  120. data/vendor/assets/javascripts/ace/mode-toml.js +177 -0
  121. data/vendor/assets/javascripts/ace/mode-twig.js +2228 -0
  122. data/vendor/assets/javascripts/ace/mode-typescript.js +1018 -0
  123. data/vendor/assets/javascripts/ace/mode-vbscript.js +250 -0
  124. data/vendor/assets/javascripts/ace/mode-velocity.js +1621 -0
  125. data/vendor/assets/javascripts/ace/mode-verilog.js +127 -0
  126. data/vendor/assets/javascripts/ace/mode-vhdl.js +139 -0
  127. data/vendor/assets/javascripts/ace/mode-xml.js +350 -242
  128. data/vendor/assets/javascripts/ace/mode-xquery.js +2490 -300
  129. data/vendor/assets/javascripts/ace/mode-yaml.js +146 -45
  130. data/vendor/assets/javascripts/ace/theme-ambiance.js +202 -0
  131. data/vendor/assets/javascripts/ace/theme-chaos.js +179 -0
  132. data/vendor/assets/javascripts/ace/theme-chrome.js +97 -153
  133. data/vendor/assets/javascripts/ace/theme-clouds.js +78 -119
  134. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +79 -120
  135. data/vendor/assets/javascripts/ace/theme-cobalt.js +89 -140
  136. data/vendor/assets/javascripts/ace/theme-crimson_editor.js +93 -145
  137. data/vendor/assets/javascripts/ace/theme-dawn.js +84 -143
  138. data/vendor/assets/javascripts/ace/theme-dreamweaver.js +99 -162
  139. data/vendor/assets/javascripts/ace/theme-eclipse.js +78 -111
  140. data/vendor/assets/javascripts/ace/theme-github.js +70 -121
  141. data/vendor/assets/javascripts/ace/theme-idle_fingers.js +75 -134
  142. data/vendor/assets/javascripts/ace/theme-kr.js +135 -0
  143. data/vendor/assets/javascripts/ace/theme-merbivore.js +80 -143
  144. data/vendor/assets/javascripts/ace/theme-merbivore_soft.js +81 -149
  145. data/vendor/assets/javascripts/ace/theme-mono_industrial.js +87 -146
  146. data/vendor/assets/javascripts/ace/theme-monokai.js +88 -146
  147. data/vendor/assets/javascripts/ace/theme-pastel_on_dark.js +82 -142
  148. data/vendor/assets/javascripts/ace/theme-solarized_dark.js +83 -144
  149. data/vendor/assets/javascripts/ace/theme-solarized_light.js +76 -133
  150. data/vendor/assets/javascripts/ace/theme-terminal.js +145 -0
  151. data/vendor/assets/javascripts/ace/theme-textmate.js +101 -158
  152. data/vendor/assets/javascripts/ace/theme-tomorrow.js +89 -163
  153. data/vendor/assets/javascripts/ace/theme-tomorrow_night.js +89 -163
  154. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue.js +89 -165
  155. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright.js +101 -162
  156. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties.js +90 -160
  157. data/vendor/assets/javascripts/ace/theme-twilight.js +87 -158
  158. data/vendor/assets/javascripts/ace/theme-vibrant_ink.js +75 -140
  159. data/vendor/assets/javascripts/ace/theme-xcode.js +120 -0
  160. data/vendor/assets/javascripts/ace/worker-coffee.js +3049 -2665
  161. data/vendor/assets/javascripts/ace/worker-css.js +1779 -4376
  162. data/vendor/assets/javascripts/ace/worker-javascript.js +8701 -9008
  163. data/vendor/assets/javascripts/ace/worker-json.js +709 -1340
  164. data/vendor/assets/javascripts/ace/worker-lua.js +3525 -0
  165. data/vendor/assets/javascripts/ace/worker-php.js +6893 -0
  166. data/vendor/assets/javascripts/ace/worker-xquery.js +19924 -64507
  167. metadata +100 -17
@@ -1,37 +1,30 @@
1
1
  /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2
+ * Distributed under the BSD license:
3
3
  *
4
- * The contents of this file are subject to the Mozilla Public License Version
5
- * 1.1 (the "License"); you may not use this file except in compliance with
6
- * the License. You may obtain a copy of the License at
7
- * http://www.mozilla.org/MPL/
8
- *
9
- * Software distributed under the License is distributed on an "AS IS" basis,
10
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
- * for the specific language governing rights and limitations under the
12
- * License.
13
- *
14
- * The Original Code is Ajax.org Code Editor (ACE).
15
- *
16
- * The Initial Developer of the Original Code is
17
- * Ajax.org B.V.
18
- * Portions created by the Initial Developer are Copyright (C) 2010
19
- * the Initial Developer. All Rights Reserved.
20
- *
21
- * Contributor(s):
22
- * Sergi Mansilla <sergi AT ajax DOT org>
23
- *
24
- * Alternatively, the contents of this file may be used under the terms of
25
- * either the GNU General Public License Version 2 or later (the "GPL"), or
26
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
- * in which case the provisions of the GPL or the LGPL are applicable instead
28
- * of those above. If you wish to allow use of your version of this file only
29
- * under the terms of either the GPL or the LGPL, and not to allow others to
30
- * use your version of this file under the terms of the MPL, indicate your
31
- * decision by deleting the provisions above and replace them with the notice
32
- * and other provisions required by the GPL or the LGPL. If you do not delete
33
- * the provisions above, a recipient may use your version of this file under
34
- * the terms of any one of the MPL, the GPL or the LGPL.
4
+ * Copyright (c) 2010, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
28
  *
36
29
  * ***** END LICENSE BLOCK ***** */
37
30
 
@@ -46,7 +39,8 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd
46
39
  var Range = require("../range").Range;
47
40
 
48
41
  var Mode = function() {
49
- this.$tokenizer = new Tokenizer(new OcamlHighlightRules().getRules());
42
+ this.HighlightRules = OcamlHighlightRules;
43
+
50
44
  this.$outdent = new MatchingBraceOutdent();
51
45
  };
52
46
  oop.inherits(Mode, TextMode);
@@ -80,7 +74,7 @@ var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|with))\s*$/;
80
74
 
81
75
  this.getNextLineIndent = function(state, line, tab) {
82
76
  var indent = this.$getIndent(line);
83
- var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
77
+ var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
84
78
 
85
79
  if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') &&
86
80
  state === 'start' && indenter.test(line))
@@ -96,33 +90,31 @@ var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|with))\s*$/;
96
90
  this.$outdent.autoOutdent(doc, row);
97
91
  };
98
92
 
93
+ this.$id = "ace/mode/ocaml";
99
94
  }).call(Mode.prototype);
100
95
 
101
96
  exports.Mode = Mode;
102
97
  });
103
98
 
104
- define('ace/mode/ocaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
99
+ define('ace/mode/ocaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
105
100
 
106
101
 
107
102
  var oop = require("../lib/oop");
108
- var lang = require("../lib/lang");
109
103
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
110
104
 
111
105
  var OcamlHighlightRules = function() {
112
106
 
113
- var keywords = lang.arrayToMap((
107
+ var keywords = (
114
108
  "and|as|assert|begin|class|constraint|do|done|downto|else|end|" +
115
109
  "exception|external|for|fun|function|functor|if|in|include|" +
116
110
  "inherit|initializer|lazy|let|match|method|module|mutable|new|" +
117
111
  "object|of|open|or|private|rec|sig|struct|then|to|try|type|val|" +
118
- "virtual|when|while|with").split("|")
112
+ "virtual|when|while|with"
119
113
  );
120
114
 
121
- var builtinConstants = lang.arrayToMap(
122
- ("true|false").split("|")
123
- );
115
+ var builtinConstants = ("true|false");
124
116
 
125
- var builtinFunctions = lang.arrayToMap((
117
+ var builtinFunctions = (
126
118
  "abs|abs_big_int|abs_float|abs_num|abstract_tag|accept|access|acos|add|" +
127
119
  "add_available_units|add_big_int|add_buffer|add_channel|add_char|" +
128
120
  "add_initializer|add_int_big_int|add_interfaces|add_num|add_string|" +
@@ -303,7 +295,14 @@ var OcamlHighlightRules = function() {
303
295
  "MoreLabels|Mutex|Nativeint|Num|Obj|Oo|Parsing|Pervasives|Printexc|" +
304
296
  "Printf|Queue|Random|Scanf|Scanning|Set|Sort|Stack|State|StdLabels|Str|" +
305
297
  "Stream|String|StringLabels|Sys|Thread|ThreadUnix|Tk|Unix|UnixLabels|Weak"
306
- ).split("|"));
298
+ );
299
+
300
+ var keywordMapper = this.createKeywordMapper({
301
+ "variable.language": "this",
302
+ "keyword": keywords,
303
+ "constant.language": builtinConstants,
304
+ "support.function": builtinFunctions
305
+ }, "identifier");
307
306
 
308
307
  var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
309
308
  var octInteger = "(?:0[oO]?[0-7]+)";
@@ -326,7 +325,6 @@ var OcamlHighlightRules = function() {
326
325
  },
327
326
  {
328
327
  token : "comment",
329
- merge : true,
330
328
  regex : '\\(\\*.*',
331
329
  next : "comment"
332
330
  },
@@ -340,7 +338,6 @@ var OcamlHighlightRules = function() {
340
338
  },
341
339
  {
342
340
  token : "string", // " string
343
- merge : true,
344
341
  regex : '"',
345
342
  next : "qstring"
346
343
  },
@@ -357,16 +354,7 @@ var OcamlHighlightRules = function() {
357
354
  regex : integer + "\\b"
358
355
  },
359
356
  {
360
- token : function(value) {
361
- if (keywords.hasOwnProperty(value))
362
- return "keyword";
363
- else if (builtinConstants.hasOwnProperty(value))
364
- return "constant.language";
365
- else if (builtinFunctions.hasOwnProperty(value))
366
- return "support.function";
367
- else
368
- return "identifier";
369
- },
357
+ token : keywordMapper,
370
358
  regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
371
359
  },
372
360
  {
@@ -394,7 +382,6 @@ var OcamlHighlightRules = function() {
394
382
  },
395
383
  {
396
384
  token : "comment", // comment spanning whole line
397
- merge : true,
398
385
  regex : ".+"
399
386
  }
400
387
  ],
@@ -406,7 +393,6 @@ var OcamlHighlightRules = function() {
406
393
  next : "start"
407
394
  }, {
408
395
  token : "string",
409
- merge : true,
410
396
  regex : '.+'
411
397
  }
412
398
  ]
@@ -450,12 +436,7 @@ var MatchingBraceOutdent = function() {};
450
436
  };
451
437
 
452
438
  this.$getIndent = function(line) {
453
- var match = line.match(/^(\s+)/);
454
- if (match) {
455
- return match[1];
456
- }
457
-
458
- return "";
439
+ return line.match(/^\s*/)[0];
459
440
  };
460
441
 
461
442
  }).call(MatchingBraceOutdent.prototype);
@@ -0,0 +1,233 @@
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Distributed under the BSD license:
3
+ *
4
+ * Copyright (c) 2012, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *
29
+ *
30
+ * Contributor(s):
31
+ *
32
+ *
33
+ *
34
+ * ***** END LICENSE BLOCK ***** */
35
+
36
+ define('ace/mode/pascal', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/pascal_highlight_rules', 'ace/mode/folding/coffee'], function(require, exports, module) {
37
+
38
+
39
+ var oop = require("../lib/oop");
40
+ var TextMode = require("./text").Mode;
41
+ var Tokenizer = require("../tokenizer").Tokenizer;
42
+ var PascalHighlightRules = require("./pascal_highlight_rules").PascalHighlightRules;
43
+ var FoldMode = require("./folding/coffee").FoldMode;
44
+
45
+ var Mode = function() {
46
+ this.HighlightRules = PascalHighlightRules;
47
+ this.foldingRules = new FoldMode();
48
+ };
49
+ oop.inherits(Mode, TextMode);
50
+
51
+ (function() {
52
+
53
+ this.lineCommentStart = ["--", "//"];
54
+ this.blockComment = [
55
+ {start: "(*", end: "*)"},
56
+ {start: "{", end: "}"}
57
+ ];
58
+
59
+ this.$id = "ace/mode/pascal";
60
+ }).call(Mode.prototype);
61
+
62
+ exports.Mode = Mode;
63
+ });
64
+
65
+ define('ace/mode/pascal_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
66
+
67
+
68
+ var oop = require("../lib/oop");
69
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
70
+
71
+ var PascalHighlightRules = function() {
72
+
73
+ this.$rules = { start:
74
+ [ { caseInsensitive: true,
75
+ token: 'keyword.control.pascal',
76
+ regex: '\\b(?:(absolute|abstract|all|and|and_then|array|as|asm|attribute|begin|bindable|case|class|const|constructor|destructor|div|do|do|else|end|except|export|exports|external|far|file|finalization|finally|for|forward|goto|if|implementation|import|in|inherited|initialization|interface|interrupt|is|label|library|mod|module|name|near|nil|not|object|of|only|operator|or|or_else|otherwise|packed|pow|private|program|property|protected|public|published|qualified|record|repeat|resident|restricted|segment|set|shl|shr|then|to|try|type|unit|until|uses|value|var|view|virtual|while|with|xor))\\b' },
77
+ { caseInsensitive: true,
78
+ token:
79
+ [ 'variable.pascal', "text",
80
+ 'storage.type.prototype.pascal',
81
+ 'entity.name.function.prototype.pascal' ],
82
+ regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
83
+ { caseInsensitive: true,
84
+ token:
85
+ [ 'variable.pascal', "text",
86
+ 'storage.type.function.pascal',
87
+ 'entity.name.function.pascal' ],
88
+ regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?' },
89
+ { token: 'constant.numeric.pascal',
90
+ regex: '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b' },
91
+ { token: 'punctuation.definition.comment.pascal',
92
+ regex: '--.*$',
93
+ push_:
94
+ [ { token: 'comment.line.double-dash.pascal.one',
95
+ regex: '$',
96
+ next: 'pop' },
97
+ { defaultToken: 'comment.line.double-dash.pascal.one' } ] },
98
+ { token: 'punctuation.definition.comment.pascal',
99
+ regex: '//.*$',
100
+ push_:
101
+ [ { token: 'comment.line.double-slash.pascal.two',
102
+ regex: '$',
103
+ next: 'pop' },
104
+ { defaultToken: 'comment.line.double-slash.pascal.two' } ] },
105
+ { token: 'punctuation.definition.comment.pascal',
106
+ regex: '\\(\\*',
107
+ push:
108
+ [ { token: 'punctuation.definition.comment.pascal',
109
+ regex: '\\*\\)',
110
+ next: 'pop' },
111
+ { defaultToken: 'comment.block.pascal.one' } ] },
112
+ { token: 'punctuation.definition.comment.pascal',
113
+ regex: '\\{',
114
+ push:
115
+ [ { token: 'punctuation.definition.comment.pascal',
116
+ regex: '\\}',
117
+ next: 'pop' },
118
+ { defaultToken: 'comment.block.pascal.two' } ] },
119
+ { token: 'punctuation.definition.string.begin.pascal',
120
+ regex: '"',
121
+ push:
122
+ [ { token: 'constant.character.escape.pascal', regex: '\\\\.' },
123
+ { token: 'punctuation.definition.string.end.pascal',
124
+ regex: '"',
125
+ next: 'pop' },
126
+ { defaultToken: 'string.quoted.double.pascal' } ],
127
+ },
128
+ { token: 'punctuation.definition.string.begin.pascal',
129
+ regex: '\'',
130
+ push:
131
+ [ { token: 'constant.character.escape.apostrophe.pascal',
132
+ regex: '\'\'' },
133
+ { token: 'punctuation.definition.string.end.pascal',
134
+ regex: '\'',
135
+ next: 'pop' },
136
+ { defaultToken: 'string.quoted.single.pascal' } ] },
137
+ { token: 'keyword.operator',
138
+ regex: '[+\\-;,/*%]|:=|=' } ] }
139
+
140
+ this.normalizeRules();
141
+ };
142
+
143
+ oop.inherits(PascalHighlightRules, TextHighlightRules);
144
+
145
+ exports.PascalHighlightRules = PascalHighlightRules;
146
+ });
147
+
148
+ define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
149
+
150
+
151
+ var oop = require("../../lib/oop");
152
+ var BaseFoldMode = require("./fold_mode").FoldMode;
153
+ var Range = require("../../range").Range;
154
+
155
+ var FoldMode = exports.FoldMode = function() {};
156
+ oop.inherits(FoldMode, BaseFoldMode);
157
+
158
+ (function() {
159
+
160
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
161
+ var range = this.indentationBlock(session, row);
162
+ if (range)
163
+ return range;
164
+
165
+ var re = /\S/;
166
+ var line = session.getLine(row);
167
+ var startLevel = line.search(re);
168
+ if (startLevel == -1 || line[startLevel] != "#")
169
+ return;
170
+
171
+ var startColumn = line.length;
172
+ var maxRow = session.getLength();
173
+ var startRow = row;
174
+ var endRow = row;
175
+
176
+ while (++row < maxRow) {
177
+ line = session.getLine(row);
178
+ var level = line.search(re);
179
+
180
+ if (level == -1)
181
+ continue;
182
+
183
+ if (line[level] != "#")
184
+ break;
185
+
186
+ endRow = row;
187
+ }
188
+
189
+ if (endRow > startRow) {
190
+ var endColumn = session.getLine(endRow).length;
191
+ return new Range(startRow, startColumn, endRow, endColumn);
192
+ }
193
+ };
194
+ this.getFoldWidget = function(session, foldStyle, row) {
195
+ var line = session.getLine(row);
196
+ var indent = line.search(/\S/);
197
+ var next = session.getLine(row + 1);
198
+ var prev = session.getLine(row - 1);
199
+ var prevIndent = prev.search(/\S/);
200
+ var nextIndent = next.search(/\S/);
201
+
202
+ if (indent == -1) {
203
+ session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
204
+ return "";
205
+ }
206
+ if (prevIndent == -1) {
207
+ if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
208
+ session.foldWidgets[row - 1] = "";
209
+ session.foldWidgets[row + 1] = "";
210
+ return "start";
211
+ }
212
+ } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
213
+ if (session.getLine(row - 2).search(/\S/) == -1) {
214
+ session.foldWidgets[row - 1] = "start";
215
+ session.foldWidgets[row + 1] = "";
216
+ return "";
217
+ }
218
+ }
219
+
220
+ if (prevIndent!= -1 && prevIndent < indent)
221
+ session.foldWidgets[row - 1] = "start";
222
+ else
223
+ session.foldWidgets[row - 1] = "";
224
+
225
+ if (indent < nextIndent)
226
+ return "start";
227
+ else
228
+ return "";
229
+ };
230
+
231
+ }).call(FoldMode.prototype);
232
+
233
+ });
@@ -1,37 +1,30 @@
1
1
  /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2
+ * Distributed under the BSD license:
3
3
  *
4
- * The contents of this file are subject to the Mozilla Public License Version
5
- * 1.1 (the "License"); you may not use this file except in compliance with
6
- * the License. You may obtain a copy of the License at
7
- * http://www.mozilla.org/MPL/
8
- *
9
- * Software distributed under the License is distributed on an "AS IS" basis,
10
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
- * for the specific language governing rights and limitations under the
12
- * License.
13
- *
14
- * The Original Code is Ajax.org Code Editor (ACE).
15
- *
16
- * The Initial Developer of the Original Code is
17
- * Ajax.org B.V.
18
- * Portions created by the Initial Developer are Copyright (C) 2010
19
- * the Initial Developer. All Rights Reserved.
20
- *
21
- * Contributor(s):
22
- * Panagiotis Astithas <pastith AT gmail DOT com>
23
- *
24
- * Alternatively, the contents of this file may be used under the terms of
25
- * either the GNU General Public License Version 2 or later (the "GPL"), or
26
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
- * in which case the provisions of the GPL or the LGPL are applicable instead
28
- * of those above. If you wish to allow use of your version of this file only
29
- * under the terms of either the GPL or the LGPL, and not to allow others to
30
- * use your version of this file under the terms of the MPL, indicate your
31
- * decision by deleting the provisions above and replace them with the notice
32
- * and other provisions required by the GPL or the LGPL. If you do not delete
33
- * the provisions above, a recipient may use your version of this file under
34
- * the terms of any one of the MPL, the GPL or the LGPL.
4
+ * Copyright (c) 2010, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
28
  *
36
29
  * ***** END LICENSE BLOCK ***** */
37
30
 
@@ -47,46 +40,26 @@ var Range = require("../range").Range;
47
40
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
48
41
 
49
42
  var Mode = function() {
50
- this.$tokenizer = new Tokenizer(new PerlHighlightRules().getRules());
43
+ this.HighlightRules = PerlHighlightRules;
44
+
51
45
  this.$outdent = new MatchingBraceOutdent();
52
- this.foldingRules = new CStyleFoldMode();
46
+ this.foldingRules = new CStyleFoldMode({start: "^=(begin|item)\\b", end: "^=(cut)\\b"});
53
47
  };
54
48
  oop.inherits(Mode, TextMode);
55
49
 
56
50
  (function() {
57
51
 
58
- this.toggleCommentLines = function(state, doc, startRow, endRow) {
59
- var outdent = true;
60
- var re = /^(\s*)#/;
61
-
62
- for (var i=startRow; i<= endRow; i++) {
63
- if (!re.test(doc.getLine(i))) {
64
- outdent = false;
65
- break;
66
- }
67
- }
52
+ this.lineCommentStart = "#";
53
+ this.blockComment = [
54
+ {start: "=begin", end: "=cut"},
55
+ {start: "=item", end: "=cut"}
56
+ ];
68
57
 
69
- if (outdent) {
70
- var deleteRange = new Range(0, 0, 0, 0);
71
- for (var i=startRow; i<= endRow; i++)
72
- {
73
- var line = doc.getLine(i);
74
- var m = line.match(re);
75
- deleteRange.start.row = i;
76
- deleteRange.end.row = i;
77
- deleteRange.end.column = m[0].length;
78
- doc.replace(deleteRange, m[1]);
79
- }
80
- }
81
- else {
82
- doc.indentRows(startRow, endRow, "#");
83
- }
84
- };
85
58
 
86
59
  this.getNextLineIndent = function(state, line, tab) {
87
60
  var indent = this.$getIndent(line);
88
61
 
89
- var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
62
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
90
63
  var tokens = tokenizedLine.tokens;
91
64
 
92
65
  if (tokens.length && tokens[tokens.length-1].type == "comment") {
@@ -111,31 +84,29 @@ oop.inherits(Mode, TextMode);
111
84
  this.$outdent.autoOutdent(doc, row);
112
85
  };
113
86
 
87
+ this.$id = "ace/mode/perl";
114
88
  }).call(Mode.prototype);
115
89
 
116
90
  exports.Mode = Mode;
117
91
  });
118
92
 
119
- define('ace/mode/perl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
93
+ define('ace/mode/perl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
120
94
 
121
95
 
122
96
  var oop = require("../lib/oop");
123
- var lang = require("../lib/lang");
124
97
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
125
98
 
126
99
  var PerlHighlightRules = function() {
127
100
 
128
- var keywords = lang.arrayToMap(
129
- ("base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" +
130
- "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars").split("|")
101
+ var keywords = (
102
+ "base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" +
103
+ "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars"
131
104
  );
132
105
 
133
- var buildinConstants = lang.arrayToMap(
134
- ("ARGV|ENV|INC|SIG").split("|")
135
- );
106
+ var buildinConstants = ("ARGV|ENV|INC|SIG");
136
107
 
137
- var builtinFunctions = lang.arrayToMap(
138
- ("getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" +
108
+ var builtinFunctions = (
109
+ "getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" +
139
110
  "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" +
140
111
  "getpeername|setpriority|getprotoent|setprotoent|getpriority|" +
141
112
  "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" +
@@ -156,17 +127,21 @@ var PerlHighlightRules = function() {
156
127
  "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" +
157
128
  "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" +
158
129
  "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" +
159
- "map|die|uc|lc|do").split("|")
130
+ "map|die|uc|lc|do"
160
131
  );
161
132
 
162
- // regexp must not have capturing parentheses. Use (?:) instead.
163
- // regexps are ordered -> the first match is used
133
+ var keywordMapper = this.createKeywordMapper({
134
+ "keyword": keywords,
135
+ "constant.language": buildinConstants,
136
+ "support.function": builtinFunctions
137
+ }, "identifier");
164
138
 
165
139
  this.$rules = {
166
140
  "start" : [
167
141
  {
168
- token : "comment",
169
- regex : "#.*$"
142
+ token : "comment.doc",
143
+ regex : "^=(?:begin|item)\\b",
144
+ next : "block_comment"
170
145
  }, {
171
146
  token : "string.regexp",
172
147
  regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
@@ -175,7 +150,6 @@ var PerlHighlightRules = function() {
175
150
  regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
176
151
  }, {
177
152
  token : "string", // multi line string start
178
- merge : true,
179
153
  regex : '["].*\\\\$',
180
154
  next : "qqstring"
181
155
  }, {
@@ -183,7 +157,6 @@ var PerlHighlightRules = function() {
183
157
  regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
184
158
  }, {
185
159
  token : "string", // multi line string start
186
- merge : true,
187
160
  regex : "['].*\\\\$",
188
161
  next : "qstring"
189
162
  }, {
@@ -193,20 +166,14 @@ var PerlHighlightRules = function() {
193
166
  token : "constant.numeric", // float
194
167
  regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
195
168
  }, {
196
- token : function(value) {
197
- if (keywords.hasOwnProperty(value))
198
- return "keyword";
199
- else if (buildinConstants.hasOwnProperty(value))
200
- return "constant.language";
201
- else if (builtinFunctions.hasOwnProperty(value))
202
- return "support.function";
203
- else
204
- return "identifier";
205
- },
169
+ token : keywordMapper,
206
170
  regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
207
171
  }, {
208
172
  token : "keyword.operator",
209
- regex : "\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)"
173
+ regex : "%#|\\$#|\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)"
174
+ }, {
175
+ token : "comment",
176
+ regex : "#.*$"
210
177
  }, {
211
178
  token : "lparen",
212
179
  regex : "[[({]"
@@ -225,7 +192,6 @@ var PerlHighlightRules = function() {
225
192
  next : "start"
226
193
  }, {
227
194
  token : "string",
228
- merge : true,
229
195
  regex : '.+'
230
196
  }
231
197
  ],
@@ -236,9 +202,18 @@ var PerlHighlightRules = function() {
236
202
  next : "start"
237
203
  }, {
238
204
  token : "string",
239
- merge : true,
240
205
  regex : '.+'
241
206
  }
207
+ ],
208
+ "block_comment": [
209
+ {
210
+ token: "comment.doc",
211
+ regex: "^=cut\\b",
212
+ next: "start"
213
+ },
214
+ {
215
+ defaultToken: "comment.doc"
216
+ }
242
217
  ]
243
218
  };
244
219
  };
@@ -280,12 +255,7 @@ var MatchingBraceOutdent = function() {};
280
255
  };
281
256
 
282
257
  this.$getIndent = function(line) {
283
- var match = line.match(/^(\s+)/);
284
- if (match) {
285
- return match[1];
286
- }
287
-
288
- return "";
258
+ return line.match(/^\s*/)[0];
289
259
  };
290
260
 
291
261
  }).call(MatchingBraceOutdent.prototype);
@@ -300,15 +270,24 @@ var oop = require("../../lib/oop");
300
270
  var Range = require("../../range").Range;
301
271
  var BaseFoldMode = require("./fold_mode").FoldMode;
302
272
 
303
- var FoldMode = exports.FoldMode = function() {};
273
+ var FoldMode = exports.FoldMode = function(commentRegex) {
274
+ if (commentRegex) {
275
+ this.foldingStartMarker = new RegExp(
276
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
277
+ );
278
+ this.foldingStopMarker = new RegExp(
279
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
280
+ );
281
+ }
282
+ };
304
283
  oop.inherits(FoldMode, BaseFoldMode);
305
284
 
306
285
  (function() {
307
286
 
308
287
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
309
288
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
310
-
311
- this.getFoldWidgetRange = function(session, foldStyle, row) {
289
+
290
+ this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
312
291
  var line = session.getLine(row);
313
292
  var match = line.match(this.foldingStartMarker);
314
293
  if (match) {
@@ -316,115 +295,63 @@ oop.inherits(FoldMode, BaseFoldMode);
316
295
 
317
296
  if (match[1])
318
297
  return this.openingBracketBlock(session, match[1], row, i);
319
-
320
- var range = session.getCommentFoldRange(row, i + match[0].length);
321
- range.end.column -= 2;
298
+
299
+ var range = session.getCommentFoldRange(row, i + match[0].length, 1);
300
+
301
+ if (range && !range.isMultiLine()) {
302
+ if (forceMultiline) {
303
+ range = this.getSectionRange(session, row);
304
+ } else if (foldStyle != "all")
305
+ range = null;
306
+ }
307
+
322
308
  return range;
323
309
  }
324
310
 
325
- if (foldStyle !== "markbeginend")
311
+ if (foldStyle === "markbegin")
326
312
  return;
327
-
313
+
328
314
  var match = line.match(this.foldingStopMarker);
329
315
  if (match) {
330
316
  var i = match.index + match[0].length;
331
317
 
332
- if (match[2]) {
333
- var range = session.getCommentFoldRange(row, i);
334
- range.end.column -= 2;
335
- return range;
336
- }
337
-
338
- var end = {row: row, column: i};
339
- var start = session.$findOpeningBracket(match[1], end);
340
-
341
- if (!start)
342
- return;
343
-
344
- start.column++;
345
- end.column--;
318
+ if (match[1])
319
+ return this.closingBracketBlock(session, match[1], row, i);
346
320
 
347
- return Range.fromPoints(start, end);
321
+ return session.getCommentFoldRange(row, i, -1);
348
322
  }
349
323
  };
350
324
 
351
- }).call(FoldMode.prototype);
352
-
353
- });
354
-
355
- define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
356
-
357
-
358
- var Range = require("../../range").Range;
359
-
360
- var FoldMode = exports.FoldMode = function() {};
361
-
362
- (function() {
363
-
364
- this.foldingStartMarker = null;
365
- this.foldingStopMarker = null;
366
-
367
- // must return "" if there's no fold, to enable caching
368
- this.getFoldWidget = function(session, foldStyle, row) {
369
- var line = session.getLine(row);
370
- if (this.foldingStartMarker.test(line))
371
- return "start";
372
- if (foldStyle == "markbeginend"
373
- && this.foldingStopMarker
374
- && this.foldingStopMarker.test(line))
375
- return "end";
376
- return "";
377
- };
378
-
379
- this.getFoldWidgetRange = function(session, foldStyle, row) {
380
- return null;
381
- };
382
-
383
- this.indentationBlock = function(session, row, column) {
384
- var re = /\S/;
325
+ this.getSectionRange = function(session, row) {
385
326
  var line = session.getLine(row);
386
- var startLevel = line.search(re);
387
- if (startLevel == -1)
388
- return;
389
-
390
- var startColumn = column || line.length;
391
- var maxRow = session.getLength();
327
+ var startIndent = line.search(/\S/);
392
328
  var startRow = row;
329
+ var startColumn = line.length;
330
+ row = row + 1;
393
331
  var endRow = row;
394
-
332
+ var maxRow = session.getLength();
395
333
  while (++row < maxRow) {
396
- var level = session.getLine(row).search(re);
397
-
398
- if (level == -1)
334
+ line = session.getLine(row);
335
+ var indent = line.search(/\S/);
336
+ if (indent === -1)
399
337
  continue;
400
-
401
- if (level <= startLevel)
338
+ if (startIndent > indent)
402
339
  break;
403
-
340
+ var subRange = this.getFoldWidgetRange(session, "all", row);
341
+
342
+ if (subRange) {
343
+ if (subRange.start.row <= startRow) {
344
+ break;
345
+ } else if (subRange.isMultiLine()) {
346
+ row = subRange.end.row;
347
+ } else if (startIndent == indent) {
348
+ break;
349
+ }
350
+ }
404
351
  endRow = row;
405
352
  }
406
-
407
- if (endRow > startRow) {
408
- var endColumn = session.getLine(endRow).length;
409
- return new Range(startRow, startColumn, endRow, endColumn);
410
- }
411
- };
412
-
413
- this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
414
- var start = {row: row, column: column + 1};
415
- var end = session.$findClosingBracket(bracket, start, typeRe);
416
- if (!end)
417
- return;
418
-
419
- var fw = session.foldWidgets[end.row];
420
- if (fw == null)
421
- fw = this.getFoldWidget(session, end.row);
422
-
423
- if (fw == "start" && end.row > start.row) {
424
- end.row --;
425
- end.column = session.getLine(end.row).length;
426
- }
427
- return Range.fromPoints(start, end);
353
+
354
+ return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
428
355
  };
429
356
 
430
357
  }).call(FoldMode.prototype);