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
- *
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
 
@@ -48,7 +41,8 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
48
41
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
49
42
 
50
43
  var Mode = function() {
51
- this.$tokenizer = new Tokenizer(new glslHighlightRules().getRules());
44
+ this.HighlightRules = glslHighlightRules;
45
+
52
46
  this.$outdent = new MatchingBraceOutdent();
53
47
  this.$behaviour = new CstyleBehaviour();
54
48
  this.foldingRules = new CStyleFoldMode();
@@ -71,47 +65,24 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
71
65
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
72
66
 
73
67
  var Mode = function() {
74
- this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
68
+ this.HighlightRules = c_cppHighlightRules;
69
+
75
70
  this.$outdent = new MatchingBraceOutdent();
76
71
  this.$behaviour = new CstyleBehaviour();
72
+
77
73
  this.foldingRules = new CStyleFoldMode();
78
74
  };
79
75
  oop.inherits(Mode, TextMode);
80
76
 
81
77
  (function() {
82
78
 
83
- this.toggleCommentLines = function(state, doc, startRow, endRow) {
84
- var outdent = true;
85
- var re = /^(\s*)\/\//;
86
-
87
- for (var i=startRow; i<= endRow; i++) {
88
- if (!re.test(doc.getLine(i))) {
89
- outdent = false;
90
- break;
91
- }
92
- }
93
-
94
- if (outdent) {
95
- var deleteRange = new Range(0, 0, 0, 0);
96
- for (var i=startRow; i<= endRow; i++)
97
- {
98
- var line = doc.getLine(i);
99
- var m = line.match(re);
100
- deleteRange.start.row = i;
101
- deleteRange.end.row = i;
102
- deleteRange.end.column = m[0].length;
103
- doc.replace(deleteRange, m[1]);
104
- }
105
- }
106
- else {
107
- doc.indentRows(startRow, endRow, "//");
108
- }
109
- };
79
+ this.lineCommentStart = "//";
80
+ this.blockComment = {start: "/*", end: "*/"};
110
81
 
111
82
  this.getNextLineIndent = function(state, line, tab) {
112
83
  var indent = this.$getIndent(line);
113
84
 
114
- var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
85
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
115
86
  var tokens = tokenizedLine.tokens;
116
87
  var endState = tokenizedLine.state;
117
88
 
@@ -148,38 +119,56 @@ oop.inherits(Mode, TextMode);
148
119
  this.$outdent.autoOutdent(doc, row);
149
120
  };
150
121
 
122
+ this.$id = "ace/mode/c_cpp";
151
123
  }).call(Mode.prototype);
152
124
 
153
125
  exports.Mode = Mode;
154
126
  });
