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,42 +1,34 @@
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
- * John Roepke <john AT justjohn DOT us>
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
 
39
- define('ace/mode/less', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/less_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/cstyle'], function(require, exports, module) {
31
+ define('ace/mode/less', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/less_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/css', 'ace/mode/folding/cstyle'], function(require, exports, module) {
40
32
 
41
33
 
42
34
  var oop = require("../lib/oop");
@@ -44,22 +36,25 @@ var TextMode = require("./text").Mode;
44
36
  var Tokenizer = require("../tokenizer").Tokenizer;
45
37
  var LessHighlightRules = require("./less_highlight_rules").LessHighlightRules;
46
38
  var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
39
+ var CssBehaviour = require("./behaviour/css").CssBehaviour;
47
40
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
48
41
 
49
42
  var Mode = function() {
50
- this.$tokenizer = new Tokenizer(new LessHighlightRules().getRules(), "i");
43
+ this.HighlightRules = LessHighlightRules;
51
44
  this.$outdent = new MatchingBraceOutdent();
45
+ this.$behaviour = new CssBehaviour();
52
46
  this.foldingRules = new CStyleFoldMode();
53
47
  };
54
48
  oop.inherits(Mode, TextMode);
55
49
 
56
50
  (function() {
51
+
52
+ this.lineCommentStart = "//";
53
+ this.blockComment = {start: "/*", end: "*/"};
57
54
 
58
55
  this.getNextLineIndent = function(state, line, tab) {
59
56
  var indent = this.$getIndent(line);
60
-
61
- // ignore braces in comments
62
- var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
57
+ var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
63
58
  if (tokens.length && tokens[tokens.length-1].type == "comment") {
64
59
  return indent;
65
60
  }
@@ -80,6 +75,7 @@ oop.inherits(Mode, TextMode);
80
75
  this.$outdent.autoOutdent(doc, row);
81
76
  };
82
77
 
78
+ this.$id = "ace/mode/less";
83
79
  }).call(Mode.prototype);
84
80
 
85
81
  exports.Mode = Mode;
@@ -142,20 +138,13 @@ var LessHighlightRules = function() {
142
138
  "text-shadow|text-transform|top|unicode-bidi|vertical-align|" +
143
139
  "visibility|voice-family|volume|white-space|widows|width|word-spacing|" +
144
140
  "z-index").split("|");
145
-
146
- //The return array
147
141
  var ret = [];
148
-
149
- //All prefixProperties will get the browserPrefix in
150
- //the begning by join the prefixProperties array with the value of browserPrefix
151
142
  for (var i=0, ln=browserPrefix.length; i<ln; i++) {
152
143
  Array.prototype.push.apply(
153
144
  ret,
154
145
  (( browserPrefix[i] + prefixProperties.join("|" + browserPrefix[i]) ).split("|"))
155
146
  );
156
147
  }
157
-
158
- //Add also prefixProperties and properties without any browser prefix
159
148
  Array.prototype.push.apply(ret, prefixProperties);
160
149
  Array.prototype.push.apply(ret, properties);
161
150
 
@@ -219,14 +208,8 @@ var LessHighlightRules = function() {
219
208
  "textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
220
209
  );
221
210
 
222
- // regexp must not have capturing parentheses. Use (?:) instead.
223
- // regexps are ordered -> the first match is used
224
-
225
211
  var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
226
212
 
227
- // regexp must not have capturing parentheses. Use (?:) instead.
228
- // regexps are ordered -> the first match is used
229
-
230
213
  this.$rules = {
231
214
  "start" : [
232
215
  {
@@ -235,7 +218,6 @@ var LessHighlightRules = function() {
235
218
  },
236
219
  {
237
220
  token : "comment", // multi line comment
238
- merge : true,
239
221
  regex : "\\/\\*",
240
222
  next : "comment"
241
223
  }, {
@@ -306,6 +288,8 @@ var LessHighlightRules = function() {
306
288
  }, {
307
289
  token : "text",
308
290
  regex : "\\s+"
291
+ }, {
292
+ caseInsensitive: true
309
293
  }
310
294
  ],
311
295
  "comment" : [
@@ -315,7 +299,6 @@ var LessHighlightRules = function() {
315
299
  next : "start"
316
300
  }, {
317
301
  token : "comment", // comment spanning whole line
318
- merge : true,
319
302
  regex : ".+"
320
303
  }
321
304
  ]
@@ -360,12 +343,7 @@ var MatchingBraceOutdent = function() {};
360
343
  };
361
344
 
362
345
  this.$getIndent = function(line) {
363
- var match = line.match(/^(\s+)/);
364
- if (match) {
365
- return match[1];
366
- }
367
-
368
- return "";
346
+ return line.match(/^\s*/)[0];
369
347
  };
370
348
 
371
349
  }).call(MatchingBraceOutdent.prototype);
@@ -373,6 +351,413 @@ var MatchingBraceOutdent = function() {};
373
351
  exports.MatchingBraceOutdent = MatchingBraceOutdent;
374
352
  });
