~ubuntu-branches/ubuntu/trusty/0ad/trusty-backports

« back to all changes in this revision

Viewing changes to source/tools/jsdebugger/js/lib/ace/mode-html.js

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2014-02-18 23:21:11 UTC
  • mfrom: (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20140218232111-9x3ag0s782wd9w62
* Repack tarball to remove minified javascript files without source in
  source/tools/jsdebugger/. (Closes: #735349)
  - debian/control: Hardcode versions of 0ad-data{,-common} to depend on to
    workaround the fact that 0.0.15+dfsg is strictly greater than 0.0.15.
* Update debian/copyright to include text of IBM Common Public License.
* Update email address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Distributed under the BSD license:
3
 
 *
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.
28
 
 *
29
 
 * ***** END LICENSE BLOCK ***** */
30
 
 
31
 
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) {
32
 
 
33
 
 
34
 
var oop = require("../lib/oop");
35
 
var TextMode = require("./text").Mode;
36
 
var JavaScriptMode = require("./javascript").Mode;
37
 
var CssMode = require("./css").Mode;
38
 
var Tokenizer = require("../tokenizer").Tokenizer;
39
 
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
40
 
var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
41
 
var HtmlFoldMode = require("./folding/html").FoldMode;
42
 
 
43
 
var Mode = function() {
44
 
    var highlighter = new HtmlHighlightRules();
45
 
    this.$tokenizer = new Tokenizer(highlighter.getRules());
46
 
    this.$behaviour = new HtmlBehaviour();
47
 
    
48
 
    this.$embeds = highlighter.getEmbeds();
49
 
    this.createModeDelegates({
50
 
        "js-": JavaScriptMode,
51
 
        "css-": CssMode
52
 
    });
53
 
    
54
 
    this.foldingRules = new HtmlFoldMode();
55
 
};
56
 
oop.inherits(Mode, TextMode);
57
 
 
58
 
(function() {
59
 
 
60
 
    
61
 
    this.toggleCommentLines = function(state, doc, startRow, endRow) {
62
 
        return 0;
63
 
    };
64
 
 
65
 
    this.getNextLineIndent = function(state, line, tab) {
66
 
        return this.$getIndent(line);
67
 
    };
68
 
 
69
 
    this.checkOutdent = function(state, line, input) {
70
 
        return false;
71
 
    };
72
 
 
73
 
}).call(Mode.prototype);
74
 
 
75
 
exports.Mode = Mode;
76
 
});
77
 
 
78
 
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) {
79
 
 
80
 
 
81
 
var oop = require("../lib/oop");
82
 
var TextMode = require("./text").Mode;
83
 
var Tokenizer = require("../tokenizer").Tokenizer;
84
 
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
85
 
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
86
 
var Range = require("../range").Range;
87
 
var WorkerClient = require("../worker/worker_client").WorkerClient;
88
 
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
89
 
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
90
 
 
91
 
var Mode = function() {
92
 
    this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
93
 
    this.$outdent = new MatchingBraceOutdent();
94
 
    this.$behaviour = new CstyleBehaviour();
95
 
    this.foldingRules = new CStyleFoldMode();
96
 
};
97
 
oop.inherits(Mode, TextMode);
98
 
 
99
 
(function() {
100
 
 
101
 
 
102
 
    this.toggleCommentLines = function(state, doc, startRow, endRow) {
103
 
        var outdent = true;
104
 
        var re = /^(\s*)\/\//;
105
 
 
106
 
        for (var i=startRow; i<= endRow; i++) {
107
 
            if (!re.test(doc.getLine(i))) {
108
 
                outdent = false;
109
 
                break;
110
 
            }
111
 
        }
112
 
 
113
 
        if (outdent) {
114
 
            var deleteRange = new Range(0, 0, 0, 0);
115
 
            for (var i=startRow; i<= endRow; i++)
116
 
            {
117
 
                var line = doc.getLine(i);
118
 
                var m = line.match(re);
119
 
                deleteRange.start.row = i;
120
 
                deleteRange.end.row = i;
121
 
                deleteRange.end.column = m[0].length;
122
 
                doc.replace(deleteRange, m[1]);
123
 
            }
124
 
        }
125
 
        else {
126
 
            doc.indentRows(startRow, endRow, "//");
127
 
        }
128
 
    };
129
 
 
130
 
    this.getNextLineIndent = function(state, line, tab) {
131
 
        var indent = this.$getIndent(line);
132
 
 
133
 
        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
134
 
        var tokens = tokenizedLine.tokens;
135
 
        var endState = tokenizedLine.state;
136
 
 
137
 
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
138
 
            return indent;
139
 
        }
140
 
        
141
 
        if (state == "start" || state == "regex_allowed") {
142
 
            var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
143
 
            if (match) {
144
 
                indent += tab;
145
 
            }
146
 
        } else if (state == "doc-start") {
147
 
            if (endState == "start" || state == "regex_allowed") {
148
 
                return "";
149
 
            }
150
 
            var match = line.match(/^\s*(\/?)\*/);
151
 
            if (match) {
152
 
                if (match[1]) {
153
 
                    indent += " ";
154
 
                }
155
 
                indent += "* ";
156
 
            }
157
 
        }
158
 
 
159
 
        return indent;
160
 
    };
161
 
 
162
 
    this.checkOutdent = function(state, line, input) {
163
 
        return this.$outdent.checkOutdent(line, input);
164
 
    };
165
 
 
166
 
    this.autoOutdent = function(state, doc, row) {
167
 
        this.$outdent.autoOutdent(doc, row);
168
 
    };
169
 
    
170
 
    this.createWorker = function(session) {
171
 
        var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
172
 
        worker.attachToDocument(session.getDocument());
173
 
 
174
 
        worker.on("jslint", function(results) {
175
 
            session.setAnnotations(results.data);
176
 
        });
177
 
        
178
 
        worker.on("terminate", function() {
179
 
            session.clearAnnotations();
180
 
        });
181
 
        
182
 
        return worker;
183
 
    };
184
 
 
185
 
}).call(Mode.prototype);
186
 
 
187
 