155
-
156
- define('ace/mode/c_cpp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
127
+ define('ace/mode/c_cpp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
157
128
 
158
129
 
159
130
  var oop = require("../lib/oop");
160
- var lang = require("../lib/lang");
161
131
  var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
162
132
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
133
+ var cFunctions = exports.cFunctions = "\\s*\\bhypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len)))\\b"
163
134
 
164
135
  var c_cppHighlightRules = function() {
165
136
 
166
- var keywords = lang.arrayToMap(
167
- ("and|double|not_eq|throw|and_eq|dynamic_cast|operator|true|" +
168
- "asm|else|or|try|auto|enum|or_eq|typedef|bitand|explicit|private|" +
169
- "typeid|bitor|extern|protected|typename|bool|false|public|union|" +
170
- "break|float|register|unsigned|case|fro|reinterpret-cast|using|catch|" +
171
- "friend|return|virtual|char|goto|short|void|class|if|signed|volatile|" +
172
- "compl|inline|sizeof|wchar_t|const|int|static|while|const-cast|long|" +
173
- "static_cast|xor|continue|mutable|struct|xor_eq|default|namespace|" +
174
- "switch|delete|new|template|do|not|this|for").split("|")
137
+ var keywordControls = (
138
+ "break|case|continue|default|do|else|for|goto|if|_Pragma|" +
139
+ "return|switch|while|catch|operator|try|throw|using"
140
+ );
141
+
142
+ var storageType = (
143
+ "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
144
+ "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
145
+ "class|wchar_t|template"
146
+ );
147
+
148
+ var storageModifiers = (
149
+ "const|extern|register|restrict|static|volatile|inline|private:|" +
150
+ "protected:|public:|friend|explicit|virtual|export|mutable|typename"
151
+ );
152
+
153
+ var keywordOperators = (
154
+ "and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" +
155
+ "const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace"
175
156
  );
176
157
 
177
- var buildinConstants = lang.arrayToMap(
178
- ("NULL").split("|")
158
+ var builtinConstants = (
159
+ "NULL|true|false|TRUE|FALSE"
179
160
  );
180
161
 
181
- // regexp must not have capturing parentheses. Use (?:) instead.
182
- // regexps are ordered -> the first match is used
162
+ var keywordMapper = this.$keywords = this.createKeywordMapper({
163
+ "keyword.control" : keywordControls,
164
+ "storage.type" : storageType,
165
+ "storage.modifier" : storageModifiers,
166
+ "keyword.operator" : keywordOperators,
167
+ "variable.language": "this",
168
+ "constant.language": builtinConstants
169
+ }, "identifier");
170
+
171
+ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\d\\$_\u00a1-\uffff]*\\b";
183
172
 
184
173
  this.$rules = {
185
174
  "start" : [
@@ -190,7 +179,6 @@ var c_cppHighlightRules = function() {
190
179
  DocCommentHighlightRules.getStartRule("doc-start"),
191
180
  {
192
181
  token : "comment", // multi line comment
193
- merge : true,
194
182
  regex : "\\/\\*",
195
183
  next : "comment"
196
184
  }, {
@@ -198,7 +186,6 @@ var c_cppHighlightRules = function() {
198
186
  regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
199
187
  }, {
200
188
  token : "string", // multi line string start
201
- merge : true,
202
189
  regex : '["].*\\\\$',
203
190
  next : "qqstring"
204
191
  }, {
@@ -206,32 +193,26 @@ var c_cppHighlightRules = function() {
206
193
  regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
207
194
  }, {
208
195
  token : "string", // multi line string start
209
- merge : true,
210
196
  regex : "['].*\\\\$",
211
197
  next : "qstring"
212
198
  }, {
213
199
  token : "constant.numeric", // hex
214
- regex : "0[xX][0-9a-fA-F]+\\b"
200
+ regex : "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
215
201
  }, {
216
202
  token : "constant.numeric", // float
217
- regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
203
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
204
+ }, {
205
+ token : "keyword", // pre-compiler directives
206
+ regex : "#\\s*(?:include|import|pragma|line|define|undef|if|ifdef|else|elif|ifndef)\\b",
207
+ next : "directive"
218
208
  }, {
219
- token : "constant", // <CONSTANT>
220
- regex : "<[a-zA-Z0-9.]+>"
209
+ token : "keyword", // special case pre-compiler directive
210
+ regex : "(?:#\\s*endif)\\b"
221
211
  }, {
222
- token : "keyword", // pre-compiler directivs
223
- regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"
224
- }, {
225
- token : function(value) {
226
- if (value == "this")
227
- return "variable.language";
228
- else if (keywords.hasOwnProperty(value))
229
- return "keyword";
230
- else if (buildinConstants.hasOwnProperty(value))
231
- return "constant.language";
232
- else
233
- return "identifier";
234
- },
212
+ token : "support.function.C99.c",
213
+ regex : cFunctions
214
+ }, {
215
+ token : keywordMapper,
235
216
  regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
236
217
  }, {
237
218
  token : "keyword.operator",
@@ -257,7 +238,6 @@ var c_cppHighlightRules = function() {
257
238
  next : "start"
258
239
  }, {
259
240
  token : "comment", // comment spanning whole line
260
- merge : true,
261
241
  regex : ".+"
262
242
  }
263
243
  ],
@@ -268,7 +248,6 @@ var c_cppHighlightRules = function() {
268
248
  next : "start"
269
249
  }, {
270
250
  token : "string",
271
- merge : true,
272
251
  regex : '.+'
273
252
  }
274
253
  ],
@@ -279,12 +258,41 @@ var c_cppHighlightRules = function() {
279
258
  next : "start"
280
259
  }, {
281
260
  token : "string",
282
- merge : true,
283
261
  regex : '.+'
284
262
  }
263
+ ],
264
+ "directive" : [
265
+ {
266
+ token : "constant.other.multiline",
267
+ regex : /\\/
268
+ },
269
+ {
270
+ token : "constant.other.multiline",
271
+ regex : /.*\\/
272
+ },
273
+ {
274
+ token : "constant.other",
275
+ regex : "\\s*<.+?>",
276
+ next : "start"
277
+ },
278
+ {
279
+ token : "constant.other", // single line
280
+ regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
281
+ next : "start"
282
+ },
283
+ {
284
+ token : "constant.other", // single line
285
+ regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
286
+ next : "start"
287
+ },
288
+ {
289
+ token : "constant.other",
290
+ regex : /[^\\\/]+/,
291
+ next : "start"
292
+ }
285
293
  ]
286
294
  };
287
-
295
+
288
296
  this.embedRules(DocCommentHighlightRules, "doc-",
289
297
  [ DocCommentHighlightRules.getEndRule("start") ]);
290
298
  };
@@ -307,21 +315,10 @@ var DocCommentHighlightRules = function() {
307
315
  token : "comment.doc.tag",
308
316
  regex : "@[\\w\\d_]+" // TODO: fix email addresses
309
317
  }, {
310
- token : "comment.doc",
311
- merge : true,
312
- regex : "\\s+"
313
- }, {
314
- token : "comment.doc",
315
- merge : true,
316
- regex : "TODO"
317
- }, {
318
- token : "comment.doc",
319
- merge : true,
320
- regex : "[^@\\*]+"
318
+ token : "comment.doc.tag",
319
+ regex : "\\bTODO\\b"
321
320
  }, {
322
- token : "comment.doc",
323
- merge : true,
324
- regex : "."
321
+ defaultToken : "comment.doc"
325
322
  }]
326
323
  };
327
324
  };
@@ -331,7 +328,6 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
331
328
  DocCommentHighlightRules.getStartRule = function(start) {
332
329
  return {
333
330
  token : "comment.doc", // doc comment
334
- merge : true,
335
331
  regex : "\\/\\*(?=\\*)",
336
332
  next : start
337
333
  };
@@ -340,7 +336,6 @@ DocCommentHighlightRules.getStartRule = function(start) {
340
336
  DocCommentHighlightRules.getEndRule = function (start) {
341
337
  return {
342
338
  token : "comment.doc", // closing comment
343
- merge : true,
344
339
  regex : "\\*\\/",
345
340
  next : start
346
341
  };
@@ -383,12 +378,7 @@ var MatchingBraceOutdent = function() {};
383
378
  };
384
379
 
385
380
  this.$getIndent = function(line) {
386
- var match = line.match(/^(\s+)/);
387
- if (match) {
388
- return match[1];
389
- }
390
-
391
- return "";
381
+ return line.match(/^\s*/)[0];
392
382
  };
393
383
 
394
384
  }).call(MatchingBraceOutdent.prototype);
@@ -396,59 +386,155 @@ var MatchingBraceOutdent = function() {};
396
386
  exports.MatchingBraceOutdent = MatchingBraceOutdent;
397
387
  });
