datagram 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/.env.sample +7 -0
  2. data/.gitignore +20 -0
  3. data/.rbenv-version +1 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +22 -0
  6. data/Procfile +1 -0
  7. data/README.md +29 -0
  8. data/Rakefile +1 -0
  9. data/config.ru +5 -0
  10. data/datagram.gemspec +23 -0
  11. data/db/migrate/1_create_queries.rb +9 -0
  12. data/db/migrate/2_add_name_to_queries.rb +5 -0
  13. data/lib/datagram/version.rb +3 -0
  14. data/lib/datagram.rb +135 -0
  15. data/lib/views/application.coffee +222 -0
  16. data/lib/views/index.haml +47 -0
  17. data/lib/views/layout.haml +17 -0
  18. data/lib/views/style.sass +179 -0
  19. data/public/ace/ace.js +15209 -0
  20. data/public/ace/ext-elastic_tabstops_lite.js +301 -0
  21. data/public/ace/ext-emmet.js +253 -0
  22. data/public/ace/ext-searchbox.js +441 -0
  23. data/public/ace/ext-spellcheck.js +67 -0
  24. data/public/ace/ext-static_highlight.js +96 -0
  25. data/public/ace/ext-textarea.js +492 -0
  26. data/public/ace/ext-whitespace.js +204 -0
  27. data/public/ace/keybinding-emacs.js +962 -0
  28. data/public/ace/keybinding-vim.js +1704 -0
  29. data/public/ace/mode-abap.js +260 -0
  30. data/public/ace/mode-asciidoc.js +372 -0
  31. data/public/ace/mode-c9search.js +182 -0
  32. data/public/ace/mode-c_cpp.js +737 -0
  33. data/public/ace/mode-clojure.js +299 -0
  34. data/public/ace/mode-coffee.js +426 -0
  35. data/public/ace/mode-coldfusion.js +1753 -0
  36. data/public/ace/mode-csharp.js +612 -0
  37. data/public/ace/mode-css.js +773 -0
  38. data/public/ace/mode-curly.js +1950 -0
  39. data/public/ace/mode-dart.js +945 -0
  40. data/public/ace/mode-diff.js +166 -0
  41. data/public/ace/mode-django.js +1969 -0
  42. data/public/ace/mode-dot.js +320 -0
  43. data/public/ace/mode-ftl.js +907 -0
  44. data/public/ace/mode-glsl.js +810 -0
  45. data/public/ace/mode-golang.js +632 -0
  46. data/public/ace/mode-groovy.js +1037 -0
  47. data/public/ace/mode-haml.js +487 -0
  48. data/public/ace/mode-haxe.js +609 -0
  49. data/public/ace/mode-html.js +1881 -0
  50. data/public/ace/mode-jade.js +1951 -0
  51. data/public/ace/mode-java.js +996 -0
  52. data/public/ace/mode-javascript.js +876 -0
  53. data/public/ace/mode-json.js +578 -0
  54. data/public/ace/mode-jsp.js +1351 -0
  55. data/public/ace/mode-jsx.js +635 -0
  56. data/public/ace/mode-latex.js +189 -0
  57. data/public/ace/mode-less.js +807 -0
  58. data/public/ace/mode-liquid.js +862 -0
  59. data/public/ace/mode-lisp.js +138 -0
  60. data/public/ace/mode-livescript.js +288 -0
  61. data/public/ace/mode-logiql.js +664 -0
  62. data/public/ace/mode-lsl.js +828 -0
  63. data/public/ace/mode-lua.js +455 -0
  64. data/public/ace/mode-luapage.js +2340 -0
  65. data/public/ace/mode-lucene.js +64 -0
  66. data/public/ace/mode-makefile.js +313 -0
  67. data/public/ace/mode-markdown.js +2280 -0
  68. data/public/ace/mode-mushcode.js +704 -0
  69. data/public/ace/mode-mushcode_high_rules.js +569 -0
  70. data/public/ace/mode-objectivec.js +659 -0
  71. data/public/ace/mode-ocaml.js +443 -0
  72. data/public/ace/mode-pascal.js +233 -0
  73. data/public/ace/mode-perl.js +316 -0
  74. data/public/ace/mode-pgsql.js +908 -0
  75. data/public/ace/mode-php.js +2291 -0
  76. data/public/ace/mode-powershell.js +618 -0
  77. data/public/ace/mode-python.js +264 -0
  78. data/public/ace/mode-r.js +404 -0
  79. data/public/ace/mode-rdoc.js +184 -0
  80. data/public/ace/mode-rhtml.js +2168 -0
  81. data/public/ace/mode-ruby.js +431 -0
  82. data/public/ace/mode-sass.js +442 -0
  83. data/public/ace/mode-scad.js +670 -0
  84. data/public/ace/mode-scala.js +1025 -0
  85. data/public/ace/mode-scheme.js +144 -0
  86. data/public/ace/mode-scss.js +832 -0
  87. data/public/ace/mode-sh.js +204 -0
  88. data/public/ace/mode-sql.js +118 -0
  89. data/public/ace/mode-stylus.js +483 -0
  90. data/public/ace/mode-svg.js +1442 -0
  91. data/public/ace/mode-tcl.js +319 -0
  92. data/public/ace/mode-tex.js +166 -0
  93. data/public/ace/mode-text.js +0 -0
  94. data/public/ace/mode-textile.js +170 -0
  95. data/public/ace/mode-tmsnippet.js +200 -0
  96. data/public/ace/mode-toml.js +180 -0
  97. data/public/ace/mode-typescript.js +961 -0
  98. data/public/ace/mode-vbscript.js +281 -0
  99. data/public/ace/mode-velocity.js +962 -0
  100. data/public/ace/mode-xml.js +789 -0
  101. data/public/ace/mode-xquery.js +2750 -0
  102. data/public/ace/mode-yaml.js +289 -0
  103. data/public/ace/theme-ambiance.js +202 -0
  104. data/public/ace/theme-chaos.js +182 -0
  105. data/public/ace/theme-chrome.js +161 -0
  106. data/public/ace/theme-clouds.js +135 -0
  107. data/public/ace/theme-clouds_midnight.js +136 -0
  108. data/public/ace/theme-cobalt.js +150 -0
  109. data/public/ace/theme-crimson_editor.js +154 -0
  110. data/public/ace/theme-dawn.js +146 -0
  111. data/public/ace/theme-dreamweaver.js +173 -0
  112. data/public/ace/theme-eclipse.js +122 -0
  113. data/public/ace/theme-github.js +136 -0
  114. data/public/ace/theme-idle_fingers.js +136 -0
  115. data/public/ace/theme-kr.js +143 -0
  116. data/public/ace/theme-merbivore.js +135 -0
  117. data/public/ace/theme-merbivore_soft.js +136 -0
  118. data/public/ace/theme-mono_industrial.js +148 -0
  119. data/public/ace/theme-monokai.js +140 -0
  120. data/public/ace/theme-pastel_on_dark.js +148 -0
  121. data/public/ace/theme-solarized_dark.js +128 -0
  122. data/public/ace/theme-solarized_light.js +131 -0
  123. data/public/ace/theme-terminal.js +154 -0
  124. data/public/ace/theme-textmate.js +0 -0
  125. data/public/ace/theme-tomorrow.js +147 -0
  126. data/public/ace/theme-tomorrow_night.js +147 -0
  127. data/public/ace/theme-tomorrow_night_blue.js +145 -0
  128. data/public/ace/theme-tomorrow_night_bright.js +147 -0
  129. data/public/ace/theme-tomorrow_night_eighties.js +144 -0
  130. data/public/ace/theme-twilight.js +147 -0
  131. data/public/ace/theme-vibrant_ink.js +131 -0
  132. data/public/ace/theme-xcode.js +125 -0
  133. data/public/ace/worker-coffee.js +7091 -0
  134. data/public/ace/worker-css.js +8289 -0
  135. data/public/ace/worker-javascript.js +6496 -0
  136. data/public/ace/worker-json.js +2305 -0
  137. data/public/ace/worker-lua.js +3313 -0
  138. data/public/ace/worker-php.js +6743 -0
  139. data/public/ace/worker-xquery.js +21897 -0
  140. data/public/font/FontAwesome.otf +0 -0
  141. data/public/font/fontawesome-webfont.eot +0 -0
  142. data/public/font/fontawesome-webfont.svg +284 -0
  143. data/public/font/fontawesome-webfont.ttf +0 -0
  144. data/public/font/fontawesome-webfont.woff +0 -0
  145. data/public/font-awesome.css +540 -0
  146. data/public/jquery.js +9597 -0
  147. data/script/migrate.sh +2 -0
  148. metadata +242 -0