exports.Mode = Mode;
188
 
});
189
 
 
190
 
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) {
191
 
 
192
 
 
193
 
var oop = require("../lib/oop");
194
 
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
195
 
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
196
 
 
197
 
var JavaScriptHighlightRules = function() {
198
 
    var keywordMapper = this.createKeywordMapper({
199
 
        "variable.language":
200
 
            "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|"  + // Constructors
201
 
            "Namespace|QName|XML|XMLList|"                                             + // E4X
202
 
            "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|"   +
203
 
            "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|"                    +
204
 
            "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|"   + // Errors
205
 
            "SyntaxError|TypeError|URIError|"                                          +
206
 
            "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
207
 
            "isNaN|parseFloat|parseInt|"                                               +
208
 
            "JSON|Math|"                                                               + // Other
209
 
            "this|arguments|prototype|window|document"                                 , // Pseudo
210
 
        "keyword":
211
 
            "const|yield|import|get|set|" +
212
 
            "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
213
 
            "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
214
 
            "__parent__|__count__|escape|unescape|with|__proto__|" +
215
 
            "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
216
 
        "storage.type":
217
 
            "const|let|var|function",
218
 
        "constant.language":
219
 
            "null|Infinity|NaN|undefined",
220
 
        "support.function":
221
 
            "alert"
222
 
    }, "identifier");
223
 
    var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
224
 
    var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
225
 
 
226
 
    var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
227
 
        "u[0-9a-fA-F]{4}|" + // unicode
228
 
        "[0-2][0-7]{0,2}|" + // oct
229
 
        "3[0-6][0-7]?|" + // oct
230
 
        "37[0-7]?|" + // oct
231
 
        "[4-7][0-7]?|" + //oct
232
 
        ".)";
233
 
 
234
 
    this.$rules = {
235
 
        "start" : [
236
 
            {
237
 
                token : "comment",
238
 
                regex : /\/\/.*$/
239
 
            },
240
 
            DocCommentHighlightRules.getStartRule("doc-start"),
241
 
            {
242
 
                token : "comment", // multi line comment
243
 
                merge : true,
244
 
                regex : /\/\*/,
245
 
                next : "comment"
246
 
            }, {
247
 
                token : "string",
248
 
                regex : "'(?=.)",
249
 
                next  : "qstring"
250
 
            }, {
251
 
                token : "string",
252
 
                regex : '"(?=.)',
253
 
                next  : "qqstring"
254
 
            }, {
255
 
                token : "constant.numeric", // hex
256
 
                regex : /0[xX][0-9a-fA-F]+\b/
257
 
            }, {
258
 
                token : "constant.numeric", // float
259
 
                regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
260
 
            }, {
261
 
                token : [
262
 
                    "storage.type", "punctuation.operator", "support.function",
263
 
                    "punctuation.operator", "entity.name.function", "text","keyword.operator"
264
 
                ],
265
 
                regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
266
 
                next: "function_arguments"
267
 
            }, {
268
 
                token : [
269
 
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
270
 
                    "keyword.operator", "text", "storage.type", "text", "paren.lparen"
271
 
                ],
272
 
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
273
 
                next: "function_arguments"
274
 
            }, {
275
 
                token : [
276
 
                    "entity.name.function", "text", "keyword.operator", "text", "storage.type",
277
 
                    "text", "paren.lparen"
278
 
                ],
279
 
                regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
280
 
                next: "function_arguments"
281
 
            }, {
282
 
                token : [
283
 
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
284
 
                    "keyword.operator", "text",
285
 
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
286
 
                ],
287
 
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
288
 
                next: "function_arguments"
289
 
            }, {
290
 
                token : [
291
 
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
292
 
                ],
293
 
                regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
294
 
                next: "function_arguments"
295
 
            }, {
296
 
                token : [
297
 
                    "entity.name.function", "text", "punctuation.operator",
298
 
                    "text", "storage.type", "text", "paren.lparen"
299
 
                ],
300
 
                regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
301
 
                next: "function_arguments"
302
 
            }, {
303
 
                token : [
304
 
                    "text", "text", "storage.type", "text", "paren.lparen"
305
 
                ],
306
 
                regex : "(:)(\\s*)(function)(\\s*)(\\()",
307
 
                next: "function_arguments"
308
 
            }, {
309
 
                token : "constant.language.boolean",
310
 
                regex : /(?:true|false)\b/
311
 
            }, {
312
 
                token : "keyword",
313
 
                regex : "(?:" + kwBeforeRe + ")\\b",
314
 
                next : "regex_allowed"
315
 
            }, {
316
 
                token : ["punctuation.operator", "support.function"],
317
 
                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(?=\()/
318
 
            }, {
319
 
                token : ["punctuation.operator", "support.function.dom"],
320
 
                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(?=\()/
321
 
            }, {
322
 
                token : ["punctuation.operator", "support.constant"],
323
 
                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/
324
 
            }, {
325
 
                token : ["storage.type", "punctuation.operator", "support.function.firebug"],
326
 
                regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
327
 
            }, {
328
 
                token : keywordMapper,
329
 
                regex : identifierRe
330
 
            }, {
331
 
                token : "keyword.operator",
332
 
                regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
333
 
                next  : "regex_allowed"
334
 
            }, {
335
 
                token : "punctuation.operator",
336
 
                regex : /\?|\:|\,|\;|\./,
337
 
                next  : "regex_allowed"
338
 
            }, {
339
 
                token : "paren.lparen",
340
 
                regex : /[\[({]/,
341
 
                next  : "regex_allowed"
342
 
            }, {
343
 
                token : "paren.rparen",
344
 
                regex : /[\])}]/
345
 
            }, {
346
 
                token : "keyword.operator",
347
 
                regex : /\/=?/,
348
 
                next  : "regex_allowed"
349
 
            }, {
350
 
                token: "comment",
351
 
                regex: /^#!.*$/
352
 
            }, {
353
 
                token : "text",
354
 
                regex : /\s+/
355
 
            }
356
 
        ],
357
 
        "regex_allowed": [
358
 
            DocCommentHighlightRules.getStartRule("doc-start"),
359
 
            {
360
 
                token : "comment", // multi line comment
361
 
                merge : true,
362
 
                regex : "\\/\\*",
363
 
                next : "comment_regex_allowed"
364
 
            }, {
365
 
                token : "comment",
366
 
                regex : "\\/\\/.*$"
367
 
            }, {
368
 
                token: "string.regexp",
369
 
                regex: "\\/",
370
 
                next: "regex",
371
 
                merge: true
372
 
            }, {
373
 
                token : "text",
374
 
                regex : "\\s+"
375
 
            }, {
376
 
                token: "empty",
377
 
                regex: "",
378
 
                next: "start"
379
 
            }
380
 
        ],
381
 
        "regex": [
382
 
            {
383
 
                token: "regexp.keyword.operator",
384
 
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
385
 
            }, {
386
 
                token: "string.regexp",
387
 
                regex: "/\\w*",
388
 
                next: "start",
389
 
                merge: true
390
 
            }, {
391
 
                token : "invalid",
392
 
                regex: /\{\d+,?(?:\d+)?}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
393
 
            }, {
394
 
                token : "constant.language.escape",
395
 
                regex: /\(\?[:=!]|\)|{\d+,?(?:\d+)?}|{,\d+}|[+*]\?|[(|)$^+*?]/
396
 
            }, {
397
 
                token: "string.regexp",
398
 
                regex: /{|[^{\[\/\\(|)$^+*?]+/,
399
 
                merge: true
400
 
            }, {
401
 
                token: "constant.language.escape",
402
 
                regex: /\[\^?/,
403
 
                next: "regex_character_class",
404
 
                merge: true
405
 
            }, {
406
 
                token: "empty",
407
 
                regex: "",
408
 
                next: "start"
409
 
            }
410
 
        ],
411
 
        "regex_character_class": [
412
 
            {
413
 
                token: "regexp.keyword.operator",
414
 
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
415
 
            }, {
416
 
                token: "constant.language.escape",
417
 
                regex: "]",
418
 
                next: "regex",
419
 
                merge: true
420
 
            }, {
421
 
                token: "constant.language.escape",
422
 
                regex: "-"
423
 
            }, {
424
 
                token: "string.regexp.charachterclass",
425
 
                regex: /[^\]\-\\]+/,
426
 
                merge: true
427
 
            }, {
428
 
                token: "empty",
429
 
                regex: "",
430
 
                next: "start"
431
 
            }
432
 
        ],
433
 
        "function_arguments": [
434
 
            {
435
 
                token: "variable.parameter",
436
 
                regex: identifierRe
437
 
            }, {
438
 
                token: "punctuation.operator",
439
 
                regex: "[, ]+",
440
 
                merge: true
441
 
            }, {
442
 
                token: "punctuation.operator",
443
 
                regex: "$",
444
 
                merge: true
445
 
            }, {
446
 
                token: "empty",
447
 
                regex: "",
448
 
                next: "start"
449
 
            }
450
 
        ],
451
 
        "comment_regex_allowed" : [
452
 
            {
453
 
                token : "comment", // closing comment
454
 
                regex : ".*?\\*\\/",
455
 
                merge : true,
456
 
                next : "regex_allowed"
457
 
            }, {
458
 
                token : "comment", // comment spanning whole line
459
 
                merge : true,
460
 
                regex : ".+"
461
 
            }
462
 
        ],
463
 
        "comment" : [
464
 
            {
465
 
                token : "comment", // closing comment
466
 
                regex : ".*?\\*\\/",
467
 
                merge : true,
468
 
                next : "start"
469
 
            }, {
470
 
                token : "comment", // comment spanning whole line
471
 
                merge : true,
472
 
                regex : ".+"
473
 
            }
474
 
        ],
475
 
        "qqstring" : [
476
 
            {
477
 
                token : "constant.language.escape",
478
 
                regex : escapedRe
479
 
            }, {
480
 
                token : "string",
481
 
                regex : '[^"\\\\]+',
482
 
                merge : true
483
 
            }, {
484
 
                token : "string",
485
 
                regex : "\\\\$",
486
 
                next  : "qqstring",
487
 
                merge : true
488
 
            }, {
489
 
                token : "string",
490
 
                regex : '"|$',
491
 
                next  : "start",
492
 
                merge : true
493
 
            }
494
 
        ],
495
 
        "qstring" : [
496
 
            {
497
 
                token : "constant.language.escape",
498
 
                regex : escapedRe
499
 
            }, {
500
 
                token : "string",
501
 
                regex : "[^'\\\\]+",
502
 
                merge : true
503
 
            }, {
504
 
                token : "string",
505
 
                regex : "\\\\$",
506
 
                next  : "qstring",
507
 
                merge : true
508
 
            }, {
509
 
                token : "string",
510
 
                regex : "'|$",
511
 
                next  : "start",
512
 
                merge : true
513
 
            }
514
 
        ]
515
 
    };
516
 
 
517
 
    this.embedRules(DocCommentHighlightRules, "doc-",
518
 
        [ DocCommentHighlightRules.getEndRule("start") ]);
519
 
};
520
 
 
521
 
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
522
 
 
523
 
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
524
 
});
525
 
 
526
 
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
527
 
 
528
 
 
529
 
var oop = require("../lib/oop");
530
 
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
531
 
 
532
 
var DocCommentHighlightRules = function() {
533
 
 
534
 
    this.$rules = {
535
 
        "start" : [ {
536
 
            token : "comment.doc.tag",
537
 
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
538
 
        }, {
539
 
            token : "comment.doc",
540
 
            merge : true,
541
 
            regex : "\\s+"
542
 
        }, {
543
 
            token : "comment.doc",
544
 
            merge : true,
545
 
            regex : "TODO"
546
 
        }, {
547
 
            token : "comment.doc",
548
 
            merge : true,
549
 
            regex : "[^@\\*]+"
550
 
        }, {
551
 
            token : "comment.doc",
552
 
            merge : true,
553
 
            regex : "."
554
 
        }]
555
 
    };
556
 
};
557
 
 
558
 
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
559
 
 
560
 
DocCommentHighlightRules.getStartRule = function(start) {
561
 
    return {
562
 
        token : "comment.doc", // doc comment
563
 
        merge : true,
564
 
        regex : "\\/\\*(?=\\*)",
565
 
        next  : start
566
 
    };
567
 
};
568
 
 
569
 
DocCommentHighlightRules.getEndRule = function (start) {
570
 
    return {
571
 
        token : "comment.doc", // closing comment
572
 
        merge : true,
573
 
        regex : "\\*\\/",
574
 
        next  : start
575
 
    };
576
 
};
577
 
 
578
 
 
579
 
exports.DocCommentHighlightRules = DocCommentHighlightRules;
580
 
 
581
 
});
582
 
 
583
 
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
584
 
 
585
 
 
586
 
var Range = require("../range").Range;
587
 
 
588
 
var MatchingBraceOutdent = function() {};
589
 
 
590
 
(function() {
591
 
 
592
 
    this.checkOutdent = function(line, input) {
593
 
        if (! /^\s+$/.test(line))
594
 
            return false;
595
 
 
596
 
        return /^\s*\}/.test(input);
597
 
    };
598
 
 
599
 
    this.autoOutdent = function(doc, row) {
600
 
        var line = doc.getLine(row);
601
 
        var match = line.match(/^(\s*\})/);
602
 
 
603
 
        if (!match) return 0;
604
 
 
605
 
        var column = match[1].length;
606
 
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
607
 
 
608
 
        if (!openBracePos || openBracePos.row == row) return 0;
609
 
 
610
 
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
611
 
        doc.replace(new Range(row, 0, row, column-1), indent);
612
 
    };
613
 
 
614
 
    this.$getIndent = function(line) {
615
 
        var match = line.match(/^(\s+)/);
616
 
        if (match) {
617
 
            return match[1];
618
 
        }
619
 
 
620
 
        return "";
621
 
    };
622
 
 
623
 
}).call(MatchingBraceOutdent.prototype);
624
 
 
625
 