398
388
 
399
- define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
389
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
400
390
 
401
391
 
402
392
  var oop = require("../../lib/oop");
403
393
  var Behaviour = require("../behaviour").Behaviour;
394
+ var TokenIterator = require("../../token_iterator").TokenIterator;
395
+ var lang = require("../../lib/lang");
396
+
397
+ var SAFE_INSERT_IN_TOKENS =
398
+ ["text", "paren.rparen", "punctuation.operator"];
399
+ var SAFE_INSERT_BEFORE_TOKENS =
400
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
401
+
402
+
403
+ var autoInsertedBrackets = 0;
404
+ var autoInsertedRow = -1;
405
+ var autoInsertedLineEnd = "";
406
+ var maybeInsertedBrackets = 0;
407
+ var maybeInsertedRow = -1;
408
+ var maybeInsertedLineStart = "";
409
+ var maybeInsertedLineEnd = "";
404
410
 
405
411
  var CstyleBehaviour = function () {
412
+
413
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
414
+ var cursor = editor.getCursorPosition();
415
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
416
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
417
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
418
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
419
+ return false;
420
+ }
421
+ iterator.stepForward();
422
+ return iterator.getCurrentTokenRow() !== cursor.row ||
423
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
424
+ };
425
+
426
+ CstyleBehaviour.$matchTokenType = function(token, types) {
427
+ return types.indexOf(token.type || token) > -1;
428
+ };
429
+
430
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
431
+ var cursor = editor.getCursorPosition();
432
+ var line = session.doc.getLine(cursor.row);
433
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
434
+ autoInsertedBrackets = 0;
435
+ autoInsertedRow = cursor.row;
436
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
437
+ autoInsertedBrackets++;
438
+ };
439
+
440
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
441
+ var cursor = editor.getCursorPosition();
442
+ var line = session.doc.getLine(cursor.row);
443
+ if (!this.isMaybeInsertedClosing(cursor, line))
444
+ maybeInsertedBrackets = 0;
445
+ maybeInsertedRow = cursor.row;
446
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
447
+ maybeInsertedLineEnd = line.substr(cursor.column);
448
+ maybeInsertedBrackets++;
449
+ };
450
+
451
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
452
+ return autoInsertedBrackets > 0 &&
453
+ cursor.row === autoInsertedRow &&
454
+ bracket === autoInsertedLineEnd[0] &&
455
+ line.substr(cursor.column) === autoInsertedLineEnd;
456
+ };
457
+
458
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
459
+ return maybeInsertedBrackets > 0 &&
460
+ cursor.row === maybeInsertedRow &&
461
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
462
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
463
+ };
464
+
465
+ CstyleBehaviour.popAutoInsertedClosing = function() {
466
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
467
+ autoInsertedBrackets--;
468
+ };
469
+
470
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
471
+ maybeInsertedBrackets = 0;
472
+ maybeInsertedRow = -1;
473
+ };
406
474
 