375
353
 
354
+ define('ace/mode/behaviour/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
355
+
356
+
357
+ var oop = require("../../lib/oop");
358
+ var Behaviour = require("../behaviour").Behaviour;
359
+ var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
360
+ var TokenIterator = require("../../token_iterator").TokenIterator;
361
+
362
+ var CssBehaviour = function () {
363
+
364
+ this.inherit(CstyleBehaviour);
365
+
366
+ this.add("colon", "insertion", function (state, action, editor, session, text) {
367
+ if (text === ':') {
368
+ var cursor = editor.getCursorPosition();
369
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
370
+ var token = iterator.getCurrentToken();
371
+ if (token && token.value.match(/\s+/)) {
372
+ token = iterator.stepBackward();
373
+ }
374
+ if (token && token.type === 'support.type') {
375
+ var line = session.doc.getLine(cursor.row);
376
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
377
+ if (rightChar === ':') {
378
+ return {
379
+ text: '',
380
+ selection: [1, 1]
381
+ }
382
+ }
383
+ if (!line.substring(cursor.column).match(/^\s*;/)) {
384
+ return {
385
+ text: ':;',
386
+ selection: [1, 1]
387
+ }
388
+ }
389
+ }
390
+ }
391
+ });
392
+
393
+ this.add("colon", "deletion", function (state, action, editor, session, range) {
394
+ var selected = session.doc.getTextRange(range);
395
+ if (!range.isMultiLine() && selected === ':') {
396
+ var cursor = editor.getCursorPosition();
397
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
398
+ var token = iterator.getCurrentToken();
399
+ if (token && token.value.match(/\s+/)) {
400
+ token = iterator.stepBackward();
401
+ }
402
+ if (token && token.type === 'support.type') {
403
+ var line = session.doc.getLine(range.start.row);
404
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
405
+ if (rightChar === ';') {
406
+ range.end.column ++;
407
+ return range;
408
+ }
409
+ }
410
+ }
411
+ });
412
+
413
+ this.add("semicolon", "insertion", function (state, action, editor, session, text) {
414
+ if (text === ';') {
415
+ var cursor = editor.getCursorPosition();
416
+ var line = session.doc.getLine(cursor.row);
417
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
418
+ if (rightChar === ';') {
419
+ return {
420
+ text: '',
421
+ selection: [1, 1]
422
+ }
423
+ }
424
+ }
425
+ });
426
+
427
+ }
428
+ oop.inherits(CssBehaviour, CstyleBehaviour);
429
+
430
+ exports.CssBehaviour = CssBehaviour;
431
+ });
432
+
433
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
434
+
435
+
436
+ var oop = require("../../lib/oop");
437
+ var Behaviour = require("../behaviour").Behaviour;
438
+ var TokenIterator = require("../../token_iterator").TokenIterator;
439
+ var lang = require("../../lib/lang");
440
+
441
+ var SAFE_INSERT_IN_TOKENS =
442
+ ["text", "paren.rparen", "punctuation.operator"];
443
+ var SAFE_INSERT_BEFORE_TOKENS =
444
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
445
+
446
+
447
+ var autoInsertedBrackets = 0;
448
+ var autoInsertedRow = -1;
449
+ var autoInsertedLineEnd = "";
450
+ var maybeInsertedBrackets = 0;
451
+ var maybeInsertedRow = -1;
452
+ var maybeInsertedLineStart = "";
453
+ var maybeInsertedLineEnd = "";
454
+
455
+ var CstyleBehaviour = function () {
456
+
457
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
458
+ var cursor = editor.getCursorPosition();
459
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
460
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
461
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
462
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
463
+ return false;
464
+ }
465
+ iterator.stepForward();
466
+ return iterator.getCurrentTokenRow() !== cursor.row ||
467
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
468
+ };
469
+
470
+ CstyleBehaviour.$matchTokenType = function(token, types) {
471
+ return types.indexOf(token.type || token) > -1;
472
+ };
473
+
474
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
475
+ var cursor = editor.getCursorPosition();
476
+ var line = session.doc.getLine(cursor.row);
477
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
478
+ autoInsertedBrackets = 0;
479
+ autoInsertedRow = cursor.row;
480
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
481
+ autoInsertedBrackets++;
482
+ };
483
+
484
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
485
+ var cursor = editor.getCursorPosition();
486
+ var line = session.doc.getLine(cursor.row);
487
+ if (!this.isMaybeInsertedClosing(cursor, line))
488
+ maybeInsertedBrackets = 0;
489
+ maybeInsertedRow = cursor.row;
490
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
491
+ maybeInsertedLineEnd = line.substr(cursor.column);
492
+ maybeInsertedBrackets++;
493
+ };
494
+
495
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
496
+ return autoInsertedBrackets > 0 &&
497
+ cursor.row === autoInsertedRow &&
498
+ bracket === autoInsertedLineEnd[0] &&
499
+ line.substr(cursor.column) === autoInsertedLineEnd;
500
+ };
501
+
502
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
503
+ return maybeInsertedBrackets > 0 &&
504
+ cursor.row === maybeInsertedRow &&
505
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
506
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
507
+ };
508
+
509
+ CstyleBehaviour.popAutoInsertedClosing = function() {
510
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
511
+ autoInsertedBrackets--;
512
+ };
513
+
514
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
515
+ maybeInsertedBrackets = 0;
516
+ maybeInsertedRow = -1;
517
+ };
518
+
519
+ this.add("braces", "insertion", function (state, action, editor, session, text) {
520
+ var cursor = editor.getCursorPosition();
521
+ var line = session.doc.getLine(cursor.row);
522
+ if (text == '{') {
523
+ var selection = editor.getSelectionRange();
524
+ var selected = session.doc.getTextRange(selection);
525
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
526
+ return {
527
+ text: '{' + selected + '}',
528
+ selection: false
529
+ };
530
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
531
+ if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
532
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
533
+ return {
534
+ text: '{}',
535
+ selection: [1, 1]
536
+ };
537
+ } else {
538
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
539
+ return {
540
+ text: '{',
541
+ selection: [1, 1]
542
+ };
543
+ }
544
+ }
545
+ } else if (text == '}') {
546
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
547
+ if (rightChar == '}') {
548
+ var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
549
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
550
+ CstyleBehaviour.popAutoInsertedClosing();
551
+ return {
552
+ text: '',
553
+ selection: [1, 1]
554
+ };
555
+ }
556
+ }
557
+ } else if (text == "\n" || text == "\r\n") {
558
+ var closing = "";
559
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
560
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
561
+ CstyleBehaviour.clearMaybeInsertedClosing();
562
+ }
563
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
564
+ if (rightChar === '}') {
565
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
566
+ if (!openBracePos)
567
+ return null;
568
+ var next_indent = this.$getIndent(session.getLine(openBracePos.row));
569
+ } else if (closing) {
570
+ var next_indent = this.$getIndent(line);
571
+ } else {
572
+ return;
573
+ }
574
+ var indent = next_indent + session.getTabString();
575
+
576
+ return {
577
+ text: '\n' + indent + '\n' + next_indent + closing,
578
+ selection: [1, indent.length, 1, indent.length]
579
+ };
580
+ } else {
581
+ CstyleBehaviour.clearMaybeInsertedClosing();
582
+ }
583
+ });
584
+
585
+ this.add("braces", "deletion", function (state, action, editor, session, range) {
586
+ var selected = session.doc.getTextRange(range);
587
+ if (!range.isMultiLine() && selected == '{') {
588
+ var line = session.doc.getLine(range.start.row);
589
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
590
+ if (rightChar == '}') {
591
+ range.end.column++;
592
+ return range;
593
+ } else {
594
+ maybeInsertedBrackets--;
595
+ }
596
+ }
597
+ });
598
+
599
+ this.add("parens", "insertion", function (state, action, editor, session, text) {
600
+ if (text == '(') {
601
+ var selection = editor.getSelectionRange();
602
+ var selected = session.doc.getTextRange(selection);
603
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
604
+ return {
605
+ text: '(' + selected + ')',
606
+ selection: false
607
+ };
608
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
609
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
610
+ return {
611
+ text: '()',
612
+ selection: [1, 1]
613
+ };
614
+ }
615
+ } else if (text == ')') {
616
+ var cursor = editor.getCursorPosition();
617
+ var line = session.doc.getLine(cursor.row);
618
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
619
+ if (rightChar == ')') {
620
+ var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
621
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
622
+ CstyleBehaviour.popAutoInsertedClosing();
623
+ return {
624
+ text: '',
625
+ selection: [1, 1]
626
+ };
627
+ }
628
+ }
629
+ }
630
+ });
631
+
632
+ this.add("parens", "deletion", function (state, action, editor, session, range) {
633
+ var selected = session.doc.getTextRange(range);
634
+ if (!range.isMultiLine() && selected == '(') {
635
+ var line = session.doc.getLine(range.start.row);
636
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
637
+ if (rightChar == ')') {
638
+ range.end.column++;
639
+ return range;
640
+ }
641
+ }
642
+ });
643
+
644
+ this.add("brackets", "insertion", function (state, action, editor, session, text) {
645
+ if (text == '[') {
646
+ var selection = editor.getSelectionRange();
647
+ var selected = session.doc.getTextRange(selection);
648
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
649
+ return {
650
+ text: '[' + selected + ']',
651
+ selection: false
652
+ };
653
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
654
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
655
+ return {
656
+ text: '[]',
657
+ selection: [1, 1]
658
+ };
659
+ }
660
+ } else if (text == ']') {
661
+ var cursor = editor.getCursorPosition();
662
+ var line = session.doc.getLine(cursor.row);
663
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
664
+ if (rightChar == ']') {
665
+ var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
666
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
667
+ CstyleBehaviour.popAutoInsertedClosing();
668
+ return {
669
+ text: '',
670
+ selection: [1, 1]
671
+ };
672
+ }
673
+ }
674
+ }
675
+ });
676
+
677
+ this.add("brackets", "deletion", function (state, action, editor, session, range) {
678
+ var selected = session.doc.getTextRange(range);
679
+ if (!range.isMultiLine() && selected == '[') {
680
+ var line = session.doc.getLine(range.start.row);
681
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
682
+ if (rightChar == ']') {
683
+ range.end.column++;
684
+ return range;
685
+ }
686
+ }
687
+ });
688
+
689
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
690
+ if (text == '"' || text == "'") {
691
+ var quote = text;
692
+ var selection = editor.getSelectionRange();
693
+ var selected = session.doc.getTextRange(selection);
694
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
695
+ return {
696
+ text: quote + selected + quote,
697
+ selection: false
698
+ };
699
+ } else {
700
+ var cursor = editor.getCursorPosition();
701
+ var line = session.doc.getLine(cursor.row);
702
+ var leftChar = line.substring(cursor.column-1, cursor.column);
703
+ if (leftChar == '\\') {
704
+ return null;
705
+ }
706
+ var tokens = session.getTokens(selection.start.row);
707
+ var col = 0, token;
708
+ var quotepos = -1; // Track whether we're inside an open quote.
709
+
710
+ for (var x = 0; x < tokens.length; x++) {
711
+ token = tokens[x];
712
+ if (token.type == "string") {
713
+ quotepos = -1;
714
+ } else if (quotepos < 0) {
715
+ quotepos = token.value.indexOf(quote);
716
+ }
717
+ if ((token.value.length + col) > selection.start.column) {
718
+ break;
719
+ }
720
+ col += tokens[x].value.length;
721
+ }
722
+ 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)))) {
723
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
724
+ return;
725
+ return {
726
+ text: quote + quote,
727
+ selection: [1,1]
728
+ };
729
+ } else if (token && token.type === "string") {
730
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
731
+ if (rightChar == quote) {
732
+ return {
733
+ text: '',
734
+ selection: [1, 1]
735
+ };
736
+ }
737
+ }
738
+ }
739
+ }
740
+ });
741
+
742
+ this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
743
+ var selected = session.doc.getTextRange(range);
744
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
745
+ var line = session.doc.getLine(range.start.row);
746
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
747
+ if (rightChar == selected) {
748
+ range.end.column++;
749
+ return range;
750
+ }
751
+ }
752
+ });
753
+
754
+ };
755
+
756
+ oop.inherits(CstyleBehaviour, Behaviour);
757
+
758
+ exports.CstyleBehaviour = CstyleBehaviour;
759
+ });
760
+
376
761
  define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
