/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/js/ace/mode-html.js

  • Committer: galaxyAbstractor
  • Date: 2013-04-10 15:49:32 UTC
  • mto: (19.1.5 lenasys)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: galaxyabstractor@gmail.com-20130410154932-4vizlzk0ar5gykvi
* Added an simple admin panel to the codeviewer-cmssy stuff
* Redesigned a bit like the mockups - still stuff to come
* Implemented the codeviewer + admin panel again using the Framework CodeIgniter instead 

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