407
475
  this.add("braces", "insertion", function (state, action, editor, session, text) {
476
+ var cursor = editor.getCursorPosition();
477
+ var line = session.doc.getLine(cursor.row);
408
478
  if (text == '{') {
409
479
  var selection = editor.getSelectionRange();
410
480
  var selected = session.doc.getTextRange(selection);
411
- if (selected !== "") {
481
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
412
482
  return {
413
483
  text: '{' + selected + '}',
414
484
  selection: false
415
485
  };
416
- } else {
417
- return {
418
- text: '{}',
419
- selection: [1, 1]
420
- };
486
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
487
+ if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
488
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
489
+ return {
490
+ text: '{}',
491
+ selection: [1, 1]
492
+ };
493
+ } else {
494
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
495
+ return {
496
+ text: '{',
497
+ selection: [1, 1]
498
+ };
499
+ }
421
500
  }
422
501
  } else if (text == '}') {
423
- var cursor = editor.getCursorPosition();
424
- var line = session.doc.getLine(cursor.row);
425
502
  var rightChar = line.substring(cursor.column, cursor.column + 1);
426
503
  if (rightChar == '}') {
427
504
  var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
428
- if (matching !== null) {
505
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
506
+ CstyleBehaviour.popAutoInsertedClosing();
429
507
  return {
430
508
  text: '',
431
509
  selection: [1, 1]
432
510
  };
433
511
  }
434
512
  }
435
- } else if (text == "\n") {
436
- var cursor = editor.getCursorPosition();
437
- var line = session.doc.getLine(cursor.row);
513
+ } else if (text == "\n" || text == "\r\n") {
514
+ var closing = "";
515
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
516
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
517
+ CstyleBehaviour.clearMaybeInsertedClosing();
518
+ }
438
519
  var rightChar = line.substring(cursor.column, cursor.column + 1);
439
- if (rightChar == '}') {
440
- var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
520
+ if (rightChar === '}') {
521
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
441
522
  if (!openBracePos)
442
523
  return null;
443
-
444
- var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
445
- var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
446
-
447
- return {
448
- text: '\n' + indent + '\n' + next_indent,
449
- selection: [1, indent.length, 1, indent.length]
450
- };
524
+ var next_indent = this.$getIndent(session.getLine(openBracePos.row));
525
+ } else if (closing) {
526
+ var next_indent = this.$getIndent(line);
527
+ } else {
528
+ return;
451
529
  }
530
+ var indent = next_indent + session.getTabString();
531
+
532
+ return {
533
+ text: '\n' + indent + '\n' + next_indent + closing,
534
+ selection: [1, indent.length, 1, indent.length]
535
+ };
536
+ } else {
537
+ CstyleBehaviour.clearMaybeInsertedClosing();
452
538
  }
453
539
  });
454
540
 
@@ -460,6 +546,8 @@ var CstyleBehaviour = function () {
460
546
  if (rightChar == '}') {
461
547
  range.end.column++;
462
548
  return range;
549
+ } else {
550
+ maybeInsertedBrackets--;
463
551
  }
464
552
  }