exports.MatchingBraceOutdent = MatchingBraceOutdent;
626
 
});
627
 
 
628
 
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
629
 
 
630
 
 
631
 
var oop = require("../../lib/oop");
632
 
var Behaviour = require("../behaviour").Behaviour;
633
 
var TokenIterator = require("../../token_iterator").TokenIterator;
634
 
var lang = require("../../lib/lang");
635
 
 
636
 
var SAFE_INSERT_IN_TOKENS =
637
 
    ["text", "paren.rparen", "punctuation.operator"];
638
 
var SAFE_INSERT_BEFORE_TOKENS =
639
 
    ["text", "paren.rparen", "punctuation.operator", "comment"];
640
 
 
641
 
 
642
 
var autoInsertedBrackets = 0;
643
 
var autoInsertedRow = -1;
644
 
var autoInsertedLineEnd = "";
645
 
var maybeInsertedBrackets = 0;
646
 
var maybeInsertedRow = -1;
647
 
var maybeInsertedLineStart = "";
648
 
var maybeInsertedLineEnd = "";
649
 
 
650
 
var CstyleBehaviour = function () {
651
 
    
652
 
    CstyleBehaviour.isSaneInsertion = function(editor, session) {
653
 
        var cursor = editor.getCursorPosition();
654
 
        var iterator = new TokenIterator(session, cursor.row, cursor.column);
655
 
        if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
656
 
            var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
657
 
            if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
658
 
                return false;
659
 
        }
660
 
        iterator.stepForward();
661
 
        return iterator.getCurrentTokenRow() !== cursor.row ||
662
 
            this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
663
 
    };
664
 
    
665
 
    CstyleBehaviour.$matchTokenType = function(token, types) {
666
 
        return types.indexOf(token.type || token) > -1;
667
 
    };
668
 
    
669
 
    CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
670
 
        var cursor = editor.getCursorPosition();
671
 
        var line = session.doc.getLine(cursor.row);
672
 
        if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
673
 
            autoInsertedBrackets = 0;
674
 
        autoInsertedRow = cursor.row;
675
 
        autoInsertedLineEnd = bracket + line.substr(cursor.column);
676
 
        autoInsertedBrackets++;
677
 
    };
678
 
    
679
 
    CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
680
 
        var cursor = editor.getCursorPosition();
681
 
        var line = session.doc.getLine(cursor.row);
682
 
        if (!this.isMaybeInsertedClosing(cursor, line))
683
 
            maybeInsertedBrackets = 0;
684
 
        maybeInsertedRow = cursor.row;
685
 
        maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
686
 
        maybeInsertedLineEnd = line.substr(cursor.column);
687
 
        maybeInsertedBrackets++;
688
 
    };
689
 
    
690
 
    CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
691
 
        return autoInsertedBrackets > 0 &&
692
 
            cursor.row === autoInsertedRow &&
693
 
            bracket === autoInsertedLineEnd[0] &&
694
 
            line.substr(cursor.column) === autoInsertedLineEnd;
695
 
    };
696
 
    
697
 
    CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
698
 
        return maybeInsertedBrackets > 0 &&
699
 
            cursor.row === maybeInsertedRow &&
700
 
            line.substr(cursor.column) === maybeInsertedLineEnd &&
701
 
            line.substr(0, cursor.column) == maybeInsertedLineStart;
702
 
    };
703
 
    
704
 
    CstyleBehaviour.popAutoInsertedClosing = function() {
705
 
        autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
706
 
        autoInsertedBrackets--;
707
 
    };
708
 
    
709
 
    CstyleBehaviour.clearMaybeInsertedClosing = function() {
710
 
        maybeInsertedBrackets = 0;
711
 
        maybeInsertedRow = -1;
712
 
    };
713
 
 
714
 
    this.add("braces", "insertion", function (state, action, editor, session, text) {
715
 
        var cursor = editor.getCursorPosition();
716
 
        var line = session.doc.getLine(cursor.row);
717
 
        if (text == '{') {
718
 
            var selection = editor.getSelectionRange();
719
 
            var selected = session.doc.getTextRange(selection);
720
 
            if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
721
 
                return {
722
 
                    text: '{' + selected + '}',
723
 
                    selection: false
724
 
                };
725
 
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
726
 
                if (/[\]\}\)]/.test(line[cursor.column])) {
727
 
                    CstyleBehaviour.recordAutoInsert(editor, session, "}");
728
 
                    return {
729
 
                        text: '{}',
730
 
                        selection: [1, 1]
731
 
                    };
732
 
                } else {
733
 
                    CstyleBehaviour.recordMaybeInsert(editor, session, "{");
734
 
                    return {
735
 
                        text: '{',
736
 
                        selection: [1, 1]
737
 
                    };
738
 
                }
