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,38 +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
- * Fabian Jakobs <fabian AT ajax DOT org>
23
- * Gastón Kleiman <gaston.kleiman AT gmail DOT com>
24
- *
25
- * Alternatively, the contents of this file may be used under the terms of
26
- * either the GNU General Public License Version 2 or later (the "GPL"), or
27
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
- * in which case the provisions of the GPL or the LGPL are applicable instead
29
- * of those above. If you wish to allow use of your version of this file only
30
- * under the terms of either the GPL or the LGPL, and not to allow others to
31
- * use your version of this file under the terms of the MPL, indicate your
32
- * decision by deleting the provisions above and replace them with the notice
33
- * and other provisions required by the GPL or the LGPL. If you do not delete
34
- * the provisions above, a recipient may use your version of this file under
35
- * 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.
36
28
  *
37
29
  * ***** END LICENSE BLOCK ***** */
38
30
 
@@ -49,7 +41,7 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
49
41
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
50
42
 
51
43
  var Mode = function() {
52
- this.$tokenizer = new Tokenizer(new scadHighlightRules().getRules());
44
+ this.HighlightRules = scadHighlightRules;
53
45
  this.$outdent = new MatchingBraceOutdent();
54
46
  this.$behaviour = new CstyleBehaviour();
55
47
  this.foldingRules = new CStyleFoldMode();
@@ -58,38 +50,13 @@ oop.inherits(Mode, TextMode);
58
50
 
59
51
  (function() {
60
52
 
61
- this.toggleCommentLines = function(state, doc, startRow, endRow) {
62
- var outdent = true;
63
- var re = /^(\s*)\/\//;
64
-
65
- for (var i=startRow; i<= endRow; i++) {
66
- if (!re.test(doc.getLine(i))) {
67
- outdent = false;
68
- break;
69
- }
70
- }
71
-
72
- if (outdent) {
73
- var deleteRange = new Range(0, 0, 0, 0);
74
- for (var i=startRow; i<= endRow; i++)
75
- {
76
- var line = doc.getLine(i);
77
- var m = line.match(re);
78
- deleteRange.start.row = i;
79
- deleteRange.end.row = i;
80
- deleteRange.end.column = m[0].length;
81
- doc.replace(deleteRange, m[1]);
82
- }
83
- }
84
- else {
85
- doc.indentRows(startRow, endRow, "//");
86
- }
87
- };
53
+ this.lineCommentStart = "//";
54
+ this.blockComment = {start: "/*", end: "*/"};
88
55
 
89
56
  this.getNextLineIndent = function(state, line, tab) {
90
57
  var indent = this.$getIndent(line);
91
58
 
92
- var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
59
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
93
60
  var tokens = tokenizedLine.tokens;
94
61
  var endState = tokenizedLine.state;
95
62
 
@@ -126,6 +93,7 @@ oop.inherits(Mode, TextMode);
126
93
  this.$outdent.autoOutdent(doc, row);
127
94
  };
128
95
 
96
+ this.$id = "ace/mode/scad";
129
97
  }).call(Mode.prototype);
130
98
 
131
99
  exports.Mode = Mode;
@@ -140,17 +108,11 @@ var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocComme
140
108
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
141
109
 
142
110
  var scadHighlightRules = function() {
143
-
144
- var keywords = lang.arrayToMap(
145
- ("module|if|else|for").split("|")
146
- );
147
-
148
- var buildinConstants = lang.arrayToMap(
149
- ("NULL").split("|")
150
- );
151
-
152
- // regexp must not have capturing parentheses. Use (?:) instead.
153
- // regexps are ordered -> the first match is used
111
+ var keywordMapper = this.createKeywordMapper({
112
+ "variable.language": "this",
113
+ "keyword": "module|if|else|for",
114
+ "constant.language": "NULL"
115
+ }, "identifier");
154
116
 
155
117
  this.$rules = {
156
118
  "start" : [
@@ -161,7 +123,6 @@ var scadHighlightRules = function() {
161
123
  DocCommentHighlightRules.getStartRule("start"),
162
124
  {
163
125
  token : "comment", // multi line comment
164
- merge : true,
165
126
  regex : "\\/\\*",
166
127
  next : "comment"
167
128
  }, {
@@ -190,17 +151,8 @@ var scadHighlightRules = function() {
190
151
  }, {
191
152
  token : "keyword", // pre-compiler directivs
192
153
  regex : "(?:use|include)"
193
- }, {
194
- token : function(value) {
195
- if (value == "this")
196
- return "variable.language";
197
- else if (keywords.hasOwnProperty(value))
198
- return "keyword";
199
- else if (buildinConstants.hasOwnProperty(value))
200
- return "constant.language";
201
- else
202
- return "identifier";
203
- },
154
+ }, {
155
+ token : keywordMapper,
204
156
  regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
205
157
  }, {
206
158
  token : "keyword.operator",
@@ -223,7 +175,6 @@ var scadHighlightRules = function() {
223
175
  next : "start"
224
176
  }, {
225
177
  token : "comment", // comment spanning whole line
226
- merge : true,
227
178
  regex : ".+"
228
179
  }
229
180
  ],
@@ -234,7 +185,6 @@ var scadHighlightRules = function() {
234
185
  next : "start"
235
186
  }, {
236
187
  token : "string",
237
- merge : true,
238
188
  regex : '.+'
239
189
  }
240
190
  ],
@@ -245,7 +195,6 @@ var scadHighlightRules = function() {
245
195
  next : "start"
246
196
  }, {
247
197
  token : "string",
248
- merge : true,
249
198
  regex : '.+'
250
199
  }
251
200
  ]
@@ -273,21 +222,10 @@ var DocCommentHighlightRules = function() {
273
222
  token : "comment.doc.tag",
274
223
  regex : "@[\\w\\d_]+" // TODO: fix email addresses
275
224
  }, {
276
- token : "comment.doc",
277
- merge : true,
278
- regex : "\\s+"
279
- }, {
280
- token : "comment.doc",
281
- merge : true,
282
- regex : "TODO"
283
- }, {
284
- token : "comment.doc",
285
- merge : true,
286
- regex : "[^@\\*]+"
225
+ token : "comment.doc.tag",
226
+ regex : "\\bTODO\\b"
287
227
  }, {
288
- token : "comment.doc",
289
- merge : true,
290
- regex : "."
228
+ defaultToken : "comment.doc"
291
229
  }]
292
230
  };
293
231
  };
@@ -297,7 +235,6 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
297
235
  DocCommentHighlightRules.getStartRule = function(start) {
298
236
  return {
299
237
  token : "comment.doc", // doc comment
300
- merge : true,
301
238
  regex : "\\/\\*(?=\\*)",
302
239
  next : start
303
240
  };
@@ -306,7 +243,6 @@ DocCommentHighlightRules.getStartRule = function(start) {
306
243
  DocCommentHighlightRules.getEndRule = function (start) {
307
244
  return {
308
245
  token : "comment.doc", // closing comment
309
- merge : true,
310
246
  regex : "\\*\\/",
311
247
  next : start
312
248
  };
@@ -349,12 +285,7 @@ var MatchingBraceOutdent = function() {};
349
285
  };
350
286
 
351
287
  this.$getIndent = function(line) {
352
- var match = line.match(/^(\s+)/);
353
- if (match) {
354
- return match[1];
355
- }
356
-
357
- return "";
288
+ return line.match(/^\s*/)[0];
358
289
  };
359
290
 
360
291
  }).call(MatchingBraceOutdent.prototype);
@@ -362,59 +293,155 @@ var MatchingBraceOutdent = function() {};
362
293
  exports.MatchingBraceOutdent = MatchingBraceOutdent;
363
294
  });