377
762
 
378
763
 
@@ -380,15 +765,24 @@ var oop = require("../../lib/oop");
380
765
  var Range = require("../../range").Range;
381
766
  var BaseFoldMode = require("./fold_mode").FoldMode;
382
767
 
383
- var FoldMode = exports.FoldMode = function() {};
768
+ var FoldMode = exports.FoldMode = function(commentRegex) {
769
+ if (commentRegex) {
770
+ this.foldingStartMarker = new RegExp(
771
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
772
+ );
773
+ this.foldingStopMarker = new RegExp(
774
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
775
+ );
776
+ }
777
+ };
384
778
  oop.inherits(FoldMode, BaseFoldMode);
385
779
 
386
780
  (function() {
387
781
 
388
782
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
389
783
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
390
-
391
- this.getFoldWidgetRange = function(session, foldStyle, row) {
784
+
785
+ this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
392
786
  var line = session.getLine(row);
393
787
  var match = line.match(this.foldingStartMarker);
394
788
  if (match) {
@@ -396,115 +790,63 @@ oop.inherits(FoldMode, BaseFoldMode);
396
790
 
397
791
  if (match[1])
398
792
  return this.openingBracketBlock(session, match[1], row, i);
399
-
400
- var range = session.getCommentFoldRange(row, i + match[0].length);
401
- range.end.column -= 2;
793
+
794
+ var range = session.getCommentFoldRange(row, i + match[0].length, 1);
795
+
796
+ if (range && !range.isMultiLine()) {
797
+ if (forceMultiline) {
798
+ range = this.getSectionRange(session, row);
799
+ } else if (foldStyle != "all")
800
+ range = null;
801
+ }
802
+
402
803
  return range;
403
804
  }
404
805
 
405
- if (foldStyle !== "markbeginend")
806
+ if (foldStyle === "markbegin")
406
807
  return;
407
-
808
+
408
809
  var match = line.match(this.foldingStopMarker);
409
810
  if (match) {
410
811
  var i = match.index + match[0].length;
411
812
 
412
- if (match[2]) {
413
- var range = session.getCommentFoldRange(row, i);
414
- range.end.column -= 2;
415
- return range;
416
- }
417
-
418
- var end = {row: row, column: i};
419
- var start = session.$findOpeningBracket(match[1], end);
420
-
421
- if (!start)
422
- return;
423
-
424
- start.column++;
425
- end.column--;
813
+ if (match[1])
814
+ return this.closingBracketBlock(session, match[1], row, i);
426
815
 
427
- return Range.fromPoints(start, end);
816
+ return session.getCommentFoldRange(row, i, -1);
428
817
  }
429
818
  };
430
819
 
431
- }).call(FoldMode.prototype);
432
-
433
- });
434
-
435
- define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
436
-
437
-
438
- var Range = require("../../range").Range;
439
-
440
- var FoldMode = exports.FoldMode = function() {};
441
-
442
- (function() {
443
-
444
- this.foldingStartMarker = null;
445
- this.foldingStopMarker = null;
446
-
447
- // must return "" if there's no fold, to enable caching
448
- this.getFoldWidget = function(session, foldStyle, row) {
820
+ this.getSectionRange = function(session, row) {
449
821
  var line = session.getLine(row);
450
- if (this.foldingStartMarker.test(line))
451
- return "start";
452
- if (foldStyle == "markbeginend"
453
- && this.foldingStopMarker
454
- && this.foldingStopMarker.test(line))
455
- return "end";
456
- return "";
457
- };
458
-
459
- this.getFoldWidgetRange = function(session, foldStyle, row) {
460
- return null;
461
- };
462
-
463
- this.indentationBlock = function(session, row, column) {
464
- var re = /\S/;
465
- var line = session.getLine(row);
466
- var startLevel = line.search(re);
467
- if (startLevel == -1)
468
- return;
469
-
470
- var startColumn = column || line.length;
471
- var maxRow = session.getLength();
822
+ var startIndent = line.search(/\S/);
472
823
  var startRow = row;
824
+ var startColumn = line.length;
825
+ row = row + 1;
473
826
  var endRow = row;
474
-
827
+ var maxRow = session.getLength();
475
828
  while (++row < maxRow) {
476
- var level = session.getLine(row).search(re);
477
-
478
- if (level == -1)
829
+ line = session.getLine(row);
830
+ var indent = line.search(/\S/);
831
+ if (indent === -1)
479
832
  continue;
480
-
481
- if (level <= startLevel)
833
+ if (startIndent > indent)
482
834
  break;
483
-
835
+ var subRange = this.getFoldWidgetRange(session, "all", row);
836
+
837
+ if (subRange) {
838
+ if (subRange.start.row <= startRow) {
839
+ break;
840
+ } else if (subRange.isMultiLine()) {
841
+ row = subRange.end.row;
842
+ } else if (startIndent == indent) {
843
+ break;
844
+ }
845
+ }
484
846
  endRow = row;
485
847
  }
486
-
487
- if (endRow > startRow) {
488
- var endColumn = session.getLine(endRow).length;
489
- return new Range(startRow, startColumn, endRow, endColumn);
490
- }
491
- };
492
-
493
- this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
494
- var start = {row: row, column: column + 1};
495
- var end = session.$findClosingBracket(bracket, start, typeRe);
496
- if (!end)
497
- return;
498
-
499
- var fw = session.foldWidgets[end.row];
500
- if (fw == null)
501
- fw = this.getFoldWidget(session, end.row);
502
-
503
- if (fw == "start" && end.row > start.row) {
504
- end.row --;
505
- end.column = session.getLine(end.row).length;
506
- }
507
- return Range.fromPoints(start, end);
848
+
849
+ return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
508
850
  };
509
851
 
510
852
  }).call(FoldMode.prototype);