739
 
            }
740
 
        } else if (text == '}') {
741
 
            var rightChar = line.substring(cursor.column, cursor.column + 1);
742
 
            if (rightChar == '}') {
743
 
                var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
744
 
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
745
 
                    CstyleBehaviour.popAutoInsertedClosing();
746
 
                    return {
747
 
                        text: '',
748
 
                        selection: [1, 1]
749
 
                    };
750
 
                }
751
 
            }
752
 
        } else if (text == "\n" || text == "\r\n") {
753
 
            var closing = "";
754
 
            if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
755
 
                closing = lang.stringRepeat("}", maybeInsertedBrackets);
756
 
                CstyleBehaviour.clearMaybeInsertedClosing();
757
 
            }
758
 
            var rightChar = line.substring(cursor.column, cursor.column + 1);
759
 
            if (rightChar == '}' || closing !== "") {
760
 
                var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
761
 
                if (!openBracePos)
762
 
                     return null;
763
 
 
764
 
                var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
765
 
                var next_indent = this.$getIndent(line);
766
 
 
767
 
                return {
768
 
                    text: '\n' + indent + '\n' + next_indent + closing,
769
 
                    selection: [1, indent.length, 1, indent.length]
770
 
                };
771
 
            }
772
 
        }
773
 
    });
774
 
 
775
 
    this.add("braces", "deletion", function (state, action, editor, session, range) {
776
 
        var selected = session.doc.getTextRange(range);
777
 
        if (!range.isMultiLine() && selected == '{') {
778
 
            var line = session.doc.getLine(range.start.row);
779
 
            var rightChar = line.substring(range.end.column, range.end.column + 1);
780
 
            if (rightChar == '}') {
781
 
                range.end.column++;
782
 
                return range;
783
 
            } else {
784
 
                maybeInsertedBrackets--;
785
 
            }
786
 
        }
787
 
    });
788
 
 
789
 
    this.add("parens", "insertion", function (state, action, editor, session, text) {
790
 
        if (text == '(') {
791
 
            var selection = editor.getSelectionRange();
792
 
            var selected = session.doc.getTextRange(selection);
793
 
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
794
 
                return {
795
 
                    text: '(' + selected + ')',
796
 
                    selection: false
797
 
                };
798
 
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
799
 
                CstyleBehaviour.recordAutoInsert(editor, session, ")");
800
 
                return {
801
 
                    text: '()',
802
 
                    selection: [1, 1]
803
 
                };
804
 
            }
805
 
        } else if (text == ')') {
806
 
            var cursor = editor.getCursorPosition();
807
 
            var line = session.doc.getLine(cursor.row);
808
 
            var rightChar = line.substring(cursor.column, cursor.column + 1);
809
 
            if (rightChar == ')') {
810
 
                var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
811
 
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
812
 
                    CstyleBehaviour.popAutoInsertedClosing();
813
 
                    return {
814
 
                        text: '',
815
 
                        selection: [1, 1]
816
 
                    };
817
 
                }
818
 
            }
819
 
        }
820
 
    });
821
 
 
822
 
    this.add("parens", "deletion", function (state, action, editor, session, range) {
823
 
        var selected = session.doc.getTextRange(range);
824
 
        if (!range.isMultiLine() && selected == '(') {
825
 
            var line = session.doc.getLine(range.start.row);
826
 
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
827
 
            if (rightChar == ')') {
828
 
                range.end.column++;
829
 
                return range;
830
 
            }
831
 
        }
832
 
    });
833
 
 
834
 
    this.add("brackets", "insertion", function (state, action, editor, session, text) {
835
 
        if (text == '[') {
836
 
            var selection = editor.getSelectionRange();
837
 
            var selected = session.doc.getTextRange(selection);
838
 
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
839
 
                return {
840
 
                    text: '[' + selected + ']',
841
 
                    selection: false
842
 
                };
843
 
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
844
 
                CstyleBehaviour.recordAutoInsert(editor, session, "]");
845
 
                return {
846
 
                    text: '[]',
847
 
                    selection: [1, 1]
848
 
                };
849
 
            }
850
 
        } else if (text == ']') {
851
 
            var cursor = editor.getCursorPosition();
852
 
            var line = session.doc.getLine(cursor.row);
853
 
            var rightChar = line.substring(cursor.column, cursor.column + 1);
854
 
            if (rightChar == ']') {
855
 
                var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
856
 
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
857
 
                    CstyleBehaviour.popAutoInsertedClosing();
858
 
                    return {
859
 
                        text: '',
860
 
                        selection: [1, 1]
861
 
                    };
862
 
                }
863
 
            }
864
 
        }
865
 
    });
866
 
 
867
 
    this.add("brackets", "deletion", function (state, action, editor, session, range) {
868
 
        var selected = session.doc.getTextRange(range);
869
 
        if (!range.isMultiLine() && selected == '[') {
870
 
            var line = session.doc.getLine(range.start.row);
871
 
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
872
 
            if (rightChar == ']') {
873
 
                range.end.column++;
874
 
                return range;
875
 
            }
876
 
        }
877
 
    });
878
 
 
879
 
    this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
880
 
        if (text == '"' || text == "'") {
881
 
            var quote = text;
882
 
            var selection = editor.getSelectionRange();
883
 
            var selected = session.doc.getTextRange(selection);
884
 
            if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
885
 
                return {
886
 
                    text: quote + selected + quote,
887
 
                    selection: false
888
 
                };
889
 
            } else {
890
 
                var cursor = editor.getCursorPosition();
891
 
                var line = session.doc.getLine(cursor.row);
892
 
                var leftChar = line.substring(cursor.column-1, cursor.column);
893
 
                if (leftChar == '\\') {
894
 
                    return null;
895
 
                }
896
 
                var tokens = session.getTokens(selection.start.row);
897
 
                var col = 0, token;
898
 
                var quotepos = -1; // Track whether we're inside an open quote.
899
 
 
900
 
                for (var x = 0; x < tokens.length; x++) {
901
 
                    token = tokens[x];
902
 
                    if (token.type == "string") {
903
 
                      quotepos = -1;
904
 
                    } else if (quotepos < 0) {
905
 
                      quotepos = token.value.indexOf(quote);
906
 
                    }
907
 
                    if ((token.value.length + col) > selection.start.column) {
908
 
                        break;
909
 
                    }
910
 
                    col += tokens[x].value.length;
911
 
                }
912
 
                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)))) {
913
 
                    if (!CstyleBehaviour.isSaneInsertion(editor, session))
914
 
                        return;
915
 
                    return {
916
 
                        text: quote + quote,
917
 
                        selection: [1,1]
918
 
                    };
919
 
                } else if (token && token.type === "string") {
920
 
                    var rightChar = line.substring(cursor.column, cursor.column + 1);
921
 
                    if (rightChar == quote) {
922
 
                        return {
923
 
                            text: '',
924
 
                            selection: [1, 1]
925
 
                        };
926
 
                    }
927
 
                }
928
 
            }
929
 
        }
930
 
    });
931
 
 
932
 
    this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
933
 
        var selected = session.doc.getTextRange(range);
934
 
        if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
935
 
            var line = session.doc.getLine(range.start.row);
936
 
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
937
 
            if (rightChar == '"') {
938
 
                range.end.column++;
939
 
                return range;
940
 
            }
941
 
        }
942
 
    });
943
 
 
944
 
};
945
 
 
946
 
oop.inherits(CstyleBehaviour, Behaviour);
947
 
 
948
 
exports.CstyleBehaviour = CstyleBehaviour;
949
 
});
950
 
 
951
 
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
952
 
 
953
 
 
954
 
var oop = require("../../lib/oop");
955
 
var Range = require("../../range").Range;
956
 
var BaseFoldMode = require("./fold_mode").FoldMode;
957
 
 
958
 
var FoldMode = exports.FoldMode = function() {};
959
 
oop.inherits(FoldMode, BaseFoldMode);
960
 
 
961
 