364
295
 
365
- define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
296
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
366
297
 
367
298
 
368
299
  var oop = require("../../lib/oop");
369
300
  var Behaviour = require("../behaviour").Behaviour;
301
+ var TokenIterator = require("../../token_iterator").TokenIterator;
302
+ var lang = require("../../lib/lang");
303
+
304
+ var SAFE_INSERT_IN_TOKENS =
305
+ ["text", "paren.rparen", "punctuation.operator"];
306
+ var SAFE_INSERT_BEFORE_TOKENS =
307
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
308
+
309
+
310
+ var autoInsertedBrackets = 0;
311
+ var autoInsertedRow = -1;
312
+ var autoInsertedLineEnd = "";
313
+ var maybeInsertedBrackets = 0;
314
+ var maybeInsertedRow = -1;
315
+ var maybeInsertedLineStart = "";
316
+ var maybeInsertedLineEnd = "";
370
317
 
371
318
  var CstyleBehaviour = function () {
319
+
320
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
321
+ var cursor = editor.getCursorPosition();
322
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
323
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
324
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
325
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
326
+ return false;
327
+ }
328
+ iterator.stepForward();
329
+ return iterator.getCurrentTokenRow() !== cursor.row ||
330
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
331
+ };
332
+
333
+ CstyleBehaviour.$matchTokenType = function(token, types) {
334
+ return types.indexOf(token.type || token) > -1;
335
+ };
336
+
337
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
338
+ var cursor = editor.getCursorPosition();
339
+ var line = session.doc.getLine(cursor.row);
340
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
341
+ autoInsertedBrackets = 0;
342
+ autoInsertedRow = cursor.row;
343
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
344
+ autoInsertedBrackets++;
345
+ };
346
+
347
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
348
+ var cursor = editor.getCursorPosition();
349
+ var line = session.doc.getLine(cursor.row);
350
+ if (!this.isMaybeInsertedClosing(cursor, line))
351
+ maybeInsertedBrackets = 0;
352
+ maybeInsertedRow = cursor.row;
353
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
354
+ maybeInsertedLineEnd = line.substr(cursor.column);
355
+ maybeInsertedBrackets++;
356
+ };
357
+
358
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
359
+ return autoInsertedBrackets > 0 &&
360
+ cursor.row === autoInsertedRow &&
361
+ bracket === autoInsertedLineEnd[0] &&
362
+ line.substr(cursor.column) === autoInsertedLineEnd;
363
+ };
364
+
365
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
366
+ return maybeInsertedBrackets > 0 &&
367
+ cursor.row === maybeInsertedRow &&
368
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
369
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
370
+ };
371
+
372
+ CstyleBehaviour.popAutoInsertedClosing = function() {
373
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
374
+ autoInsertedBrackets--;
375
+ };
376
+
377
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
378
+ maybeInsertedBrackets = 0;
379
+ maybeInsertedRow = -1;
380
+ };
372
381
 