465
553
  });
@@ -468,12 +556,13 @@ var CstyleBehaviour = function () {
468
556
  if (text == '(') {
469
557
  var selection = editor.getSelectionRange();
470
558
  var selected = session.doc.getTextRange(selection);
471
- if (selected !== "") {
559
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
472
560
  return {
473
561
  text: '(' + selected + ')',
474
562
  selection: false
475
563
  };
476
- } else {
564
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
565
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
477
566
  return {
478
567
  text: '()',
479
568
  selection: [1, 1]
@@ -485,7 +574,8 @@ var CstyleBehaviour = function () {
485
574
  var rightChar = line.substring(cursor.column, cursor.column + 1);
486
575
  if (rightChar == ')') {
487
576
  var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
488
- if (matching !== null) {
577
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
578
+ CstyleBehaviour.popAutoInsertedClosing();
489
579
  return {
490
580
  text: '',
491
581
  selection: [1, 1]
@@ -511,12 +601,13 @@ var CstyleBehaviour = function () {
511
601
  if (text == '[') {
512
602
  var selection = editor.getSelectionRange();
513
603
  var selected = session.doc.getTextRange(selection);
514
- if (selected !== "") {
604
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
515
605
  return {
516
606
  text: '[' + selected + ']',
517
607
  selection: false
518
608
  };
519
- } else {
609
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
610
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
520
611
  return {
521
612
  text: '[]',
522
613
  selection: [1, 1]
@@ -528,7 +619,8 @@ var CstyleBehaviour = function () {
528
619
  var rightChar = line.substring(cursor.column, cursor.column + 1);
529
620
  if (rightChar == ']') {
530
621
  var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
531
- if (matching !== null) {
622
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
623
+ CstyleBehaviour.popAutoInsertedClosing();
532
624
  return {
533
625
  text: '',
534
626
  selection: [1, 1]
@@ -555,7 +647,7 @@ var CstyleBehaviour = function () {
555
647
  var quote = text;
556
648
  var selection = editor.getSelectionRange();
557
649
  var selected = session.doc.getTextRange(selection);
558
- if (selected !== "") {
650
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
559
651
  return {
560
652
  text: quote + selected + quote,
561
653
  selection: false
@@ -564,13 +656,9 @@ var CstyleBehaviour = function () {
564
656
  var cursor = editor.getCursorPosition();
565
657
  var line = session.doc.getLine(cursor.row);
566
658
  var leftChar = line.substring(cursor.column-1, cursor.column);
567
-
568
- // We're escaped.
569
659
  if (leftChar == '\\') {
570
660
  return null;
571
661
  }
572
-
573
- // Find what token we're inside.
574
662
  var tokens = session.getTokens(selection.start.row);
575
663
  var col = 0, token;
576
664
  var quotepos = -1; // Track whether we're inside an open quote.
@@ -587,15 +675,14 @@ var CstyleBehaviour = function () {
587
675
  }
588
676
  col += tokens[x].value.length;
589
677
  }
590
-
591
- // Try and be smart about when we auto insert.
592
678
  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)))) {
679
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
680
+ return;
593
681
  return {
594
682
  text: quote + quote,
595
683
  selection: [1,1]
596
684
  };
597
685
  } else if (token && token.type === "string") {
598
- // Ignore input and move right one if we're typing over the closing quote.
599
686
  var rightChar = line.substring(cursor.column, cursor.column + 1);
600
687
  if (rightChar == quote) {
601
688
  return {
@@ -613,7 +700,7 @@ var CstyleBehaviour = function () {
613
700
  if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
614
701
  var line = session.doc.getLine(range.start.row);
615
702
  var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
616
- if (rightChar == '"') {
703
+ if (rightChar == selected) {
617
704
  range.end.column++;
618
705
  return range;
619
706
  }
@@ -634,15 +721,24 @@ var oop = require("../../lib/oop");
634
721
  var Range = require("../../range").Range;
635
722
  var BaseFoldMode = require("./fold_mode").FoldMode;
636
723
 
637
- var FoldMode = exports.FoldMode = function() {};
724
+ var FoldMode = exports.FoldMode = function(commentRegex) {
725
+ if (commentRegex) {
726
+ this.foldingStartMarker = new RegExp(
727
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
728
+ );
729
+ this.foldingStopMarker = new RegExp(
730
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
731
+ );
732
+ }
733
+ };
638
734
  oop.inherits(FoldMode, BaseFoldMode);
639
735
 
640
736
  (function() {
641
737
 
642
738
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
643
739
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
644
-
645
- this.getFoldWidgetRange = function(session, foldStyle, row) {
740
+
741
+ this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
646
742
  var line = session.getLine(row);
647
743
  var match = line.match(this.foldingStartMarker);
648
744
  if (match) {
@@ -650,140 +746,87 @@ oop.inherits(FoldMode, BaseFoldMode);
650
746
 
651
747
  if (match[1])
652
748
  return this.openingBracketBlock(session, match[1], row, i);
653
-
654
- var range = session.getCommentFoldRange(row, i + match[0].length);
655
- range.end.column -= 2;
749
+
750
+ var range = session.getCommentFoldRange(row, i + match[0].length, 1);
751
+
752
+ if (range && !range.isMultiLine()) {
753
+ if (forceMultiline) {
754
+ range = this.getSectionRange(session, row);
755
+ } else if (foldStyle != "all")
756
+ range = null;
757
+ }
758
+
656
759
  return range;
657
760
  }
658
761
 
659
- if (foldStyle !== "markbeginend")
762
+ if (foldStyle === "markbegin")
660
763
  return;
661
-
764
+
662
765
  var match = line.match(this.foldingStopMarker);
663
766
  if (match) {
664
767
  var i = match.index + match[0].length;
665
768
 
666
- if (match[2]) {
667
- var range = session.getCommentFoldRange(row, i);
668
- range.end.column -= 2;
669
- return range;
670
- }
671
-
672
- var end = {row: row, column: i};
673
- var start = session.$findOpeningBracket(match[1], end);
674
-
675
- if (!start)
676
- return;
677
-
678
- start.column++;
679
- end.column--;
769
+ if (match[1])
770
+ return this.closingBracketBlock(session, match[1], row, i);
680
771
 
681
- return Range.fromPoints(start, end);
772
+ return session.getCommentFoldRange(row, i, -1);
682
773
  }
683
774
  };
684
775
 
685
- }).call(FoldMode.prototype);
686
-
687
- });
688
-
689
- define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
690
-
691
-
692
- var Range = require("../../range").Range;
693
-
694
- var FoldMode = exports.FoldMode = function() {};
695
-
696
- (function() {
697
-
698
- this.foldingStartMarker = null;
699
- this.foldingStopMarker = null;
700
-
701
- // must return "" if there's no fold, to enable caching
702
- this.getFoldWidget = function(session, foldStyle, row) {
776
+ this.getSectionRange = function(session, row) {
703
777
  var line = session.getLine(row);
704
- if (this.foldingStartMarker.test(line))
705
- return "start";
706
- if (foldStyle == "markbeginend"
707
- && this.foldingStopMarker
708
- && this.foldingStopMarker.test(line))
709
- return "end";
710
- return "";
711
- };
712
-
713
- this.getFoldWidgetRange = function(session, foldStyle, row) {
714
- return null;
715
- };
716
-
717
- this.indentationBlock = function(session, row, column) {
718
- var re = /\S/;
719
- var line = session.getLine(row);
720
- var startLevel = line.search(re);
721
- if (startLevel == -1)
722
- return;
723
-
724
- var startColumn = column || line.length;
725
- var maxRow = session.getLength();
778
+ var startIndent = line.search(/\S/);
726
779
  var startRow = row;
780
+ var startColumn = line.length;
781
+ row = row + 1;
727
782
  var endRow = row;
728
-
783
+ var maxRow = session.getLength();
729
784
  while (++row < maxRow) {
730
- var level = session.getLine(row).search(re);
731
-
732
- if (level == -1)
785
+ line = session.getLine(row);
786
+ var indent = line.search(/\S/);
787
+ if (indent === -1)
733
788
  continue;
734
-
735
- if (level <= startLevel)
789
+ if (startIndent > indent)
736
790
  break;
737
-
791
+ var subRange = this.getFoldWidgetRange(session, "all", row);
792
+
793
+ if (subRange) {
794
+ if (subRange.start.row <= startRow) {
795
+ break;
796
+ } else if (subRange.isMultiLine()) {
797
+ row = subRange.end.row;
798
+ } else if (startIndent == indent) {
799
+ break;
800
+ }
801
+ }
738
802
  endRow = row;
739
803
  }
740
-
741
- if (endRow > startRow) {
742
- var endColumn = session.getLine(endRow).length;
743
- return new Range(startRow, startColumn, endRow, endColumn);
744
- }
745
- };
746
-
747
- this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
748
- var start = {row: row, column: column + 1};
749
- var end = session.$findClosingBracket(bracket, start, typeRe);
750
- if (!end)
751
- return;
752
-
753
- var fw = session.foldWidgets[end.row];
754
- if (fw == null)
755
- fw = this.getFoldWidget(session, end.row);
756
-
757
- if (fw == "start" && end.row > start.row) {
758
- end.row --;
759
- end.column = session.getLine(end.row).length;
760
- }
761
- return Range.fromPoints(start, end);
804
+
805
+ return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
762
806
  };
763
807
 
764
808
  }).call(FoldMode.prototype);
765
809
 
766
810
  });
767
811
 
768
- define('ace/mode/glsl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/c_cpp_highlight_rules'], function(require, exports, module) {
812
+ define('ace/mode/glsl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/c_cpp_highlight_rules'], function(require, exports, module) {
769
813
 
770
814
 
771
815
  var oop = require("../lib/oop");
772
- var lang = require("../lib/lang");
773
816
  var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
774
817
 
775
818
  var glslHighlightRules = function() {
776
819
 
777
- var keywords = lang.arrayToMap(
778
- ("attribute|const|uniform|varying|break|continue|do|for|while|" +
820
+ var keywords = (
821
+ "attribute|const|uniform|varying|break|continue|do|for|while|" +
779
822
  "if|else|in|out|inout|float|int|void|bool|true|false|" +
780
823
  "lowp|mediump|highp|precision|invariant|discard|return|mat2|mat3|" +
781
824
  "mat4|vec2|vec3|vec4|ivec2|ivec3|ivec4|bvec2|bvec3|bvec4|sampler2D|" +
782
- "samplerCube|struct").split("|")
825
+ "samplerCube|struct"
783
826
  );
784
827
 
785
- var buildinConstants = lang.arrayToMap(
786
- ("radians|degrees|sin|cos|tan|asin|acos|atan|pow|" +
828
+ var buildinConstants = (
829
+ "radians|degrees|sin|cos|tan|asin|acos|atan|pow|" +
787
830
  "exp|log|exp2|log2|sqrt|inversesqrt|abs|sign|floor|ceil|fract|mod|" +
788
831
  "min|max|clamp|mix|step|smoothstep|length|distance|dot|cross|" +
789
832
  "normalize|faceforward|reflect|refract|matrixCompMult|lessThan|" +
@@ -794,25 +837,20 @@ var glslHighlightRules = function() {
794
837
  "gl_MaxVertexTextureImageUnits|gl_MaxCombinedTextureImageUnits|" +
795
838
  "gl_MaxTextureImageUnits|gl_MaxFragmentUniformVectors|gl_MaxDrawBuffers|" +
796
839
  "gl_DepthRangeParameters|gl_DepthRange|" +
797
- // The following two are only for MIME x-shader/x-vertex.
798
840
  "gl_Position|gl_PointSize|" +
799
- // The following five are only for MIME x-shader/x-fragment.
800
- "gl_FragCoord|gl_FrontFacing|gl_PointCoord|gl_FragColor|gl_FragData").split("|")
841
+ "gl_FragCoord|gl_FrontFacing|gl_PointCoord|gl_FragColor|gl_FragData"
801
842
  );
802
843
 
844
+ var keywordMapper = this.createKeywordMapper({
845
+ "variable.language": "this",
846
+ "keyword": keywords,
847
+ "constant.language": buildinConstants
848
+ }, "identifier");
849
+
803
850
  this.$rules = new c_cppHighlightRules().$rules;
804
851
  this.$rules.start.forEach(function(rule) {
805
- if (typeof rule.token == "function")
806
- rule.token = function(value) {
807
- if (value == "this")
808
- return "variable.language";
809
- else if (keywords.hasOwnProperty(value))
810
- return "keyword";
811
- else if (buildinConstants.hasOwnProperty(value))
812
- return "constant.language";
813
- else
814
- return "identifier";
815
- };
852
+ if (typeof rule.token == "function")
853
+ rule.token = keywordMapper;
816
854
  })
817
855
  };
818
856