(function() {
962
 
 
963
 
    this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
964
 
    this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
965
 
 
966
 
    this.getFoldWidgetRange = function(session, foldStyle, row) {
967
 
        var line = session.getLine(row);
968
 
        var match = line.match(this.foldingStartMarker);
969
 
        if (match) {
970
 
            var i = match.index;
971
 
 
972
 
            if (match[1])
973
 
                return this.openingBracketBlock(session, match[1], row, i);
974
 
 
975
 
            return session.getCommentFoldRange(row, i + match[0].length, 1);
976
 
        }
977
 
 
978
 
        if (foldStyle !== "markbeginend")
979
 
            return;
980
 
 
981
 
        var match = line.match(this.foldingStopMarker);
982
 
        if (match) {
983
 
            var i = match.index + match[0].length;
984
 
 
985
 
            if (match[1])
986
 
                return this.closingBracketBlock(session, match[1], row, i);
987
 
 
988
 
            return session.getCommentFoldRange(row, i, -1);
989
 
        }
990
 
    };
991
 
 
992
 
}).call(FoldMode.prototype);
993
 
 
994
 
});
995
 
 
996
 
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/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
997
 
 
998
 
 
999
 
var oop = require("../lib/oop");
1000
 
var TextMode = require("./text").Mode;
1001
 
var Tokenizer = require("../tokenizer").Tokenizer;
1002
 
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1003
 
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1004
 
var WorkerClient = require("../worker/worker_client").WorkerClient;
1005
 
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
1006
 
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1007
 
 
1008
 
var Mode = function() {
1009
 
    this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i");
1010
 
    this.$outdent = new MatchingBraceOutdent();
1011
 
    this.$behaviour = new CstyleBehaviour();
1012
 
    this.foldingRules = new CStyleFoldMode();
1013
 
};
1014
 
oop.inherits(Mode, TextMode);
1015
 
 
1016
 
(function() {
1017
 
 
1018
 
    this.foldingRules = "cStyle";
1019
 
 
1020
 
    this.getNextLineIndent = function(state, line, tab) {
1021
 
        var indent = this.$getIndent(line);
1022
 
        var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
1023
 
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
1024
 
            return indent;
1025
 
        }
1026
 
 
1027
 
        var match = line.match(/^.*\{\s*$/);
1028
 
        if (match) {
1029
 
            indent += tab;
1030
 
        }
1031
 
 
1032
 
        return indent;
1033
 
    };
1034
 
 
1035
 
    this.checkOutdent = function(state, line, input) {
1036
 
        return this.$outdent.checkOutdent(line, input);
1037
 
    };
1038
 
 
1039
 
    this.autoOutdent = function(state, doc, row) {
1040
 
        this.$outdent.autoOutdent(doc, row);
1041
 
    };
1042
 
 
1043
 
    this.createWorker = function(session) {
1044
 
        var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
1045
 
        worker.attachToDocument(session.getDocument());
1046
 
 
1047
 
        worker.on("csslint", function(e) {
1048
 
            session.setAnnotations(e.data);
1049
 
        });
1050
 
 
1051
 
        worker.on("terminate", function() {
1052
 
            session.clearAnnotations();
1053
 
        });
1054
 
 
1055
 
        return worker;
1056
 
    };
1057
 
 
1058
 
}).call(Mode.prototype);
1059
 
 
1060
 
exports.Mode = Mode;
1061
 
 
1062
 
});
1063
 
 
1064
 
define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1065
 
 
1066
 
 
1067
 
var oop = require("../lib/oop");
1068
 
var lang = require("../lib/lang");
1069
 
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1070
 
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";
1071
 
var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
1072
 
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";
1073
 
var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
1074
 
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";
1075
 
 
1076
 
var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
1077
 
var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
1078
 
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";
1079
 
 
1080
 
var CssHighlightRules = function() {
1081
 
 
1082
 
    var keywordMapper = this.createKeywordMapper({
1083
 
        "support.function": supportFunction,
1084
 
        "support.constant": supportConstant,
1085
 
        "support.type": supportType,
1086
 
        "support.constant.color": supportConstantColor,
1087
 
        "support.constant.fonts": supportConstantFonts
1088
 
    }, "text", true);
1089
 
 
1090
 
    var base_ruleset = [
1091
 
        {
1092
 
            token : "comment", // multi line comment
1093
 
            merge : true,
1094
 
            regex : "\\/\\*",
1095
 
            next : "ruleset_comment"
1096
 
        }, {
1097
 
            token : "string", // single line
1098
 
            regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
1099
 
        }, {
1100
 
            token : "string", // single line
1101
 
            regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
1102
 
        }, {
1103
 
            token : ["constant.numeric", "keyword"],
1104
 
            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|%)"
1105
 
        }, {
1106
 
            token : "constant.numeric",
1107
 
            regex : numRe
1108
 
        }, {
1109
 
            token : "constant.numeric",  // hex6 color
1110
 
            regex : "#[a-f0-9]{6}"
1111
 
        }, {
1112
 
            token : "constant.numeric", // hex3 color
1113
 
            regex : "#[a-f0-9]{3}"
1114
 
        }, {
1115
 
            token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
1116
 
            regex : pseudoElements
1117
 
        }, {
1118
 
            token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
1119
 
            regex : pseudoClasses
1120
 
        }, {
1121
 
            token : keywordMapper,
1122
 
            regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
1123
 
        }
1124
 
      ];
1125
 
 
1126
 
    var ruleset = lang.copyArray(base_ruleset);
1127
 
    ruleset.unshift({
1128
 
        token : "paren.rparen",
1129
 
        regex : "\\}",
1130
 
        next:   "start"
1131
 
    });
1132
 
 
1133
 
    var media_ruleset = lang.copyArray( base_ruleset );
1134
 
    media_ruleset.unshift({
1135
 
        token : "paren.rparen",
1136
 
        regex : "\\}",
1137
 
        next:   "media"
1138
 
    });
1139
 
 
1140
 
    var base_comment = [{
1141
 
          token : "comment", // comment spanning whole line
1142
 
          merge : true,
1143
 
          regex : ".+"
1144
 
    }];
1145
 
 
1146
 
    var comment = lang.copyArray(base_comment);
1147
 
    comment.unshift({
1148
 
          token : "comment", // closing comment
1149
 
          regex : ".*?\\*\\/",
1150
 
          next : "start"
1151
 
    });
1152
 
 
1153
 
    var media_comment = lang.copyArray(base_comment);
1154
 
    media_comment.unshift({
1155
 
          token : "comment", // closing comment
1156
 
          regex : ".*?\\*\\/",
1157
 
          next : "media"
1158
 
    });
1159
 
 
1160
 
    var ruleset_comment = lang.copyArray(base_comment);
1161
 
    ruleset_comment.unshift({
1162
 
          token : "comment", // closing comment
1163
 
          regex : ".*?\\*\\/",
1164
 
          next : "ruleset"
1165
 
    });
1166
 
 
1167
 
    this.$rules = {
1168
 
        "start" : [{
1169
 
            token : "comment", // multi line comment
1170
 
            merge : true,
1171
 
            regex : "\\/\\*",
1172
 
            next : "comment"
1173
 
        }, {
1174
 
            token: "paren.lparen",
1175
 
            regex: "\\{",
1176
 
            next:  "ruleset"
1177
 
        }, {
1178
 
            token: "string",
1179
 
            regex: "@.*?{",
1180
 
            next:  "media"
1181
 
        },{
1182
 
            token: "keyword",
1183
 
            regex: "#[a-z0-9-_]+"
1184
 
        },{
1185
 
            token: "variable",
1186
 
            regex: "\\.[a-z0-9-_]+"
1187
 
        },{
1188
 
            token: "string",
1189
 
            regex: ":[a-z0-9-_]+"
1190
 
        },{
1191
 
            token: "constant",
1192
 
            regex: "[a-z0-9-_]+"
1193
 
        }],
1194
 
 
1195
 
        "media" : [ {
1196
 
            token : "comment", // multi line comment
1197
 
            merge : true,
1198
 
            regex : "\\/\\*",
1199
 
            next : "media_comment"
1200
 
        }, {
1201
 
            token: "paren.lparen",
1202
 
            regex: "\\{",
1203
 
            next:  "media_ruleset"
1204
 
        },{
1205
 
            token: "string",
1206
 
            regex: "\\}",
1207
 
            next:  "start"
1208
 
        },{
1209
 
            token: "keyword",
1210
 
            regex: "#[a-z0-9-_]+"
1211
 
        },{
1212
 
            token: "variable",
1213
 
            regex: "\\.[a-z0-9-_]+"
1214
 
        },{
1215
 
            token: "string",
1216
 
            regex: ":[a-z0-9-_]+"
1217
 
        },{
1218
 
            token: "constant",
1219
 
            regex: "[a-z0-9-_]+"
1220
 
        }],
1221
 
 
1222
 
        "comment" : comment,
1223
 
 
1224
 
        "ruleset" : ruleset,
1225
 
        "ruleset_comment" : ruleset_comment,
1226
 
 
1227
 
        "media_ruleset" : media_ruleset,
1228
 
        "media_comment" : media_comment
1229
 
    };