@@ -0,0 +1,1969 @@
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Distributed under the BSD license:
3
+ *
4
+ * Copyright (c) 2012, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *
29
+ * ***** END LICENSE BLOCK ***** */
30
+
31
+ define('ace/mode/django', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
32
+
33
+ var oop = require("../lib/oop");
34
+ var HtmlMode = require("./html").Mode;
35
+ var Tokenizer = require("../tokenizer").Tokenizer;
36
+ var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
37
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
38
+
39
+ var DjangoHighlightRules = function(){
40
+ this.$rules = {
41
+ 'start': [{
42
+ token: "string",
43
+ regex: '".*?"'
44
+ }, {
45
+ token: "string",
46
+ regex: "'.*?'"
47
+ }, {
48
+ token: "constant",
49
+ regex: '[0-9]+'
50
+ }, {
51
+ token: "variable",
52
+ regex: "[-_a-zA-Z0-9:]+"
53
+ }],
54
+ 'comment': [{
55
+ token : "comment.block",
56
+ merge: true,
57
+ regex : ".+?"
58
+ }],
59
+ 'tag': [{
60
+ token: "entity.name.function",
61
+ regex: "[a-zA-Z][_a-zA-Z0-9]*",
62
+ next: "start"
63
+ }]
64
+ };
65
+ };
66
+
67
+ oop.inherits(DjangoHighlightRules, TextHighlightRules)
68
+
69
+ var DjangoHtmlHighlightRules = function() {
70
+ this.$rules = new HtmlHighlightRules().getRules();
71
+
72
+ for (var i in this.$rules) {
73
+ this.$rules[i].unshift({
74
+ token: "comment.line",
75
+ regex: "\\{#.*?#\\}"
76
+ }, {
77
+ token: "comment.block",
78
+ regex: "\\{\\%\\s*comment\\s*\\%\\}",
79
+ merge: true,
80
+ next: "django-comment"
81
+ }, {
82
+ token: "constant.language",
83
+ regex: "\\{\\{",
84
+ next: "django-start"
85
+ }, {
86
+ token: "constant.language",
87
+ regex: "\\{\\%",
88
+ next: "django-tag"
89
+ });
90
+ this.embedRules(DjangoHighlightRules, "django-", [{
91
+ token: "comment.block",
92
+ regex: "\\{\\%\\s*endcomment\\s*\\%\\}",
93
+ merge: true,
94
+ next: "start"
95
+ }, {
96
+ token: "constant.language",
97
+ regex: "\\%\\}",
98
+ next: "start"
99
+ }, {
100
+ token: "constant.language",
101
+ regex: "\\}\\}",
102
+ next: "start"
103
+ }]);
104
+ }
105
+ };
106
+
107
+ oop.inherits(DjangoHtmlHighlightRules, HtmlHighlightRules);
108
+
109
+ var Mode = function() {
110
+ var highlighter = new DjangoHtmlHighlightRules();
111
+ this.$tokenizer = new Tokenizer(highlighter.getRules());
112
+ this.$embeds = highlighter.getEmbeds();
113
+ };
114
+ oop.inherits(Mode, HtmlMode);
115
+
116
+ exports.Mode = Mode;
117
+ });
118
+
119
+ define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/html', 'ace/mode/folding/html'], function(require, exports, module) {
120
+
121
+
122
+ var oop = require("../lib/oop");
123
+ var TextMode = require("./text").Mode;
124
+ var JavaScriptMode = require("./javascript").Mode;
125
+ var CssMode = require("./css").Mode;
126
+ var Tokenizer = require("../tokenizer").Tokenizer;
127
+ var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
128
+ var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
129
+ var HtmlFoldMode = require("./folding/html").FoldMode;
130
+
131
+ var Mode = function() {
132
+ var highlighter = new HtmlHighlightRules();
133
+ this.$tokenizer = new Tokenizer(highlighter.getRules());
134
+ this.$behaviour = new HtmlBehaviour();
135
+
136
+ this.$embeds = highlighter.getEmbeds();
137
+ this.createModeDelegates({
138
+ "js-": JavaScriptMode,
139
+ "css-": CssMode
140
+ });
141
+
142
+ this.foldingRules = new HtmlFoldMode();
143
+ };
144
+ oop.inherits(Mode, TextMode);
145
+
146
+ (function() {
147
+
148
+ this.blockComment = {start: "<!--", end: "-->"};
149
+
150
+ this.getNextLineIndent = function(state, line, tab) {
151
+ return this.$getIndent(line);
152
+ };
153
+
154
+ this.checkOutdent = function(state, line, input) {
155
+ return false;
156
+ };
157
+
158
+ }).call(Mode.prototype);
159
+
160
+ exports.Mode = Mode;
161
+ });
162
+
163
+ define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
164
+
165
+
166
+ var oop = require("../lib/oop");
167
+ var TextMode = require("./text").Mode;
168
+ var Tokenizer = require("../tokenizer").Tokenizer;
169
+ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
170
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
171
+ var Range = require("../range").Range;
172
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
173
+ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
174
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
175
+
176
+ var Mode = function() {
177
+ this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
178
+ this.$outdent = new MatchingBraceOutdent();
179
+ this.$behaviour = new CstyleBehaviour();
180
+ this.foldingRules = new CStyleFoldMode();
181
+ };
182
+ oop.inherits(Mode, TextMode);
183
+
184
+ (function() {
185
+
186
+ this.lineCommentStart = "//";
187
+ this.blockComment = {start: "/*", end: "*/"};
188
+
189
+ this.getNextLineIndent = function(state, line, tab) {
190
+ var indent = this.$getIndent(line);
191
+
192
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
193
+ var tokens = tokenizedLine.tokens;
194
+ var endState = tokenizedLine.state;
195
+
196
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
197
+ return indent;
198
+ }
199
+
200
+ if (state == "start" || state == "no_regex") {
201
+ var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
202
+ if (match) {
203
+ indent += tab;
204
+ }
205
+ } else if (state == "doc-start") {
206
+ if (endState == "start" || endState == "no_regex") {
207
+ return "";
208
+ }
209
+ var match = line.match(/^\s*(\/?)\*/);
210
+ if (match) {
211
+ if (match[1]) {
212
+ indent += " ";
213
+ }
214
+ indent += "* ";
215
+ }
216
+ }
217
+
218
+ return indent;
219
+ };
220
+
221
+ this.checkOutdent = function(state, line, input) {
222
+ return this.$outdent.checkOutdent(line, input);
223
+ };
224
+
225
+ this.autoOutdent = function(state, doc, row) {
226
+ this.$outdent.autoOutdent(doc, row);
227
+ };
228
+
229
+ this.createWorker = function(session) {
230
+ var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
231
+ worker.attachToDocument(session.getDocument());
232
+
233
+ worker.on("jslint", function(results) {
234
+ session.setAnnotations(results.data);
235
+ });
236
+
237
+ worker.on("terminate", function() {
238
+ session.clearAnnotations();
239
+ });
240
+
241
+ return worker;
242
+ };
243
+
244
+ }).call(Mode.prototype);
245
+
246
+ exports.Mode = Mode;
247
+ });
248
+
249
+ define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
250
+
251
+
252
+ var oop = require("../lib/oop");
253
+ var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
254
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
255
+
256
+ var JavaScriptHighlightRules = function() {
257
+ var keywordMapper = this.createKeywordMapper({
258
+ "variable.language":
259
+ "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
260
+ "Namespace|QName|XML|XMLList|" + // E4X
261
+ "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
262
+ "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
263
+ "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
264
+ "SyntaxError|TypeError|URIError|" +
265
+ "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
266
+ "isNaN|parseFloat|parseInt|" +
267
+ "JSON|Math|" + // Other
268
+ "this|arguments|prototype|window|document" , // Pseudo
269
+ "keyword":
270
+ "const|yield|import|get|set|" +
271
+ "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
272
+ "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
273
+ "__parent__|__count__|escape|unescape|with|__proto__|" +
274
+ "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
275
+ "storage.type":
276
+ "const|let|var|function",
277
+ "constant.language":
278
+ "null|Infinity|NaN|undefined",
279
+ "support.function":
280
+ "alert",
281
+ "constant.language.boolean": "true|false"
282
+ }, "identifier");
283
+ var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
284
+ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
285
+
286
+ var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
287
+ "u[0-9a-fA-F]{4}|" + // unicode
288
+ "[0-2][0-7]{0,2}|" + // oct
289
+ "3[0-6][0-7]?|" + // oct
290
+ "37[0-7]?|" + // oct
291
+ "[4-7][0-7]?|" + //oct
292
+ ".)";
293
+
294
+ this.$rules = {
295
+ "no_regex" : [
296
+ {
297
+ token : "comment",
298
+ regex : /\/\/.*$/
299
+ },
300
+ DocCommentHighlightRules.getStartRule("doc-start"),
301
+ {
302
+ token : "comment", // multi line comment
303
+ regex : /\/\*/,
304
+ next : "comment"
305
+ }, {
306
+ token : "string",
307
+ regex : "'(?=.)",
308
+ next : "qstring"
309
+ }, {
310
+ token : "string",
311
+ regex : '"(?=.)',
312
+ next : "qqstring"
313
+ }, {
314
+ token : "constant.numeric", // hex
315
+ regex : /0[xX][0-9a-fA-F]+\b/
316
+ }, {
317
+ token : "constant.numeric", // float
318
+ regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
319
+ }, {
320
+ token : [
321
+ "storage.type", "punctuation.operator", "support.function",
322
+ "punctuation.operator", "entity.name.function", "text","keyword.operator"
323
+ ],
324
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
325
+ next: "function_arguments"
326
+ }, {
327
+ token : [
328
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
329
+ "keyword.operator", "text", "storage.type", "text", "paren.lparen"
330
+ ],
331
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
332
+ next: "function_arguments"
333
+ }, {
334
+ token : [
335
+ "entity.name.function", "text", "keyword.operator", "text", "storage.type",
336
+ "text", "paren.lparen"
337
+ ],
338
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
339
+ next: "function_arguments"
340
+ }, {
341
+ token : [
342
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
343
+ "keyword.operator", "text",
344
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
345
+ ],
346
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
347
+ next: "function_arguments"
348
+ }, {
349
+ token : [
350
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
351
+ ],
352
+ regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
353
+ next: "function_arguments"
354
+ }, {
355
+ token : [
356
+ "entity.name.function", "text", "punctuation.operator",
357
+ "text", "storage.type", "text", "paren.lparen"
358
+ ],
359
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
360
+ next: "function_arguments"
361
+ }, {
362
+ token : [
363
+ "text", "text", "storage.type", "text", "paren.lparen"
364
+ ],
365
+ regex : "(:)(\\s*)(function)(\\s*)(\\()",
366
+ next: "function_arguments"
367
+ }, {
368
+ token : "keyword",
369
+ regex : "(?:" + kwBeforeRe + ")\\b",
370
+ next : "start"
371
+ }, {
372
+ token : ["punctuation.operator", "support.function"],
373
+ regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
374
+ }, {
375
+ token : ["punctuation.operator", "support.function.dom"],
376
+ regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
377
+ }, {
378
+ token : ["punctuation.operator", "support.constant"],
379
+ regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
380
+ }, {
381
+ token : ["storage.type", "punctuation.operator", "support.function.firebug"],
382
+ regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
383
+ }, {
384
+ token : keywordMapper,
385
+ regex : identifierRe
386
+ }, {
387
+ token : "keyword.operator",
388
+ regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
389
+ next : "start"
390
+ }, {
391
+ token : "punctuation.operator",
392
+ regex : /\?|\:|\,|\;|\./,
393
+ next : "start"
394
+ }, {
395
+ token : "paren.lparen",
396
+ regex : /[\[({]/,
397
+ next : "start"
398
+ }, {
399
+ token : "paren.rparen",
400
+ regex : /[\])}]/
401
+ }, {
402
+ token : "keyword.operator",
403
+ regex : /\/=?/,
404
+ next : "start"
405
+ }, {
406
+ token: "comment",
407
+ regex: /^#!.*$/
408
+ }
409
+ ],
410
+ "start": [
411
+ DocCommentHighlightRules.getStartRule("doc-start"),
412
+ {
413
+ token : "comment", // multi line comment
414
+ regex : "\\/\\*",
415
+ next : "comment_regex_allowed"
416
+ }, {
417
+ token : "comment",
418
+ regex : "\\/\\/.*$",
419
+ next : "start"
420
+ }, {
421
+ token: "string.regexp",
422
+ regex: "\\/",
423
+ next: "regex"
424
+ }, {
425
+ token : "text",
426
+ regex : "\\s+|^$",
427
+ next : "start"
428
+ }, {
429
+ token: "empty",
430
+ regex: "",
431
+ next: "no_regex"
432
+ }
433
+ ],
434
+ "regex": [
435
+ {
436
+ token: "regexp.keyword.operator",
437
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
438
+ }, {
439
+ token: "string.regexp",
440
+ regex: "/\\w*",
441
+ next: "no_regex"
442
+ }, {
443
+ token : "invalid",
444
+ regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
445
+ }, {
446
+ token : "constant.language.escape",
447
+ regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
448
+ }, {
449
+ token : "constant.language.delimiter",
450
+ regex: /\|/
451
+ }, {
452
+ token: "constant.language.escape",
453
+ regex: /\[\^?/,
454
+ next: "regex_character_class"
455
+ }, {
456
+ token: "empty",
457
+ regex: "$",
458
+ next: "no_regex"
459
+ }, {
460
+ defaultToken: "string.regexp"
461
+ }
462
+ ],
463
+ "regex_character_class": [
464
+ {
465
+ token: "regexp.keyword.operator",
466
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
467
+ }, {
468
+ token: "constant.language.escape",
469
+ regex: "]",
470
+ next: "regex"
471
+ }, {
472
+ token: "constant.language.escape",
473
+ regex: "-"
474
+ }, {
475
+ token: "empty",
476
+ regex: "$",
477
+ next: "no_regex"
478
+ }, {
479
+ defaultToken: "string.regexp.charachterclass"
480
+ }
481
+ ],
482
+ "function_arguments": [
483
+ {
484
+ token: "variable.parameter",
485
+ regex: identifierRe
486
+ }, {
487
+ token: "punctuation.operator",
488
+ regex: "[, ]+"
489
+ }, {
490
+ token: "punctuation.operator",
491
+ regex: "$"
492
+ }, {
493
+ token: "empty",
494
+ regex: "",
495
+ next: "no_regex"
496
+ }
497
+ ],
498
+ "comment_regex_allowed" : [
499
+ {token : "comment", regex : "\\*\\/", next : "start"},
500
+ {defaultToken : "comment"}
501
+ ],
502
+ "comment" : [
503
+ {token : "comment", regex : "\\*\\/", next : "no_regex"},
504
+ {defaultToken : "comment"}
505
+ ],
506
+ "qqstring" : [
507
+ {
508
+ token : "constant.language.escape",
509
+ regex : escapedRe
510
+ }, {
511
+ token : "string",
512
+ regex : "\\\\$",
513
+ next : "qqstring"
514
+ }, {
515
+ token : "string",
516
+ regex : '"|$',
517
+ next : "no_regex"
518
+ }, {
519
+ defaultToken: "string"
520
+ }
521
+ ],
522
+ "qstring" : [
523
+ {
524
+ token : "constant.language.escape",
525
+ regex : escapedRe
526
+ }, {
527
+ token : "string",
528
+ regex : "\\\\$",
529
+ next : "qstring"
530
+ }, {
531
+ token : "string",
532
+ regex : "'|$",
533
+ next : "no_regex"
534
+ }, {
535
+ defaultToken: "string"
536
+ }
537
+ ]
538
+ };
539
+
540
+ this.embedRules(DocCommentHighlightRules, "doc-",
541
+ [ DocCommentHighlightRules.getEndRule("no_regex") ]);
542
+ };
543
+
544
+ oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
545
+
546
+ exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
547
+ });
548
+
549
+ define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
550
+
551
+
552
+ var oop = require("../lib/oop");
553
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
554
+
555
+ var DocCommentHighlightRules = function() {
556
+
557
+ this.$rules = {
558
+ "start" : [ {
559
+ token : "comment.doc.tag",
560
+ regex : "@[\\w\\d_]+" // TODO: fix email addresses
561
+ }, {
562
+ token : "comment.doc.tag",
563
+ regex : "\\bTODO\\b"
564
+ }, {
565
+ defaultToken : "comment.doc"
566
+ }]
567
+ };
568
+ };
569
+
570
+ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
571
+
572
+ DocCommentHighlightRules.getStartRule = function(start) {
573
+ return {
574
+ token : "comment.doc", // doc comment
575
+ regex : "\\/\\*(?=\\*)",
576
+ next : start
577
+ };
578
+ };
579
+
580
+ DocCommentHighlightRules.getEndRule = function (start) {
581
+ return {
582
+ token : "comment.doc", // closing comment
583
+ regex : "\\*\\/",
584
+ next : start
585
+ };
586
+ };
587
+
588
+
589
+ exports.DocCommentHighlightRules = DocCommentHighlightRules;
590
+
591
+ });
592
+
593
+ define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
594
+
595
+
596
+ var Range = require("../range").Range;
597
+
598
+ var MatchingBraceOutdent = function() {};
599
+
600
+ (function() {
601
+
602
+ this.checkOutdent = function(line, input) {
603
+ if (! /^\s+$/.test(line))
604
+ return false;
605
+
606
+ return /^\s*\}/.test(input);
607
+ };
608
+
609
+ this.autoOutdent = function(doc, row) {
610
+ var line = doc.getLine(row);
611
+ var match = line.match(/^(\s*\})/);
612
+
613
+ if (!match) return 0;
614
+
615
+ var column = match[1].length;
616
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
617
+
618
+ if (!openBracePos || openBracePos.row == row) return 0;
619
+
620
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
621
+ doc.replace(new Range(row, 0, row, column-1), indent);
622
+ };
623
+
624
+ this.$getIndent = function(line) {
625
+ return line.match(/^\s*/)[0];
626
+ };
627
+
628
+ }).call(MatchingBraceOutdent.prototype);
629
+
630
+ exports.MatchingBraceOutdent = MatchingBraceOutdent;
631
+ });
632
+
633
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
634
+
635
+
636
+ var oop = require("../../lib/oop");
637
+ var Behaviour = require("../behaviour").Behaviour;
638
+ var TokenIterator = require("../../token_iterator").TokenIterator;
639
+ var lang = require("../../lib/lang");
640
+
641
+ var SAFE_INSERT_IN_TOKENS =
642
+ ["text", "paren.rparen", "punctuation.operator"];
643
+ var SAFE_INSERT_BEFORE_TOKENS =
644
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
645
+
646
+
647
+ var autoInsertedBrackets = 0;
648
+ var autoInsertedRow = -1;
649
+ var autoInsertedLineEnd = "";
650
+ var maybeInsertedBrackets = 0;
651
+ var maybeInsertedRow = -1;
652
+ var maybeInsertedLineStart = "";
653
+ var maybeInsertedLineEnd = "";
654
+
655
+ var CstyleBehaviour = function () {
656
+
657
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
658
+ var cursor = editor.getCursorPosition();
659
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
660
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
661
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
662
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
663
+ return false;
664
+ }
665
+ iterator.stepForward();
666
+ return iterator.getCurrentTokenRow() !== cursor.row ||
667
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
668
+ };
669
+
670
+ CstyleBehaviour.$matchTokenType = function(token, types) {
671
+ return types.indexOf(token.type || token) > -1;
672
+ };
673
+
674
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
675
+ var cursor = editor.getCursorPosition();
676
+ var line = session.doc.getLine(cursor.row);
677
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
678
+ autoInsertedBrackets = 0;
679
+ autoInsertedRow = cursor.row;
680
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
681
+ autoInsertedBrackets++;
682
+ };
683
+
684
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
685
+ var cursor = editor.getCursorPosition();
686
+ var line = session.doc.getLine(cursor.row);
687
+ if (!this.isMaybeInsertedClosing(cursor, line))
688
+ maybeInsertedBrackets = 0;
689
+ maybeInsertedRow = cursor.row;
690
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
691
+ maybeInsertedLineEnd = line.substr(cursor.column);
692
+ maybeInsertedBrackets++;
693
+ };
694
+
695
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
696
+ return autoInsertedBrackets > 0 &&
697
+ cursor.row === autoInsertedRow &&
698
+ bracket === autoInsertedLineEnd[0] &&
699
+ line.substr(cursor.column) === autoInsertedLineEnd;
700
+ };
701
+
702
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
703
+ return maybeInsertedBrackets > 0 &&
704
+ cursor.row === maybeInsertedRow &&
705
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
706
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
707
+ };
708
+
709
+ CstyleBehaviour.popAutoInsertedClosing = function() {
710
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
711
+ autoInsertedBrackets--;
712
+ };
713
+
714
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
715
+ maybeInsertedBrackets = 0;
716
+ maybeInsertedRow = -1;
717
+ };
718
+
719
+ this.add("braces", "insertion", function (state, action, editor, session, text) {
720
+ var cursor = editor.getCursorPosition();
721
+ var line = session.doc.getLine(cursor.row);
722
+ if (text == '{') {
723
+ var selection = editor.getSelectionRange();
724
+ var selected = session.doc.getTextRange(selection);
725
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
726
+ return {
727
+ text: '{' + selected + '}',
728
+ selection: false
729
+ };
730
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
731
+ if (/[\]\}\)]/.test(line[cursor.column])) {
732
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
733
+ return {
734
+ text: '{}',
735
+ selection: [1, 1]
736
+ };
737
+ } else {
738
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
739
+ return {
740
+ text: '{',
741
+ selection: [1, 1]
742
+ };
743
+ }
744
+ }
745
+ } else if (text == '}') {
746
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
747
+ if (rightChar == '}') {
748
+ var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
749
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
750
+ CstyleBehaviour.popAutoInsertedClosing();
751
+ return {
752
+ text: '',
753
+ selection: [1, 1]
754
+ };
755
+ }
756
+ }
757
+ } else if (text == "\n" || text == "\r\n") {
758
+ var closing = "";
759
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
760
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
761
+ CstyleBehaviour.clearMaybeInsertedClosing();
762
+ }
763
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
764
+ if (rightChar == '}' || closing !== "") {
765
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
766
+ if (!openBracePos)
767
+ return null;
768
+
769
+ var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
770
+ var next_indent = this.$getIndent(line);
771
+
772
+ return {
773
+ text: '\n' + indent + '\n' + next_indent + closing,
774
+ selection: [1, indent.length, 1, indent.length]
775
+ };
776
+ }
777
+ }
778
+ });
779
+
780
+ this.add("braces", "deletion", function (state, action, editor, session, range) {
781
+ var selected = session.doc.getTextRange(range);
782
+ if (!range.isMultiLine() && selected == '{') {
783
+ var line = session.doc.getLine(range.start.row);
784
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
785
+ if (rightChar == '}') {
786
+ range.end.column++;
787
+ return range;
788
+ } else {
789
+ maybeInsertedBrackets--;
790
+ }
791
+ }
792
+ });
793
+
794
+ this.add("parens", "insertion", function (state, action, editor, session, text) {
795
+ if (text == '(') {
796
+ var selection = editor.getSelectionRange();
797
+ var selected = session.doc.getTextRange(selection);
798
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
799
+ return {
800
+ text: '(' + selected + ')',
801
+ selection: false
802
+ };
803
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
804
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
805
+ return {
806
+ text: '()',
807
+ selection: [1, 1]
808
+ };
809
+ }
810
+ } else if (text == ')') {
811
+ var cursor = editor.getCursorPosition();
812
+ var line = session.doc.getLine(cursor.row);
813
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
814
+ if (rightChar == ')') {
815
+ var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
816
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
817
+ CstyleBehaviour.popAutoInsertedClosing();
818
+ return {
819
+ text: '',
820
+ selection: [1, 1]
821
+ };
822
+ }
823
+ }
824
+ }
825
+ });
826
+
827
+ this.add("parens", "deletion", function (state, action, editor, session, range) {
828
+ var selected = session.doc.getTextRange(range);
829
+ if (!range.isMultiLine() && selected == '(') {
830
+ var line = session.doc.getLine(range.start.row);
831
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
832
+ if (rightChar == ')') {
833
+ range.end.column++;
834
+ return range;
835
+ }
836
+ }
837
+ });
838
+
839
+ this.add("brackets", "insertion", function (state, action, editor, session, text) {
840
+ if (text == '[') {
841
+ var selection = editor.getSelectionRange();
842
+ var selected = session.doc.getTextRange(selection);
843
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
844
+ return {
845
+ text: '[' + selected + ']',
846
+ selection: false
847
+ };
848
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
849
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
850
+ return {
851
+ text: '[]',
852
+ selection: [1, 1]
853
+ };
854
+ }
855
+ } else if (text == ']') {
856
+ var cursor = editor.getCursorPosition();
857
+ var line = session.doc.getLine(cursor.row);
858
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
859
+ if (rightChar == ']') {
860
+ var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
861
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
862
+ CstyleBehaviour.popAutoInsertedClosing();
863
+ return {
864
+ text: '',
865
+ selection: [1, 1]
866
+ };
867
+ }
868
+ }
869
+ }
870
+ });
871
+
872
+ this.add("brackets", "deletion", function (state, action, editor, session, range) {
873
+ var selected = session.doc.getTextRange(range);
874
+ if (!range.isMultiLine() && selected == '[') {
875
+ var line = session.doc.getLine(range.start.row);
876
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
877
+ if (rightChar == ']') {
878
+ range.end.column++;
879
+ return range;
880
+ }
881
+ }
882
+ });
883
+
884
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
885
+ if (text == '"' || text == "'") {
886
+ var quote = text;
887
+ var selection = editor.getSelectionRange();
888
+ var selected = session.doc.getTextRange(selection);
889
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
890
+ return {
891
+ text: quote + selected + quote,
892
+ selection: false
893
+ };
894
+ } else {
895
+ var cursor = editor.getCursorPosition();
896
+ var line = session.doc.getLine(cursor.row);
897
+ var leftChar = line.substring(cursor.column-1, cursor.column);
898
+ if (leftChar == '\\') {
899
+ return null;
900
+ }
901
+ var tokens = session.getTokens(selection.start.row);
902
+ var col = 0, token;
903
+ var quotepos = -1; // Track whether we're inside an open quote.
904
+
905
+ for (var x = 0; x < tokens.length; x++) {
906
+ token = tokens[x];
907
+ if (token.type == "string") {
908
+ quotepos = -1;
909
+ } else if (quotepos < 0) {
910
+ quotepos = token.value.indexOf(quote);
911
+ }
912
+ if ((token.value.length + col) > selection.start.column) {
913
+ break;
914
+ }
915
+ col += tokens[x].value.length;
916
+ }
917
+ 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)))) {
918
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
919
+ return;
920
+ return {
921
+ text: quote + quote,
922
+ selection: [1,1]
923
+ };
924
+ } else if (token && token.type === "string") {
925
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
926
+ if (rightChar == quote) {
927
+ return {
928
+ text: '',
929
+ selection: [1, 1]
930
+ };
931
+ }
932
+ }
933
+ }
934
+ }
935
+ });
936
+
937
+ this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
938
+ var selected = session.doc.getTextRange(range);
939
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
940
+ var line = session.doc.getLine(range.start.row);
941
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
942
+ if (rightChar == selected) {
943
+ range.end.column++;
944
+ return range;
945
+ }
946
+ }
947
+ });
948
+
949
+ };
950
+
951
+ oop.inherits(CstyleBehaviour, Behaviour);
952
+
953
+ exports.CstyleBehaviour = CstyleBehaviour;
954
+ });
955
+
956
+ define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
957
+
958
+
959
+ var oop = require("../../lib/oop");
960
+ var Range = require("../../range").Range;
961
+ var BaseFoldMode = require("./fold_mode").FoldMode;
962
+
963
+ var FoldMode = exports.FoldMode = function(commentRegex) {
964
+ if (commentRegex) {
965
+ this.foldingStartMarker = new RegExp(
966
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
967
+ );
968
+ this.foldingStopMarker = new RegExp(
969
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
970
+ );
971
+ }
972
+ };
973
+ oop.inherits(FoldMode, BaseFoldMode);
974
+
975
+ (function() {
976
+
977
+ this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
978
+ this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
979
+
980
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
981
+ var line = session.getLine(row);
982
+ var match = line.match(this.foldingStartMarker);
983
+ if (match) {
984
+ var i = match.index;
985
+
986
+ if (match[1])
987
+ return this.openingBracketBlock(session, match[1], row, i);
988
+
989
+ return session.getCommentFoldRange(row, i + match[0].length, 1);
990
+ }
991
+
992
+ if (foldStyle !== "markbeginend")
993
+ return;
994
+
995
+ var match = line.match(this.foldingStopMarker);
996
+ if (match) {
997
+ var i = match.index + match[0].length;
998
+
999
+ if (match[1])
1000
+ return this.closingBracketBlock(session, match[1], row, i);
1001
+
1002
+ return session.getCommentFoldRange(row, i, -1);
1003
+ }
1004
+ };
1005
+
1006
+ }).call(FoldMode.prototype);
1007
+
1008
+ });
1009
+
1010
+ define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/behaviour/css', 'ace/mode/folding/cstyle'], function(require, exports, module) {
1011
+
1012
+
1013
+ var oop = require("../lib/oop");
1014
+ var TextMode = require("./text").Mode;
1015
+ var Tokenizer = require("../tokenizer").Tokenizer;
1016
+ var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1017
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1018
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
1019
+ var CssBehaviour = require("./behaviour/css").CssBehaviour;
1020
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1021
+
1022
+ var Mode = function() {
1023
+ this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
1024
+ this.$outdent = new MatchingBraceOutdent();
1025
+ this.$behaviour = new CssBehaviour();
1026
+ this.foldingRules = new CStyleFoldMode();
1027
+ };
1028
+ oop.inherits(Mode, TextMode);
1029
+
1030
+ (function() {
1031
+
1032
+ this.foldingRules = "cStyle";
1033
+ this.blockComment = {start: "/*", end: "*/"};
1034
+
1035
+ this.getNextLineIndent = function(state, line, tab) {
1036
+ var indent = this.$getIndent(line);
1037
+ var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
1038
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
1039
+ return indent;
1040
+ }
1041
+
1042
+ var match = line.match(/^.*\{\s*$/);
1043
+ if (match) {
1044
+ indent += tab;
1045
+ }
1046
+
1047
+ return indent;
1048
+ };
1049
+
1050
+ this.checkOutdent = function(state, line, input) {
1051
+ return this.$outdent.checkOutdent(line, input);
1052
+ };
1053
+
1054
+ this.autoOutdent = function(state, doc, row) {
1055
+ this.$outdent.autoOutdent(doc, row);
1056
+ };
1057
+
1058
+ this.createWorker = function(session) {
1059
+ var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
1060
+ worker.attachToDocument(session.getDocument());
1061
+
1062
+ worker.on("csslint", function(e) {
1063
+ session.setAnnotations(e.data);
1064
+ });
1065
+
1066
+ worker.on("terminate", function() {
1067
+ session.clearAnnotations();
1068
+ });
1069
+
1070
+ return worker;
1071
+ };
1072
+
1073
+ }).call(Mode.prototype);
1074
+
1075
+ exports.Mode = Mode;
1076
+
1077
+ });
1078
+
1079
+ define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1080
+
1081
+
1082
+ var oop = require("../lib/oop");
1083
+ var lang = require("../lib/lang");
1084
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1085
+ var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index";
1086
+ var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
1087
+ var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
1088
+ var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
1089
+ var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
1090
+
1091
+ var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
1092
+ var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
1093
+ var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
1094
+
1095
+ var CssHighlightRules = function() {
1096
+
1097
+ var keywordMapper = this.createKeywordMapper({
1098
+ "support.function": supportFunction,
1099
+ "support.constant": supportConstant,
1100
+ "support.type": supportType,
1101
+ "support.constant.color": supportConstantColor,
1102
+ "support.constant.fonts": supportConstantFonts
1103
+ }, "text", true);
1104
+
1105
+ var base_ruleset = [
1106
+ {
1107
+ token : "comment", // multi line comment
1108
+ regex : "\\/\\*",
1109
+ next : "ruleset_comment"
1110
+ }, {
1111
+ token : "string", // single line
1112
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
1113
+ }, {
1114
+ token : "string", // single line
1115
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
1116
+ }, {
1117
+ token : ["constant.numeric", "keyword"],
1118
+ regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
1119
+ }, {
1120
+ token : "constant.numeric",
1121
+ regex : numRe
1122
+ }, {
1123
+ token : "constant.numeric", // hex6 color
1124
+ regex : "#[a-f0-9]{6}"
1125
+ }, {
1126
+ token : "constant.numeric", // hex3 color
1127
+ regex : "#[a-f0-9]{3}"
1128
+ }, {
1129
+ token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
1130
+ regex : pseudoElements
1131
+ }, {
1132
+ token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
1133
+ regex : pseudoClasses
1134
+ }, {
1135
+ token : ["support.function", "string", "support.function"],
1136
+ regex : "(url\\()(.*)(\\))"
1137
+ }, {
1138
+ token : keywordMapper,
1139
+ regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
1140
+ }, {
1141
+ caseInsensitive: true
1142
+ }
1143
+ ];
1144
+
1145
+ var ruleset = lang.copyArray(base_ruleset);
1146
+ ruleset.unshift({
1147
+ token : "paren.rparen",
1148
+ regex : "\\}",
1149
+ next: "start"
1150
+ });
1151
+
1152
+ var media_ruleset = lang.copyArray( base_ruleset );
1153
+ media_ruleset.unshift({
1154
+ token : "paren.rparen",
1155
+ regex : "\\}",
1156
+ next: "media"
1157
+ });
1158
+
1159
+ var base_comment = [{
1160
+ token : "comment", // comment spanning whole line
1161
+ regex : ".+"
1162
+ }];
1163
+
1164
+ var comment = lang.copyArray(base_comment);
1165
+ comment.unshift({
1166
+ token : "comment", // closing comment
1167
+ regex : ".*?\\*\\/",
1168
+ next : "start"
1169
+ });
1170
+
1171
+ var media_comment = lang.copyArray(base_comment);
1172
+ media_comment.unshift({
1173
+ token : "comment", // closing comment
1174
+ regex : ".*?\\*\\/",
1175
+ next : "media"
1176
+ });
1177
+
1178
+ var ruleset_comment = lang.copyArray(base_comment);
1179
+ ruleset_comment.unshift({
1180
+ token : "comment", // closing comment
1181
+ regex : ".*?\\*\\/",
1182
+ next : "ruleset"
1183
+ });
1184
+
1185
+ this.$rules = {
1186
+ "start" : [{
1187
+ token : "comment", // multi line comment
1188
+ regex : "\\/\\*",
1189
+ next : "comment"
1190
+ }, {
1191
+ token: "paren.lparen",
1192
+ regex: "\\{",
1193
+ next: "ruleset"
1194
+ }, {
1195
+ token: "string",
1196
+ regex: "@.*?{",
1197
+ next: "media"
1198
+ },{
1199
+ token: "keyword",
1200
+ regex: "#[a-z0-9-_]+"
1201
+ },{
1202
+ token: "variable",
1203
+ regex: "\\.[a-z0-9-_]+"
1204
+ },{
1205
+ token: "string",
1206
+ regex: ":[a-z0-9-_]+"
1207
+ },{
1208
+ token: "constant",
1209
+ regex: "[a-z0-9-_]+"
1210
+ },{
1211
+ caseInsensitive: true
1212
+ }],
1213
+
1214
+ "media" : [ {
1215
+ token : "comment", // multi line comment
1216
+ regex : "\\/\\*",
1217
+ next : "media_comment"
1218
+ }, {
1219
+ token: "paren.lparen",
1220
+ regex: "\\{",
1221
+ next: "media_ruleset"
1222
+ },{
1223
+ token: "string",
1224
+ regex: "\\}",
1225
+ next: "start"
1226
+ },{
1227
+ token: "keyword",
1228
+ regex: "#[a-z0-9-_]+"
1229
+ },{
1230
+ token: "variable",
1231
+ regex: "\\.[a-z0-9-_]+"
1232
+ },{
1233
+ token: "string",
1234
+ regex: ":[a-z0-9-_]+"
1235
+ },{
1236
+ token: "constant",
1237
+ regex: "[a-z0-9-_]+"
1238
+ },{
1239
+ caseInsensitive: true
1240
+ }],
1241
+
1242
+ "comment" : comment,
1243
+
1244
+ "ruleset" : ruleset,
1245
+ "ruleset_comment" : ruleset_comment,
1246
+
1247
+ "media_ruleset" : media_ruleset,
1248
+ "media_comment" : media_comment
1249
+ };
1250
+ };
1251
+
1252
+ oop.inherits(CssHighlightRules, TextHighlightRules);
1253
+
1254
+ exports.CssHighlightRules = CssHighlightRules;
1255
+
1256
+ });
1257
+
1258
+ 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) {
1259
+
1260
+
1261
+ var oop = require("../../lib/oop");
1262
+ var Behaviour = require("../behaviour").Behaviour;
1263
+ var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1264
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1265
+
1266
+ var CssBehaviour = function () {
1267
+
1268
+ this.inherit(CstyleBehaviour);
1269
+
1270
+ this.add("colon", "insertion", function (state, action, editor, session, text) {
1271
+ if (text === ':') {
1272
+ var cursor = editor.getCursorPosition();
1273
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1274
+ var token = iterator.getCurrentToken();
1275
+ if (token && token.value.match(/\s+/)) {
1276
+ token = iterator.stepBackward();
1277
+ }
1278
+ if (token && token.type === 'support.type') {
1279
+ var line = session.doc.getLine(cursor.row);
1280
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1281
+ if (rightChar === ':') {
1282
+ return {
1283
+ text: '',
1284
+ selection: [1, 1]
1285
+ }
1286
+ }
1287
+ if (!line.substring(cursor.column).match(/^\s*;/)) {
1288
+ return {
1289
+ text: ':;',
1290
+ selection: [1, 1]
1291
+ }
1292
+ }
1293
+ }
1294
+ }
1295
+ });
1296
+
1297
+ this.add("colon", "deletion", function (state, action, editor, session, range) {
1298
+ var selected = session.doc.getTextRange(range);
1299
+ if (!range.isMultiLine() && selected === ':') {
1300
+ var cursor = editor.getCursorPosition();
1301
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1302
+ var token = iterator.getCurrentToken();
1303
+ if (token && token.value.match(/\s+/)) {
1304
+ token = iterator.stepBackward();
1305
+ }
1306
+ if (token && token.type === 'support.type') {
1307
+ var line = session.doc.getLine(range.start.row);
1308
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
1309
+ if (rightChar === ';') {
1310
+ range.end.column ++;
1311
+ return range;
1312
+ }
1313
+ }
1314
+ }
1315
+ });
1316
+
1317
+ this.add("semicolon", "insertion", function (state, action, editor, session, text) {
1318
+ if (text === ';') {
1319
+ var cursor = editor.getCursorPosition();
1320
+ var line = session.doc.getLine(cursor.row);
1321
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1322
+ if (rightChar === ';') {
1323
+ return {
1324
+ text: '',
1325
+ selection: [1, 1]
1326
+ }
1327
+ }
1328
+ }
1329
+ });
1330
+
1331
+ }
1332
+ oop.inherits(CssBehaviour, CstyleBehaviour);
1333
+
1334
+ exports.CssBehaviour = CssBehaviour;
1335
+ });
1336
+
1337
+ define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1338
+
1339
+
1340
+ var oop = require("../lib/oop");
1341
+ var lang = require("../lib/lang");
1342
+ var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1343
+ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1344
+ var xmlUtil = require("./xml_util");
1345
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1346
+
1347
+ var tagMap = lang.createMap({
1348
+ a : 'anchor',
1349
+ button : 'form',
1350
+ form : 'form',
1351
+ img : 'image',
1352
+ input : 'form',
1353
+ label : 'form',
1354
+ script : 'script',
1355
+ select : 'form',
1356
+ textarea : 'form',
1357
+ style : 'style',
1358
+ table : 'table',
1359
+ tbody : 'table',
1360
+ td : 'table',
1361
+ tfoot : 'table',
1362
+ th : 'table',
1363
+ tr : 'table'
1364
+ });
1365
+
1366
+ var HtmlHighlightRules = function() {
1367
+ this.$rules = {
1368
+ start : [{
1369
+ token : "text",
1370
+ regex : "<\\!\\[CDATA\\[",
1371
+ next : "cdata"
1372
+ }, {
1373
+ token : "xml-pe",
1374
+ regex : "<\\?.*?\\?>"
1375
+ }, {
1376
+ token : "comment",
1377
+ regex : "<\\!--",
1378
+ next : "comment"
1379
+ }, {
1380
+ token : "xml-pe",
1381
+ regex : "<\\!.*?>"
1382
+ }, {
1383
+ token : "meta.tag",
1384
+ regex : "<(?=script\\b)",
1385
+ next : "script"
1386
+ }, {
1387
+ token : "meta.tag",
1388
+ regex : "<(?=style\\b)",
1389
+ next : "style"
1390
+ }, {
1391
+ token : "meta.tag", // opening tag
1392
+ regex : "<\\/?",
1393
+ next : "tag"
1394
+ }, {
1395
+ token : "text",
1396
+ regex : "\\s+"
1397
+ }, {
1398
+ token : "constant.character.entity",
1399
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1400
+ }],
1401
+
1402
+ cdata : [ {
1403
+ token : "text",
1404
+ regex : "\\]\\]>",
1405
+ next : "start"
1406
+ } ],
1407
+
1408
+ comment : [ {
1409
+ token : "comment",
1410
+ regex : ".*?-->",
1411
+ next : "start"
1412
+ }, {
1413
+ defaultToken : "comment"
1414
+ } ]
1415
+ };
1416
+
1417
+ xmlUtil.tag(this.$rules, "tag", "start", tagMap);
1418
+ xmlUtil.tag(this.$rules, "style", "css-start", tagMap);
1419
+ xmlUtil.tag(this.$rules, "script", "js-start", tagMap);
1420
+
1421
+ this.embedRules(JavaScriptHighlightRules, "js-", [{
1422
+ token: "comment",
1423
+ regex: "\\/\\/.*(?=<\\/script>)",
1424
+ next: "tag"
1425
+ }, {
1426
+ token: "meta.tag",
1427
+ regex: "<\\/(?=script)",
1428
+ next: "tag"
1429
+ }]);
1430
+
1431
+ this.embedRules(CssHighlightRules, "css-", [{
1432
+ token: "meta.tag",
1433
+ regex: "<\\/(?=style)",
1434
+ next: "tag"
1435
+ }]);
1436
+ };
1437
+
1438
+ oop.inherits(HtmlHighlightRules, TextHighlightRules);
1439
+
1440
+ exports.HtmlHighlightRules = HtmlHighlightRules;
1441
+ });
1442
+
1443
+ define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
1444
+
1445
+
1446
+ function string(state) {
1447
+ return [{
1448
+ token : "string",
1449
+ regex : '"',
1450
+ next : state + "_qqstring"
1451
+ }, {
1452
+ token : "string",
1453
+ regex : "'",
1454
+ next : state + "_qstring"
1455
+ }];
1456
+ }
1457
+
1458
+ function multiLineString(quote, state) {
1459
+ return [
1460
+ {token : "string", regex : quote, next : state},
1461
+ {
1462
+ token : "constant.language.escape",
1463
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1464
+ },
1465
+ {defaultToken : "string"}
1466
+ ];
1467
+ }
1468
+
1469
+ exports.tag = function(states, name, nextState, tagMap) {
1470
+ states[name] = [{
1471
+ token : "text",
1472
+ regex : "\\s+"
1473
+ }, {
1474
+
1475
+ token : !tagMap ? "meta.tag.tag-name" : function(value) {
1476
+ if (tagMap[value])
1477
+ return "meta.tag.tag-name." + tagMap[value];
1478
+ else
1479
+ return "meta.tag.tag-name";
1480
+ },
1481
+ regex : "[-_a-zA-Z0-9:]+",
1482
+ next : name + "_embed_attribute_list"
1483
+ }, {
1484
+ token: "empty",
1485
+ regex: "",
1486
+ next : name + "_embed_attribute_list"
1487
+ }];
1488
+
1489
+ states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
1490
+ states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
1491
+
1492
+ states[name + "_embed_attribute_list"] = [{
1493
+ token : "meta.tag.r",
1494
+ regex : "/?>",
1495
+ next : nextState
1496
+ }, {
1497
+ token : "keyword.operator",
1498
+ regex : "="
1499
+ }, {
1500
+ token : "entity.other.attribute-name",
1501
+ regex : "[-_a-zA-Z0-9:]+"
1502
+ }, {
1503
+ token : "constant.numeric", // float
1504
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
1505
+ }, {
1506
+ token : "text",
1507
+ regex : "\\s+"
1508
+ }].concat(string(name));
1509
+ };
1510
+
1511
+ });
1512
+
1513
+ define('ace/mode/behaviour/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour/xml', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
1514
+
1515
+
1516
+ var oop = require("../../lib/oop");
1517
+ var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
1518
+ var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1519
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1520
+ var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
1521
+
1522
+ function hasType(token, type) {
1523
+ var hasType = true;
1524
+ var typeList = token.type.split('.');
1525
+ var needleList = type.split('.');
1526
+ needleList.forEach(function(needle){
1527
+ if (typeList.indexOf(needle) == -1) {
1528
+ hasType = false;
1529
+ return false;
1530
+ }
1531
+ });
1532
+ return hasType;
1533
+ }
1534
+
1535
+ var HtmlBehaviour = function () {
1536
+
1537
+ this.inherit(XmlBehaviour); // Get xml behaviour
1538
+
1539
+ this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1540
+ if (text == '>') {
1541
+ var position = editor.getCursorPosition();
1542
+ var iterator = new TokenIterator(session, position.row, position.column);
1543
+ var token = iterator.getCurrentToken();
1544
+ var atCursor = false;
1545
+ if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1546
+ do {
1547
+ token = iterator.stepBackward();
1548
+ } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1549
+ } else {
1550
+ atCursor = true;
1551
+ }
1552
+ if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1553
+ return
1554
+ }
1555
+ var element = token.value;
1556
+ if (atCursor){
1557
+ var element = element.substring(0, position.column - token.start);
1558
+ }
1559
+ if (voidElements.indexOf(element) !== -1){
1560
+ return;
1561
+ }
1562
+ return {
1563
+ text: '>' + '</' + element + '>',
1564
+ selection: [1, 1]
1565
+ }
1566
+ }
1567
+ });
1568
+ }
1569
+ oop.inherits(HtmlBehaviour, XmlBehaviour);
1570
+
1571
+ exports.HtmlBehaviour = HtmlBehaviour;
1572
+ });
1573
+
1574
+ define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
1575
+
1576
+
1577
+ var oop = require("../../lib/oop");
1578
+ var Behaviour = require("../behaviour").Behaviour;
1579
+ var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1580
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1581
+
1582
+ function hasType(token, type) {
1583
+ var hasType = true;
1584
+ var typeList = token.type.split('.');
1585
+ var needleList = type.split('.');
1586
+ needleList.forEach(function(needle){
1587
+ if (typeList.indexOf(needle) == -1) {
1588
+ hasType = false;
1589
+ return false;
1590
+ }
1591
+ });
1592
+ return hasType;
1593
+ }
1594
+
1595
+ var XmlBehaviour = function () {
1596
+
1597
+ this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
1598
+
1599
+ this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1600
+ if (text == '>') {
1601
+ var position = editor.getCursorPosition();
1602
+ var iterator = new TokenIterator(session, position.row, position.column);
1603
+ var token = iterator.getCurrentToken();
1604
+ var atCursor = false;
1605
+ if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1606
+ do {
1607
+ token = iterator.stepBackward();
1608
+ } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1609
+ } else {
1610
+ atCursor = true;
1611
+ }
1612
+ if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1613
+ return
1614
+ }
1615
+ var tag = token.value;
1616
+ if (atCursor){
1617
+ var tag = tag.substring(0, position.column - token.start);
1618
+ }
1619
+
1620
+ return {
1621
+ text: '>' + '</' + tag + '>',
1622
+ selection: [1, 1]
1623
+ }
1624
+ }
1625
+ });
1626
+
1627
+ this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
1628
+ if (text == "\n") {
1629
+ var cursor = editor.getCursorPosition();
1630
+ var line = session.doc.getLine(cursor.row);
1631
+ var rightChars = line.substring(cursor.column, cursor.column + 2);
1632
+ if (rightChars == '</') {
1633
+ var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
1634
+ var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
1635
+
1636
+ return {
1637
+ text: '\n' + indent + '\n' + next_indent,
1638
+ selection: [1, indent.length, 1, indent.length]
1639
+ }
1640
+ }
1641
+ }
1642
+ });
1643
+
1644
+ }
1645
+ oop.inherits(XmlBehaviour, Behaviour);
1646
+
1647
+ exports.XmlBehaviour = XmlBehaviour;
1648
+ });
1649
+
1650
+ define('ace/mode/folding/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/mixed', 'ace/mode/folding/xml', 'ace/mode/folding/cstyle'], function(require, exports, module) {
1651
+
1652
+
1653
+ var oop = require("../../lib/oop");
1654
+ var MixedFoldMode = require("./mixed").FoldMode;
1655
+ var XmlFoldMode = require("./xml").FoldMode;
1656
+ var CStyleFoldMode = require("./cstyle").FoldMode;
1657
+
1658
+ var FoldMode = exports.FoldMode = function() {
1659
+ MixedFoldMode.call(this, new XmlFoldMode({
1660
+ "area": 1,
1661
+ "base": 1,
1662
+ "br": 1,
1663
+ "col": 1,
1664
+ "command": 1,
1665
+ "embed": 1,
1666
+ "hr": 1,
1667
+ "img": 1,
1668
+ "input": 1,
1669
+ "keygen": 1,
1670
+ "link": 1,
1671
+ "meta": 1,
1672
+ "param": 1,
1673
+ "source": 1,
1674
+ "track": 1,
1675
+ "wbr": 1,
1676
+ "li": 1,
1677
+ "dt": 1,
1678
+ "dd": 1,
1679
+ "p": 1,
1680
+ "rt": 1,
1681
+ "rp": 1,
1682
+ "optgroup": 1,
1683
+ "option": 1,
1684
+ "colgroup": 1,
1685
+ "td": 1,
1686
+ "th": 1
1687
+ }), {
1688
+ "js-": new CStyleFoldMode(),
1689
+ "css-": new CStyleFoldMode()
1690
+ });
1691
+ };
1692
+
1693
+ oop.inherits(FoldMode, MixedFoldMode);
1694
+
1695
+ });
1696
+
1697
+ define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1698
+
1699
+
1700
+ var oop = require("../../lib/oop");
1701
+ var BaseFoldMode = require("./fold_mode").FoldMode;
1702
+
1703
+ var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
1704
+ this.defaultMode = defaultMode;
1705
+ this.subModes = subModes;
1706
+ };
1707
+ oop.inherits(FoldMode, BaseFoldMode);
1708
+
1709
+ (function() {
1710
+
1711
+
1712
+ this.$getMode = function(state) {
1713
+ for (var key in this.subModes) {
1714
+ if (state.indexOf(key) === 0)
1715
+ return this.subModes[key];
1716
+ }
1717
+ return null;
1718
+ };
1719
+
1720
+ this.$tryMode = function(state, session, foldStyle, row) {
1721
+ var mode = this.$getMode(state);
1722
+ return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1723
+ };
1724
+
1725
+ this.getFoldWidget = function(session, foldStyle, row) {
1726
+ return (
1727
+ this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
1728
+ this.$tryMode(session.getState(row), session, foldStyle, row) ||
1729
+ this.defaultMode.getFoldWidget(session, foldStyle, row)
1730
+ );
1731
+ };
1732
+
1733
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
1734
+ var mode = this.$getMode(session.getState(row-1));
1735
+
1736
+ if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1737
+ mode = this.$getMode(session.getState(row));
1738
+
1739
+ if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1740
+ mode = this.defaultMode;
1741
+
1742
+ return mode.getFoldWidgetRange(session, foldStyle, row);
1743
+ };
1744
+
1745
+ }).call(FoldMode.prototype);
1746
+
1747
+ });
1748
+
1749
+ define('ace/mode/folding/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/range', 'ace/mode/folding/fold_mode', 'ace/token_iterator'], function(require, exports, module) {
1750
+
1751
+
1752
+ var oop = require("../../lib/oop");
1753
+ var lang = require("../../lib/lang");
1754
+ var Range = require("../../range").Range;
1755
+ var BaseFoldMode = require("./fold_mode").FoldMode;
1756
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1757
+
1758
+ var FoldMode = exports.FoldMode = function(voidElements) {
1759
+ BaseFoldMode.call(this);
1760
+ this.voidElements = voidElements || {};
1761
+ };
1762
+ oop.inherits(FoldMode, BaseFoldMode);
1763
+
1764
+ (function() {
1765
+
1766
+ this.getFoldWidget = function(session, foldStyle, row) {
1767
+ var tag = this._getFirstTagInLine(session, row);
1768
+
1769
+ if (tag.closing)
1770
+ return foldStyle == "markbeginend" ? "end" : "";
1771
+
1772
+ if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
1773
+ return "";
1774
+
1775
+ if (tag.selfClosing)
1776
+ return "";
1777
+
1778
+ if (tag.value.indexOf("/" + tag.tagName) !== -1)
1779
+ return "";
1780
+
1781
+ return "start";
1782
+ };
1783
+
1784
+ this._getFirstTagInLine = function(session, row) {
1785
+ var tokens = session.getTokens(row);
1786
+ var value = "";
1787
+ for (var i = 0; i < tokens.length; i++) {
1788
+ var token = tokens[i];
1789
+ if (token.type.indexOf("meta.tag") === 0)
1790
+ value += token.value;
1791
+ else
1792
+ value += lang.stringRepeat(" ", token.value.length);
1793
+ }
1794
+
1795
+ return this._parseTag(value);
1796
+ };
1797
+
1798
+ this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
1799
+ this._parseTag = function(tag) {
1800
+
1801
+ var match = this.tagRe.exec(tag);
1802
+ var column = this.tagRe.lastIndex || 0;
1803
+ this.tagRe.lastIndex = 0;
1804
+
1805
+ return {
1806
+ value: tag,
1807
+ match: match ? match[2] : "",
1808
+ closing: match ? !!match[3] : false,
1809
+ selfClosing: match ? !!match[5] || match[2] == "/>" : false,
1810
+ tagName: match ? match[4] : "",
1811
+ column: match[1] ? column + match[1].length : column
1812
+ };
1813
+ };
1814
+ this._readTagForward = function(iterator) {
1815
+ var token = iterator.getCurrentToken();
1816
+ if (!token)
1817
+ return null;
1818
+
1819
+ var value = "";
1820
+ var start;
1821
+
1822
+ do {
1823
+ if (token.type.indexOf("meta.tag") === 0) {
1824
+ if (!start) {
1825
+ var start = {
1826
+ row: iterator.getCurrentTokenRow(),
1827
+ column: iterator.getCurrentTokenColumn()
1828
+ };
1829
+ }
1830
+ value += token.value;
1831
+ if (value.indexOf(">") !== -1) {
1832
+ var tag = this._parseTag(value);
1833
+ tag.start = start;
1834
+ tag.end = {
1835
+ row: iterator.getCurrentTokenRow(),
1836
+ column: iterator.getCurrentTokenColumn() + token.value.length
1837
+ };
1838
+ iterator.stepForward();
1839
+ return tag;
1840
+ }
1841
+ }
1842
+ } while(token = iterator.stepForward());
1843
+
1844
+ return null;
1845
+ };
1846
+
1847
+ this._readTagBackward = function(iterator) {
1848
+ var token = iterator.getCurrentToken();
1849
+ if (!token)
1850
+ return null;
1851
+
1852
+ var value = "";
1853
+ var end;
1854
+
1855
+ do {
1856
+ if (token.type.indexOf("meta.tag") === 0) {
1857
+ if (!end) {
1858
+ end = {
1859
+ row: iterator.getCurrentTokenRow(),
1860
+ column: iterator.getCurrentTokenColumn() + token.value.length
1861
+ };
1862
+ }
1863
+ value = token.value + value;
1864
+ if (value.indexOf("<") !== -1) {
1865
+ var tag = this._parseTag(value);
1866
+ tag.end = end;
1867
+ tag.start = {
1868
+ row: iterator.getCurrentTokenRow(),
1869
+ column: iterator.getCurrentTokenColumn()
1870
+ };
1871
+ iterator.stepBackward();
1872
+ return tag;
1873
+ }
1874
+ }
1875
+ } while(token = iterator.stepBackward());
1876
+
1877
+ return null;
1878
+ };
1879
+
1880
+ this._pop = function(stack, tag) {
1881
+ while (stack.length) {
1882
+
1883
+ var top = stack[stack.length-1];
1884
+ if (!tag || top.tagName == tag.tagName) {
1885
+ return stack.pop();
1886
+ }
1887
+ else if (this.voidElements[tag.tagName]) {
1888
+ return;
1889
+ }
1890
+ else if (this.voidElements[top.tagName]) {
1891
+ stack.pop();
1892
+ continue;
1893
+ } else {
1894
+ return null;
1895
+ }
1896
+ }
1897
+ };
1898
+
1899
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
1900
+ var firstTag = this._getFirstTagInLine(session, row);
1901
+
1902
+ if (!firstTag.match)
1903
+ return null;
1904
+
1905
+ var isBackward = firstTag.closing || firstTag.selfClosing;
1906
+ var stack = [];
1907
+ var tag;
1908
+
1909
+ if (!isBackward) {
1910
+ var iterator = new TokenIterator(session, row, firstTag.column);
1911
+ var start = {
1912
+ row: row,
1913
+ column: firstTag.column + firstTag.tagName.length + 2
1914
+ };
1915
+ while (tag = this._readTagForward(iterator)) {
1916
+ if (tag.selfClosing) {
1917
+ if (!stack.length) {
1918
+ tag.start.column += tag.tagName.length + 2;
1919
+ tag.end.column -= 2;
1920
+ return Range.fromPoints(tag.start, tag.end);
1921
+ } else
1922
+ continue;
1923
+ }
1924
+
1925
+ if (tag.closing) {
1926
+ this._pop(stack, tag);
1927
+ if (stack.length == 0)
1928
+ return Range.fromPoints(start, tag.start);
1929
+ }
1930
+ else {
1931
+ stack.push(tag)
1932
+ }
1933
+ }
1934
+ }
1935
+ else {
1936
+ var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
1937
+ var end = {
1938
+ row: row,
1939
+ column: firstTag.column
1940
+ };
1941
+
1942
+ while (tag = this._readTagBackward(iterator)) {
1943
+ if (tag.selfClosing) {
1944
+ if (!stack.length) {
1945
+ tag.start.column += tag.tagName.length + 2;
1946
+ tag.end.column -= 2;
1947
+ return Range.fromPoints(tag.start, tag.end);
1948
+ } else
1949
+ continue;
1950
+ }
1951
+
1952
+ if (!tag.closing) {
1953
+ this._pop(stack, tag);
1954
+ if (stack.length == 0) {
1955
+ tag.start.column += tag.tagName.length + 2;
1956
+ return Range.fromPoints(tag.start, end);
1957
+ }
1958
+ }
1959
+ else {
1960
+ stack.push(tag)
1961
+ }
1962
+ }
1963
+ }
1964
+
1965
+ };
1966
+
1967
+ }).call(FoldMode.prototype);
1968
+
1969
+ });