373
382
  this.add("braces", "insertion", function (state, action, editor, session, text) {
383
+ var cursor = editor.getCursorPosition();
384
+ var line = session.doc.getLine(cursor.row);
374
385
  if (text == '{') {
375
386
  var selection = editor.getSelectionRange();
376
387
  var selected = session.doc.getTextRange(selection);
377
- if (selected !== "") {
388
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
378
389
  return {
379
390
  text: '{' + selected + '}',
380
391
  selection: false
381
392
  };
382
- } else {
383
- return {
384
- text: '{}',
385
- selection: [1, 1]
386
- };
393
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
394
+ if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
395
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
396
+ return {
397
+ text: '{}',
398
+ selection: [1, 1]
399
+ };
400
+ } else {
401
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
402
+ return {
403
+ text: '{',
404
+ selection: [1, 1]
405
+ };
406
+ }
387
407
  }
388
408
  } else if (text == '}') {
389
- var cursor = editor.getCursorPosition();
390
- var line = session.doc.getLine(cursor.row);
391
409
  var rightChar = line.substring(cursor.column, cursor.column + 1);
392
410
  if (rightChar == '}') {
393
411
  var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
394
- if (matching !== null) {
412
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
413
+ CstyleBehaviour.popAutoInsertedClosing();
395
414
  return {
396
415
  text: '',
397
416
  selection: [1, 1]
398
417
  };
399
418
  }
400
419
  }
401
- } else if (text == "\n") {
402
- var cursor = editor.getCursorPosition();
403
- var line = session.doc.getLine(cursor.row);
420
+ } else if (text == "\n" || text == "\r\n") {
421
+ var closing = "";
422
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
423
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
424
+ CstyleBehaviour.clearMaybeInsertedClosing();
425
+ }
404
426
  var rightChar = line.substring(cursor.column, cursor.column + 1);
405
- if (rightChar == '}') {
406
- var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
427
+ if (rightChar === '}') {
428
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
407
429
  if (!openBracePos)
408
430
  return null;
409
-
410
- var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
411
- var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
412
-
413
- return {
414
- text: '\n' + indent + '\n' + next_indent,
415
- selection: [1, indent.length, 1, indent.length]
416
- };
431
+ var next_indent = this.$getIndent(session.getLine(openBracePos.row));
432
+ } else if (closing) {
433
+ var next_indent = this.$getIndent(line);
434
+ } else {
435
+ return;
417
436
  }
437
+ var indent = next_indent + session.getTabString();
438
+
439
+ return {
440
+ text: '\n' + indent + '\n' + next_indent + closing,
441
+ selection: [1, indent.length, 1, indent.length]
442
+ };
443
+ } else {
444
+ CstyleBehaviour.clearMaybeInsertedClosing();
418
445
  }
419
446
  });