1230
 
};
1231
 
 
1232
 
oop.inherits(CssHighlightRules, TextHighlightRules);
1233
 
 
1234
 
exports.CssHighlightRules = CssHighlightRules;
1235
 
 
1236
 
});
1237
 
 
1238
 
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) {
1239
 
 
1240
 
 
1241
 
var oop = require("../lib/oop");
1242
 
var lang = require("../lib/lang");
1243
 
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1244
 
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1245
 
var xmlUtil = require("./xml_util");
1246
 
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1247
 
 
1248
 
var tagMap = lang.createMap({
1249
 
    a           : 'anchor',
1250
 
    button          : 'form',
1251
 
    form        : 'form',
1252
 
    img         : 'image',
1253
 
    input       : 'form',
1254
 
    label       : 'form',
1255
 
    script      : 'script',
1256
 
    select      : 'form',
1257
 
    textarea    : 'form',
1258
 
    style       : 'style',
1259
 
    table       : 'table',
1260
 
    tbody       : 'table',
1261
 
    td          : 'table',
1262
 
    tfoot       : 'table',
1263
 
    th          : 'table',
1264
 
    tr          : 'table'
1265
 
});
1266
 
 
1267
 
var HtmlHighlightRules = function() {
1268
 
    this.$rules = {
1269
 
        start : [{
1270
 
            token : "text",
1271
 
            merge : true,
1272
 
            regex : "<\\!\\[CDATA\\[",
1273
 
            next : "cdata"
1274
 
        }, {
1275
 
            token : "xml-pe",
1276
 
            regex : "<\\?.*?\\?>"
1277
 
        }, {
1278
 
            token : "comment",
1279
 
            merge : true,
1280
 
            regex : "<\\!--",
1281
 
            next : "comment"
1282
 
        }, {
1283
 
            token : "xml-pe",
1284
 
            regex : "<\\!.*?>"
1285
 
        }, {
1286
 
            token : "meta.tag",
1287
 
            regex : "<(?=script\\b)",
1288
 
            next : "script"
1289
 
        }, {
1290
 
            token : "meta.tag",
1291
 
            regex : "<(?=style\\b)",
1292
 
            next : "style"
1293
 
        }, {
1294
 
            token : "meta.tag", // opening tag
1295
 
            regex : "<\\/?",
1296
 
            next : "tag"
1297
 
        }, {
1298
 
            token : "text",
1299
 
            regex : "\\s+"
1300
 
        }, {
1301
 
            token : "constant.character.entity",
1302
 
            regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1303
 
        }, {
1304
 
            token : "text",
1305
 
            regex : "[^<]+"
1306
 
        } ],
1307
 
    
1308
 
        cdata : [ {
1309
 
            token : "text",
1310
 
            regex : "\\]\\]>",
1311
 
            next : "start"
1312
 
        }, {
1313
 
            token : "text",
1314
 
            merge : true,
1315
 
            regex : "\\s+"
1316
 
        }, {
1317
 
            token : "text",
1318
 
            merge : true,
1319
 
            regex : ".+"
1320
 
        } ],
1321
 
 
1322
 
        comment : [ {
1323
 
            token : "comment",
1324
 
            regex : ".*?-->",
1325
 
            next : "start"
1326
 
        }, {
1327
 
            token : "comment",
1328
 
            merge : true,
1329
 
            regex : ".+"
1330
 
        } ]
1331
 
    };
1332
 
    
1333
 
    xmlUtil.tag(this.$rules, "tag", "start", tagMap);
1334
 
    xmlUtil.tag(this.$rules, "style", "css-start", tagMap);
1335
 
    xmlUtil.tag(this.$rules, "script", "js-start", tagMap);
1336
 
    
1337
 
    this.embedRules(JavaScriptHighlightRules, "js-", [{
1338
 
        token: "comment",
1339
 
        regex: "\\/\\/.*(?=<\\/script>)",
1340
 
        next: "tag"
1341
 
    }, {
1342
 
        token: "meta.tag",
1343
 
        regex: "<\\/(?=script)",
1344
 
        next: "tag"
1345
 
    }]);
1346
 
    
1347
 
    this.embedRules(CssHighlightRules, "css-", [{
1348
 
        token: "meta.tag",
1349
 
        regex: "<\\/(?=style)",
1350
 
        next: "tag"
1351
 
    }]);
1352
 
};
1353
 
 
1354
 
oop.inherits(HtmlHighlightRules, TextHighlightRules);
1355
 
 
1356
 
exports.HtmlHighlightRules = HtmlHighlightRules;
1357
 
});
1358
 
 
1359
 
define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
1360
 
 
1361
 
 
1362
 
function string(state) {
1363
 
    return [{
1364
 
        token : "string",
1365
 
        regex : '".*?"'
1366
 
    }, {
1367
 
        token : "string", // multi line string start
1368
 
        merge : true,
1369
 
        regex : '["].*',
1370
 
        next : state + "_qqstring"
1371
 
    }, {
1372
 
        token : "string",
1373
 
        regex : "'.*?'"
1374
 
    }, {
1375
 
        token : "string", // multi line string start
1376
 
        merge : true,
1377
 
        regex : "['].*",
1378
 
        next : state + "_qstring"
1379
 
    }];
1380
 
}
1381
 
 
1382
 
function multiLineString(quote, state) {
1383
 
    return [{
1384
 
        token : "string",
1385
 
        merge : true,
1386
 
        regex : ".*?" + quote,
1387
 
        next : state
1388
 
    }, {
1389
 
        token : "string",
1390
 
        merge : true,
1391
 
        regex : '.+'
1392
 
    }];
1393
 
}
1394
 
 
1395
 