420
447
 
@@ -426,6 +453,8 @@ var CstyleBehaviour = function () {
426
453
  if (rightChar == '}') {
427
454
  range.end.column++;
428
455
  return range;
456
+ } else {
457
+ maybeInsertedBrackets--;
429
458
  }
430
459
  }
431
460
  });
@@ -434,12 +463,13 @@ var CstyleBehaviour = function () {
434
463
  if (text == '(') {
435
464
  var selection = editor.getSelectionRange();
436
465
  var selected = session.doc.getTextRange(selection);
437
- if (selected !== "") {
466
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
438
467
  return {
439
468
  text: '(' + selected + ')',
440
469
  selection: false
441
470
  };
442
- } else {
471
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
472
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
443
473
  return {
444
474
  text: '()',
445
475
  selection: [1, 1]
@@ -451,7 +481,8 @@ var CstyleBehaviour = function () {
451
481
  var rightChar = line.substring(cursor.column, cursor.column + 1);
452
482
  if (rightChar == ')') {
453
483
  var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
454
- if (matching !== null) {
484
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
485
+ CstyleBehaviour.popAutoInsertedClosing();
455
486
  return {
456
487
  text: '',
457
488
  selection: [1, 1]
@@ -477,12 +508,13 @@ var CstyleBehaviour = function () {
477
508
  if (text == '[') {
478
509
  var selection = editor.getSelectionRange();
479
510
  var selected = session.doc.getTextRange(selection);
480
- if (selected !== "") {
511
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
481
512
  return {
482
513
  text: '[' + selected + ']',
483
514
  selection: false
484
515
  };
485
- } else {
516
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
517
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
486
518
  return {
487
519
  text: '[]',
488
520
  selection: [1, 1]
@@ -494,7 +526,8 @@ var CstyleBehaviour = function () {
494
526
  var rightChar = line.substring(cursor.column, cursor.column + 1);
495
527
  if (rightChar == ']') {
496
528
  var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
497
- if (matching !== null) {
529
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
530
+ CstyleBehaviour.popAutoInsertedClosing();
498
531
  return {
499
532
  text: '',
500
533
  selection: [1, 1]
@@ -521,7 +554,7 @@ var CstyleBehaviour = function () {
521
554
  var quote = text;
522
555
  var selection = editor.getSelectionRange();
523
556
  var selected = session.doc.getTextRange(selection);
524
- if (selected !== "") {
557
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
525
558
  return {
526
559
  text: quote + selected + quote,
527
560
  selection: false
@@ -530,13 +563,9 @@ var CstyleBehaviour = function () {
530
563
  var cursor = editor.getCursorPosition();
531
564
  var line = session.doc.getLine(cursor.row);
532
565
  var leftChar = line.substring(cursor.column-1, cursor.column);
533
-
534
- // We're escaped.
535
566
  if (leftChar == '\\') {
536
567
  return null;
537
568
  }
538
-
539
- // Find what token we're inside.
540
569
  var tokens = session.getTokens(selection.start.row);
541
570
  var col = 0, token;
542
571
  var quotepos = -1; // Track whether we're inside an open quote.
@@ -553,15 +582,14 @@ var CstyleBehaviour = function () {
553
582
  }
554
583
  col += tokens[x].value.length;
555
584
  }
556
-
557
- // Try and be smart about when we auto insert.
558
585
  if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
586
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
587
+ return;
559
588
  return {
560
589
  text: quote + quote,
561
590
  selection: [1,1]
562
591
  };
563
592
  } else if (token && token.type === "string") {
564
- // Ignore input and move right one if we're typing over the closing quote.
565
593
  var rightChar = line.substring(cursor.column, cursor.column + 1);
566
594
  if (rightChar == quote) {
567
595
  return {
@@ -579,7 +607,7 @@ var CstyleBehaviour = function () {
579
607
  if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
580
608
  var line = session.doc.getLine(range.start.row);
581
609
  var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
582
- if (rightChar == '"') {
610
+ if (rightChar == selected) {
583
611
  range.end.column++;
584
612
  return range;
585
613
  }
@@ -600,15 +628,24 @@ var oop = require("../../lib/oop");
600
628
  var Range = require("../../range").Range;
601
629
  var BaseFoldMode = require("./fold_mode").FoldMode;
602
630
 
603
- var FoldMode = exports.FoldMode = function() {};
631
+ var FoldMode = exports.FoldMode = function(commentRegex) {
632
+ if (commentRegex) {
633
+ this.foldingStartMarker = new RegExp(
634
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
635
+ );
636
+ this.foldingStopMarker = new RegExp(
637
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
638
+ );
639
+ }
640
+ };
604
641
  oop.inherits(FoldMode, BaseFoldMode);
605
642
 
606
643
  (function() {
607
644
 
608
645
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
609
646
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
610
-
611
- this.getFoldWidgetRange = function(session, foldStyle, row) {
647
+
648
+ this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
612
649
  var line = session.getLine(row);
613
650
  var match = line.match(this.foldingStartMarker);
614
651
  if (match) {
@@ -616,115 +653,63 @@ oop.inherits(FoldMode, BaseFoldMode);
616
653
 
617
654
  if (match[1])
618
655
  return this.openingBracketBlock(session, match[1], row, i);
619
-
620
- var range = session.getCommentFoldRange(row, i + match[0].length);
621
- range.end.column -= 2;
656
+
657
+ var range = session.getCommentFoldRange(row, i + match[0].length, 1);
658
+
659
+ if (range && !range.isMultiLine()) {
660
+ if (forceMultiline) {
661
+ range = this.getSectionRange(session, row);
662
+ } else if (foldStyle != "all")
663
+ range = null;
664
+ }
665
+
622
666
  return range;
623
667
  }
624
668
 
625
- if (foldStyle !== "markbeginend")
669
+ if (foldStyle === "markbegin")
626
670
  return;
627
-
671
+
628
672
  var match = line.match(this.foldingStopMarker);
629
673
  if (match) {
630
674
  var i = match.index + match[0].length;
631
675
 
632
- if (match[2]) {
633
- var range = session.getCommentFoldRange(row, i);
634
- range.end.column -= 2;
635
- return range;
636
- }
637
-
638
- var end = {row: row, column: i};
639
- var start = session.$findOpeningBracket(match[1], end);
640
-
641
- if (!start)
642
- return;
643
-
644
- start.column++;
645
- end.column--;
676
+ if (match[1])
677
+ return this.closingBracketBlock(session, match[1], row, i);
646
678
 
647
- return Range.fromPoints(start, end);
679
+ return session.getCommentFoldRange(row, i, -1);
648
680
  }
649
681
  };
650
682
 
651
- }).call(FoldMode.prototype);
652
-
653
- });
654
-
655
- define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
656
-
657
-
658
- var Range = require("../../range").Range;
659
-
660
- var FoldMode = exports.FoldMode = function() {};
661
-
662
- (function() {
663
-
664
- this.foldingStartMarker = null;
665
- this.foldingStopMarker = null;
666
-
667
- // must return "" if there's no fold, to enable caching
668
- this.getFoldWidget = function(session, foldStyle, row) {
669
- var line = session.getLine(row);
670
- if (this.foldingStartMarker.test(line))
671
- return "start";
672
- if (foldStyle == "markbeginend"
673
- && this.foldingStopMarker
674
- && this.foldingStopMarker.test(line))
675
- return "end";
676
- return "";
677
- };
678
-
679
- this.getFoldWidgetRange = function(session, foldStyle, row) {
680
- return null;
681
- };
682
-
683
- this.indentationBlock = function(session, row, column) {
684
- var re = /\S/;
683
+ this.getSectionRange = function(session, row) {
685
684
  var line = session.getLine(row);
686
- var startLevel = line.search(re);
687
- if (startLevel == -1)
688
- return;
689
-
690
- var startColumn = column || line.length;
691
- var maxRow = session.getLength();
685
+ var startIndent = line.search(/\S/);
692
686
  var startRow = row;
687
+ var startColumn = line.length;
688
+ row = row + 1;
693
689
  var endRow = row;
694
-
690
+ var maxRow = session.getLength();
695
691
  while (++row < maxRow) {
696
- var level = session.getLine(row).search(re);
697
-
698
- if (level == -1)
692
+ line = session.getLine(row);
693
+ var indent = line.search(/\S/);
694
+ if (indent === -1)
699
695
  continue;
700
-
701
- if (level <= startLevel)
696
+ if (startIndent > indent)
702
697
  break;
703
-
698
+ var subRange = this.getFoldWidgetRange(session, "all", row);
699
+
700
+ if (subRange) {
701
+ if (subRange.start.row <= startRow) {
702
+ break;
703
+ } else if (subRange.isMultiLine()) {
704
+ row = subRange.end.row;
705
+ } else if (startIndent == indent) {
706
+ break;
707
+ }
708
+ }
704
709
  endRow = row;
705
710
  }
706
-
707
- if (endRow > startRow) {
708
- var endColumn = session.getLine(endRow).length;
709
- return new Range(startRow, startColumn, endRow, endColumn);
710
- }
711
- };
712
-
713
- this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
714
- var start = {row: row, column: column + 1};
715
- var end = session.$findClosingBracket(bracket, start, typeRe);
716
- if (!end)
717
- return;
718
-
719
- var fw = session.foldWidgets[end.row];
720
- if (fw == null)
721
- fw = this.getFoldWidget(session, end.row);
722
-
723
- if (fw == "start" && end.row > start.row) {
724
- end.row --;
725
- end.column = session.getLine(end.row).length;
726
- }
727
- return Range.fromPoints(start, end);
711
+
712
+ return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
728
713
  };
729
714
 
730
715
  }).call(FoldMode.prototype);