exports.tag = function(states, name, nextState, tagMap) {
1396
 
    states[name] = [{
1397
 
        token : "text",
1398
 
        regex : "\\s+"
1399
 
    }, {
1400
 
        
1401
 
    token : !tagMap ? "meta.tag.tag-name" : function(value) {
1402
 
            if (tagMap[value])
1403
 
                return "meta.tag.tag-name." + tagMap[value];
1404
 
            else
1405
 
                return "meta.tag.tag-name";
1406
 
        },
1407
 
        merge : true,
1408
 
        regex : "[-_a-zA-Z0-9:]+",
1409
 
        next : name + "_embed_attribute_list" 
1410
 
    }, {
1411
 
        token: "empty",
1412
 
        regex: "",
1413
 
        next : name + "_embed_attribute_list"
1414
 
    }];
1415
 
 
1416
 
    states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
1417
 
    states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
1418
 
    
1419
 
    states[name + "_embed_attribute_list"] = [{
1420
 
        token : "meta.tag",
1421
 
        merge : true,
1422
 
        regex : "\/?>",
1423
 
        next : nextState
1424
 
    }, {
1425
 
        token : "keyword.operator",
1426
 
        regex : "="
1427
 
    }, {
1428
 
        token : "entity.other.attribute-name",
1429
 
        regex : "[-_a-zA-Z0-9:]+"
1430
 
    }, {
1431
 
        token : "constant.numeric", // float
1432
 
        regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
1433
 
    }, {
1434
 
        token : "text",
1435
 
        regex : "\\s+"
1436
 
    }].concat(string(name));
1437
 
};
1438
 
 
1439
 
});
1440
 
 
1441
 
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) {
1442
 
 
1443
 
 
1444
 
var oop = require("../../lib/oop");
1445
 
var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
1446
 
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1447
 
var TokenIterator = require("../../token_iterator").TokenIterator;
1448
 
var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
1449
 
 
1450
 
function hasType(token, type) {
1451
 
    var hasType = true;
1452
 
    var typeList = token.type.split('.');
1453
 
    var needleList = type.split('.');
1454
 
    needleList.forEach(function(needle){
1455
 
        if (typeList.indexOf(needle) == -1) {
1456
 
            hasType = false;
1457
 
            return false;
1458
 
        }
1459
 
    });
1460
 
    return hasType;
1461
 
}
1462
 
 
1463
 
var HtmlBehaviour = function () {
1464
 
 
1465
 
    this.inherit(XmlBehaviour); // Get xml behaviour
1466
 
    
1467
 
    this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1468
 
        if (text == '>') {
1469
 
            var position = editor.getCursorPosition();
1470
 
            var iterator = new TokenIterator(session, position.row, position.column);
1471
 
            var token = iterator.getCurrentToken();
1472
 
            var atCursor = false;
1473
 
            if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1474
 
                do {
1475
 
                    token = iterator.stepBackward();
1476
 
                } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1477
 
            } else {
1478
 
                atCursor = true;
1479
 
            }
1480
 
            if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1481
 
                return
1482
 
            }
1483
 
            var element = token.value;
1484
 
            if (atCursor){
1485
 
                var element = element.substring(0, position.column - token.start);
1486
 
            }
1487
 
            if (voidElements.indexOf(element) !== -1){
1488
 
                return;
1489
 
            }
1490
 
            return {
1491
 
               text: '>' + '</' + element + '>',
1492
 
               selection: [1, 1]
1493
 
            }
1494
 
        }
1495
 
    });
1496
 
}
1497
 
oop.inherits(HtmlBehaviour, XmlBehaviour);
1498
 
 
1499
 
exports.HtmlBehaviour = HtmlBehaviour;
1500
 
});
1501
 
 
1502
 
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) {
1503
 
 
1504
 
 
1505
 
var oop = require("../../lib/oop");
1506
 
var Behaviour = require("../behaviour").Behaviour;
1507
 
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1508
 
var TokenIterator = require("../../token_iterator").TokenIterator;
1509
 
 
1510
 
function hasType(token, type) {
1511
 
    var hasType = true;
1512
 
    var typeList = token.type.split('.');
1513
 
    var needleList = type.split('.');
1514
 
    needleList.forEach(function(needle){
1515
 
        if (typeList.indexOf(needle) == -1) {
1516
 
            hasType = false;
1517
 
            return false;
1518
 
        }
1519
 
    });
1520
 
    return hasType;
1521
 
}
1522
 
 
1523
 
var XmlBehaviour = function () {
1524
 
    
1525
 
    this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
1526
 
    
1527
 
    this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1528
 
        if (text == '>') {
1529
 
            var position = editor.getCursorPosition();
1530
 
            var iterator = new TokenIterator(session, position.row, position.column);
1531
 
            var token = iterator.getCurrentToken();
1532
 
            var atCursor = false;
1533
 
            if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1534
 
                do {
1535
 
                    token = iterator.stepBackward();
1536
 
                } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1537
 
            } else {
1538
 
                atCursor = true;
1539
 
            }
1540
 
            if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1541
 
                return
1542
 
            }
1543
 
            var tag = token.value;
1544
 
            if (atCursor){
1545
 
                var tag = tag.substring(0, position.column - token.start);
1546
 
            }
1547
 
 
1548
 
            return {
1549
 
               text: '>' + '</' + tag + '>',
1550
 
               selection: [1, 1]
1551
 
            }
1552
 
        }
1553
 
    });
1554
 
 
1555
 
    this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
1556
 
        if (text == "\n") {
1557
 
            var cursor = editor.getCursorPosition();
1558
 
            var line = session.doc.getLine(cursor.row);
1559
 
            var rightChars = line.substring(cursor.column, cursor.column + 2);
1560
 
            if (rightChars == '</') {
1561
 
                var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
1562
 
                var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
1563
 
 
1564
 
                return {
1565
 
                    text: '\n' + indent + '\n' + next_indent,
1566
 
                    selection: [1, indent.length, 1, indent.length]
1567
 
                }
1568
 
            }
1569
 
        }
1570
 
    });
1571
 
    
1572
 
}
1573
 
oop.inherits(XmlBehaviour, Behaviour);
1574
 
 
1575
 
exports.XmlBehaviour = XmlBehaviour;
1576
 
});
1577
 
 
1578
 
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) {
1579
 
 
1580
 
 
1581
 
var oop = require("../../lib/oop");
1582
 
var MixedFoldMode = require("./mixed").FoldMode;
1583
 
var XmlFoldMode = require("./xml").FoldMode;
1584
 
var CStyleFoldMode = require("./cstyle").FoldMode;
1585
 
 
1586
 
var FoldMode = exports.FoldMode = function() {
1587
 
    MixedFoldMode.call(this, new XmlFoldMode({
1588
 
        "area": 1,
1589
 
        "base": 1,
1590
 
        "br": 1,
1591
 
        "col": 1,
1592
 
        "command": 1,
1593
 
        "embed": 1,
1594
 
        "hr": 1,
1595
 
        "img": 1,
1596
 
        "input": 1,
1597
 
        "keygen": 1,
1598
 
        "link": 1,
1599
 
        "meta": 1,
1600
 
        "param": 1,
1601
 
        "source": 1,
1602
 
        "track": 1,
1603
 
        "wbr": 1,
1604
 
        "li": 1,
1605
 
        "dt": 1,
1606
 
        "dd": 1,
1607
 
        "p": 1,
1608
 
        "rt": 1,
1609
 
        "rp": 1,
1610
 
        "optgroup": 1,
1611
 
        "option": 1,
1612
 
        "colgroup": 1,
1613
 
        "td": 1,
1614
 
        "th": 1
1615
 
    }), {
1616
 
        "js-": new CStyleFoldMode(),
1617
 
        "css-": new CStyleFoldMode()
1618
 
    });
1619
 
};
1620
 
 
1621
 
oop.inherits(FoldMode, MixedFoldMode);
1622
 
 
1623
 
});
1624
 
 
1625
 
define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1626
 
 
1627
 
 
1628
 
var oop = require("../../lib/oop");
1629
 
var BaseFoldMode = require("./fold_mode").FoldMode;
1630
 
 
1631
 
var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
1632
 
    this.defaultMode = defaultMode;
1633
 
    this.subModes = subModes;
1634
 
};
1635
 
oop.inherits(FoldMode, BaseFoldMode);
1636
 
 
1637
 
(function() {
1638
 
 
1639
 
 
1640
 
    this.$getMode = function(state) {
1641
 
        for (var key in this.subModes) {
1642
 
            if (state.indexOf(key) === 0)
1643
 
                return this.subModes[key];
1644
 
        }
1645
 
        return null;
1646
 
    };
1647
 
    
1648
 
    this.$tryMode = function(state, session, foldStyle, row) {
1649
 
        var mode = this.$getMode(state);
1650
 
        return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1651
 
    };
1652
 
 
1653
 
    this.getFoldWidget = function(session, foldStyle, row) {
1654
 
        return (
1655
 
            this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
1656
 
            this.$tryMode(session.getState(row), session, foldStyle, row) ||
1657
 
            this.defaultMode.getFoldWidget(session, foldStyle, row)
1658
 
        );
1659
 
    };
1660
 
 
1661
 
    this.getFoldWidgetRange = function(session, foldStyle, row) {
1662
 
        var mode = this.$getMode(session.getState(row-1));
1663
 
        
1664
 
        if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1665
 
            mode = this.$getMode(session.getState(row));
1666
 
        
1667
 
        if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1668
 
            mode = this.defaultMode;
1669
 
        
1670
 
        return mode.getFoldWidgetRange(session, foldStyle, row);
1671
 
    };
1672
 
 
1673
 
}).call(FoldMode.prototype);
1674
 
 
1675
 
});
1676
 
 
1677
 
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) {
1678
 
 
1679
 
 
1680
 
var oop = require("../../lib/oop");
1681
 
var lang = require("../../lib/lang");
1682
 
var Range = require("../../range").Range;
1683
 
var BaseFoldMode = require("./fold_mode").FoldMode;
1684
 
var TokenIterator = require("../../token_iterator").TokenIterator;
1685
 
 
1686
 
var FoldMode = exports.FoldMode = function(voidElements) {
1687
 
    BaseFoldMode.call(this);
1688
 
    this.voidElements = voidElements || {};
1689
 
};
1690
 
oop.inherits(FoldMode, BaseFoldMode);
1691
 
 
1692
 
(function() {
1693
 
 
1694
 
    this.getFoldWidget = function(session, foldStyle, row) {
1695
 
        var tag = this._getFirstTagInLine(session, row);
1696
 
 
1697
 
        if (tag.closing)
1698
 
            return foldStyle == "markbeginend" ? "end" : "";
1699
 
 
1700
 
        if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
1701
 
            return "";
1702
 
 
1703
 
        if (tag.selfClosing)
1704
 
            return "";
1705
 
 
1706
 
        if (tag.value.indexOf("/" + tag.tagName) !== -1)
1707
 
            return "";
1708
 
 
1709
 
        return "start";
1710
 
    };
1711
 
    
1712
 
    this._getFirstTagInLine = function(session, row) {
1713
 
        var tokens = session.getTokens(row);
1714
 
        var value = "";
1715
 
        for (var i = 0; i < tokens.length; i++) {
1716
 
            var token = tokens[i];
1717
 
            if (token.type.indexOf("meta.tag") === 0)
1718
 
                value += token.value;
1719
 
            else
1720
 
                value += lang.stringRepeat(" ", token.value.length);
1721
 
        }
1722
 
        
1723
 
        return this._parseTag(value);
1724
 
    };
1725
 
 
1726
 
    this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
1727
 
    this._parseTag = function(tag) {
1728
 
        
1729
 
        var match = this.tagRe.exec(tag);
1730
 
        var column = this.tagRe.lastIndex || 0;
1731
 
        this.tagRe.lastIndex = 0;
1732
 
 
1733
 
        return {
1734
 
            value: tag,
1735
 
            match: match ? match[2] : "",
1736
 
            closing: match ? !!match[3] : false,
1737
 
            selfClosing: match ? !!match[5] || match[2] == "/>" : false,
1738
 
            tagName: match ? match[4] : "",
1739
 
            column: match[1] ? column + match[1].length : column
1740
 
        };
1741
 
    };
1742
 
    this._readTagForward = function(iterator) {
1743
 
        var token = iterator.getCurrentToken();
1744
 
        if (!token)
1745
 
            return null;
1746
 
            
1747
 
        var value = "";
1748
 
        var start;
1749
 
        
1750
 
        do {
1751
 
            if (token.type.indexOf("meta.tag") === 0) {
1752
 
                if (!start) {
1753
 
                    var start = {
1754
 
                        row: iterator.getCurrentTokenRow(),
1755
 
                        column: iterator.getCurrentTokenColumn()
1756
 
                    };
1757
 
                }
1758
 
                value += token.value;
1759
 
                if (value.indexOf(">") !== -1) {
1760
 
                    var tag = this._parseTag(value);
1761
 
                    tag.start = start;
1762
 
                    tag.end = {
1763
 
                        row: iterator.getCurrentTokenRow(),
1764
 
                        column: iterator.getCurrentTokenColumn() + token.value.length
1765
 
                    };
1766
 
                    iterator.stepForward();
1767
 
                    return tag;
1768
 
                }
1769
 
            }
1770
 
        } while(token = iterator.stepForward());
1771
 
        
1772
 
        return null;
1773
 
    };
1774
 
    
1775
 
    this._readTagBackward = function(iterator) {
1776
 
        var token = iterator.getCurrentToken();
1777
 
        if (!token)
1778
 
            return null;
1779
 
            
1780
 
        var value = "";
1781
 
        var end;
1782
 
 
1783
 
        do {
1784
 
            if (token.type.indexOf("meta.tag") === 0) {
1785
 
                if (!end) {
1786
 
                    end = {
1787
 
                        row: iterator.getCurrentTokenRow(),
1788
 
                        column: iterator.getCurrentTokenColumn() + token.value.length
1789
 
                    };
1790
 
                }
1791
 
                value = token.value + value;
1792
 
                if (value.indexOf("<") !== -1) {
1793
 
                    var tag = this._parseTag(value);
1794
 
                    tag.end = end;
1795
 
                    tag.start = {
1796
 
                        row: iterator.getCurrentTokenRow(),
1797
 
                        column: iterator.getCurrentTokenColumn()
1798
 
                    };
1799
 
                    iterator.stepBackward();
1800
 
                    return tag;
1801
 
                }
1802
 
            }
1803
 
        } while(token = iterator.stepBackward());
1804
 
        
1805
 
        return null;
1806
 
    };
1807
 
    
1808
 
    this._pop = function(stack, tag) {
1809
 
        while (stack.length) {
1810
 
            
1811
 
            var top = stack[stack.length-1];
1812
 
            if (!tag || top.tagName == tag.tagName) {
1813
 
                return stack.pop();
1814
 
            }
1815
 
            else if (this.voidElements[tag.tagName]) {
1816
 
                return;
1817
 
            }
1818
 
            else if (this.voidElements[top.tagName]) {
1819
 
                stack.pop();
1820
 
                continue;
1821
 
            } else {
1822
 
                return null;
1823
 
            }
1824
 
        }
1825
 
    };
1826
 
    
1827
 
    this.getFoldWidgetRange = function(session, foldStyle, row) {
1828
 
        var firstTag = this._getFirstTagInLine(session, row);
1829
 
        
1830
 
        if (!firstTag.match)
1831
 
            return null;
1832
 
        
1833
 
        var isBackward = firstTag.closing || firstTag.selfClosing;
1834
 
        var stack = [];
1835
 
        var tag;
1836
 
        
1837
 
        if (!isBackward) {
1838
 
            var iterator = new TokenIterator(session, row, firstTag.column);
1839
 
            var start = {
1840
 
                row: row,
1841
 
                column: firstTag.column + firstTag.tagName.length + 2
1842
 
            };
1843
 
            while (tag = this._readTagForward(iterator)) {
1844
 
                if (tag.selfClosing) {
1845
 
                    if (!stack.length) {
1846
 
                        tag.start.column += tag.tagName.length + 2;
1847
 
                        tag.end.column -= 2;
1848
 
                        return Range.fromPoints(tag.start, tag.end);
1849
 
                    } else
1850
 
                        continue;
1851
 
                }
1852
 
                
1853
 
                if (tag.closing) {
1854
 
                    this._pop(stack, tag);
1855
 
                    if (stack.length == 0)
1856
 
                        return Range.fromPoints(start, tag.start);
1857
 
                }
1858
 
                else {
1859
 
                    stack.push(tag)
1860
 
                }
1861
 
            }
1862
 
        }
1863
 
        else {
1864
 
            var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
1865
 
            var end = {
1866
 
                row: row,
1867
 
                column: firstTag.column
1868
 
            };
1869
 
            
1870
 
            while (tag = this._readTagBackward(iterator)) {
1871
 
                if (tag.selfClosing) {
1872
 
                    if (!stack.length) {
1873
 
                        tag.start.column += tag.tagName.length + 2;
1874
 
                        tag.end.column -= 2;
1875
 
                        return Range.fromPoints(tag.start, tag.end);
1876
 
                    } else
1877
 
                        continue;
1878
 
                }
1879
 
                
1880
 
                if (!tag.closing) {
1881
 
                    this._pop(stack, tag);
1882
 
                    if (stack.length == 0) {
1883
 
                        tag.start.column += tag.tagName.length + 2;
1884
 
                        return Range.fromPoints(tag.start, end);
1885
 
                    }
1886
 
                }
1887
 
                else {
1888
 
                    stack.push(tag)
1889
 
                }
1890
 
            }
1891
 
        }
1892
 
        
1893
 
    };
1894
 
 
1895
 
}).call(FoldMode.prototype);
1896
 
 
1897
 
});