/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 js/ace/mode-svg.js

  • Committer: galaxyAbstractor
  • Date: 2013-04-04 16:19:07 UTC
  • mto: (12.2.4 lenasys) (19.1.4 lenasys)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: galaxyabstractor@gmail.com-20130404161907-eo1wnb7ac2rnizg8
Started implementation of a new codeviewer using Ace

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/svg', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/svg_highlight_rules', 'ace/mode/folding/mixed', 'ace/mode/folding/xml', 'ace/mode/folding/cstyle'], function(require, exports, module) {
 
32
 
 
33
 
 
34
var oop = require("../lib/oop");
 
35
var XmlMode = require("./xml").Mode;
 
36
var JavaScriptMode = require("./javascript").Mode;
 
37
var Tokenizer = require("../tokenizer").Tokenizer;
 
38
var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
 
39
var MixedFoldMode = require("./folding/mixed").FoldMode;
 
40
var XmlFoldMode = require("./folding/xml").FoldMode;
 
41
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
 
42
 
 
43
var Mode = function() {
 
44
    XmlMode.call(this);
 
45
    
 
46
    this.highlighter = new SvgHighlightRules();
 
47
    this.$tokenizer = new Tokenizer(this.highlighter.getRules());
 
48
    
 
49
    this.$embeds = this.highlighter.getEmbeds();
 
50
    this.createModeDelegates({
 
51
        "js-": JavaScriptMode
 
52
    });
 
53
    
 
54
    this.foldingRules = new MixedFoldMode(new XmlFoldMode({}), {
 
55
        "js-": new CStyleFoldMode()
 
56
    });
 
57
};
 
58
 
 
59
oop.inherits(Mode, XmlMode);
 
60
 
 
61
(function() {
 
62
 
 
63
    this.getNextLineIndent = function(state, line, tab) {
 
64
        return this.$getIndent(line);
 
65
    };
 
66
    
 
67
 
 
68
}).call(Mode.prototype);
 
69
 
 
70
exports.Mode = Mode;
 
71
});
 
72
 
 
73
define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) {
 
74
 
 
75
 
 
76
var oop = require("../lib/oop");
 
77
var TextMode = require("./text").Mode;
 
78
var Tokenizer = require("../tokenizer").Tokenizer;
 
79
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
 
80
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
 
81
var XmlFoldMode = require("./folding/xml").FoldMode;
 
82
 
 
83
var Mode = function() {
 
84
    this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules());
 
85
    this.$behaviour = new XmlBehaviour();
 
86
    this.foldingRules = new XmlFoldMode();
 
87
};
 
88
 
 
89
oop.inherits(Mode, TextMode);
 
90
 
 
91
(function() {
 
92
    
 
93
    this.blockComment = {start: "<!--", end: "-->"};
 
94
 
 
95
}).call(Mode.prototype);
 
96
 
 
97
exports.Mode = Mode;
 
98
});
 
99
 
 
100
define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
101
 
 
102
 
 
103
var oop = require("../lib/oop");
 
104
var xmlUtil = require("./xml_util");
 
105
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
106
 
 
107
var XmlHighlightRules = function() {
 
108
    this.$rules = {
 
109
        start : [
 
110
            {token : "text", regex : "<\\!\\[CDATA\\[", next : "cdata"},
 
111
            {token : "xml-pe", regex : "<\\?.*?\\?>"},
 
112
            {token : "comment", regex : "<\\!--", next : "comment"},
 
113
            {token : "xml-pe", regex : "<\\!.*?>"},
 
114
            {token : "meta.tag", regex : "<\\/?", next : "tag"},
 
115
            {token : "text", regex : "\\s+"},
 
116
            {
 
117
                token : "constant.character.entity", 
 
118
                regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" 
 
119
            }
 
120
        ],
 
121
        
 
122
        cdata : [
 
123
            {token : "text", regex : "\\]\\]>", next : "start"},
 
124
            {token : "text", regex : "\\s+"},
 
125
            {token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
 
126
        ],
 
127
 
 
128
        comment : [
 
129
            {token : "comment", regex : ".*?-->", next : "start"},
 
130
            {token : "comment", regex : ".+"}
 
131
        ]
 
132
    };
 
133
    
 
134
    xmlUtil.tag(this.$rules, "tag", "start");
 
135
};
 
136
 
 
137
oop.inherits(XmlHighlightRules, TextHighlightRules);
 
138
 
 
139
exports.XmlHighlightRules = XmlHighlightRules;
 
140
});
 
141
 
 
142
define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
 
143
 
 
144
 
 
145
function string(state) {
 
146
    return [{
 
147
        token : "string",
 
148
        regex : '"',
 
149
        next : state + "_qqstring"
 
150
    }, {
 
151
        token : "string",
 
152
        regex : "'",
 
153
        next : state + "_qstring"
 
154
    }];
 
155
}
 
156
 
 
157
function multiLineString(quote, state) {
 
158
    return [
 
159
        {token : "string", regex : quote, next : state},
 
160
        {
 
161
            token : "constant.language.escape",
 
162
            regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" 
 
163
        },
 
164
        {defaultToken : "string"}
 
165
    ];
 
166
}
 
167
 
 
168
exports.tag = function(states, name, nextState, tagMap) {
 
169
    states[name] = [{
 
170
        token : "text",
 
171
        regex : "\\s+"
 
172
    }, {
 
173
        
 
174
    token : !tagMap ? "meta.tag.tag-name" : function(value) {
 
175
            if (tagMap[value])
 
176
                return "meta.tag.tag-name." + tagMap[value];
 
177
            else
 
178
                return "meta.tag.tag-name";
 
179
        },
 
180
        regex : "[-_a-zA-Z0-9:]+",
 
181
        next : name + "_embed_attribute_list" 
 
182
    }, {
 
183
        token: "empty",
 
184
        regex: "",
 
185
        next : name + "_embed_attribute_list"
 
186
    }];
 
187
 
 
188
    states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
 
189
    states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
 
190
    
 
191
    states[name + "_embed_attribute_list"] = [{
 
192
        token : "meta.tag.r",
 
193
        regex : "/?>",
 
194
        next : nextState
 
195
    }, {
 
196
        token : "keyword.operator",
 
197
        regex : "="
 
198
    }, {
 
199
        token : "entity.other.attribute-name",
 
200
        regex : "[-_a-zA-Z0-9:]+"
 
201
    }, {
 
202
        token : "constant.numeric", // float
 
203
        regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
 
204
    }, {
 
205
        token : "text",
 
206
        regex : "\\s+"
 
207
    }].concat(string(name));
 
208
};
 
209
 
 
210
});
 
211
 
 
212
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) {
 
213
 
 
214
 
 
215
var oop = require("../../lib/oop");
 
216
var Behaviour = require("../behaviour").Behaviour;
 
217
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
 
218
var TokenIterator = require("../../token_iterator").TokenIterator;
 
219
 
 
220
function hasType(token, type) {
 
221
    var hasType = true;
 
222
    var typeList = token.type.split('.');
 
223
    var needleList = type.split('.');
 
224
    needleList.forEach(function(needle){
 
225
        if (typeList.indexOf(needle) == -1) {
 
226
            hasType = false;
 
227
            return false;
 
228
        }
 
229
    });
 
230
    return hasType;
 
231
}
 
232
 
 
233
var XmlBehaviour = function () {
 
234
    
 
235
    this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
 
236
    
 
237
    this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
 
238
        if (text == '>') {
 
239
            var position = editor.getCursorPosition();
 
240
            var iterator = new TokenIterator(session, position.row, position.column);
 
241
            var token = iterator.getCurrentToken();
 
242
            var atCursor = false;
 
243
            if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
 
244
                do {
 
245
                    token = iterator.stepBackward();
 
246
                } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
 
247
            } else {
 
248
                atCursor = true;
 
249
            }
 
250
            if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
 
251
                return
 
252
            }
 
253
            var tag = token.value;
 
254
            if (atCursor){
 
255
                var tag = tag.substring(0, position.column - token.start);
 
256
            }
 
257
 
 
258
            return {
 
259
               text: '>' + '</' + tag + '>',
 
260
               selection: [1, 1]
 
261
            }
 
262
        }
 
263
    });
 
264
 
 
265
    this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
 
266
        if (text == "\n") {
 
267
            var cursor = editor.getCursorPosition();
 
268
            var line = session.doc.getLine(cursor.row);
 
269
            var rightChars = line.substring(cursor.column, cursor.column + 2);
 
270
            if (rightChars == '</') {
 
271
                var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
 
272
                var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
 
273
 
 
274
                return {
 
275
                    text: '\n' + indent + '\n' + next_indent,
 
276
                    selection: [1, indent.length, 1, indent.length]
 
277
                }
 
278
            }
 
279
        }
 
280
    });
 
281
    
 
282
}
 
283
oop.inherits(XmlBehaviour, Behaviour);
 
284
 
 
285
exports.XmlBehaviour = XmlBehaviour;
 
286
});
 
287
 
 
288
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
 
289
 
 
290
 
 
291
var oop = require("../../lib/oop");
 
292
var Behaviour = require("../behaviour").Behaviour;
 
293
var TokenIterator = require("../../token_iterator").TokenIterator;
 
294
var lang = require("../../lib/lang");
 
295
 
 
296
var SAFE_INSERT_IN_TOKENS =
 
297
    ["text", "paren.rparen", "punctuation.operator"];
 
298
var SAFE_INSERT_BEFORE_TOKENS =
 
299
    ["text", "paren.rparen", "punctuation.operator", "comment"];
 
300
 
 
301
 
 
302
var autoInsertedBrackets = 0;
 
303
var autoInsertedRow = -1;
 
304
var autoInsertedLineEnd = "";
 
305
var maybeInsertedBrackets = 0;
 
306
var maybeInsertedRow = -1;
 
307
var maybeInsertedLineStart = "";
 
308
var maybeInsertedLineEnd = "";
 
309
 
 
310
var CstyleBehaviour = function () {
 
311
    
 
312
    CstyleBehaviour.isSaneInsertion = function(editor, session) {
 
313
        var cursor = editor.getCursorPosition();
 
314
        var iterator = new TokenIterator(session, cursor.row, cursor.column);
 
315
        if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
 
316
            var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
 
317
            if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
 
318
                return false;
 
319
        }
 
320
        iterator.stepForward();
 
321
        return iterator.getCurrentTokenRow() !== cursor.row ||
 
322
            this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
 
323
    };
 
324
    
 
325
    CstyleBehaviour.$matchTokenType = function(token, types) {
 
326
        return types.indexOf(token.type || token) > -1;
 
327
    };
 
328
    
 
329
    CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
 
330
        var cursor = editor.getCursorPosition();
 
331
        var line = session.doc.getLine(cursor.row);
 
332
        if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
 
333
            autoInsertedBrackets = 0;
 
334
        autoInsertedRow = cursor.row;
 
335
        autoInsertedLineEnd = bracket + line.substr(cursor.column);
 
336
        autoInsertedBrackets++;
 
337
    };
 
338
    
 
339
    CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
 
340
        var cursor = editor.getCursorPosition();
 
341
        var line = session.doc.getLine(cursor.row);
 
342
        if (!this.isMaybeInsertedClosing(cursor, line))
 
343
            maybeInsertedBrackets = 0;
 
344
        maybeInsertedRow = cursor.row;
 
345
        maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
 
346
        maybeInsertedLineEnd = line.substr(cursor.column);
 
347
        maybeInsertedBrackets++;
 
348
    };
 
349
    
 
350
    CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
 
351
        return autoInsertedBrackets > 0 &&
 
352
            cursor.row === autoInsertedRow &&
 
353
            bracket === autoInsertedLineEnd[0] &&
 
354
            line.substr(cursor.column) === autoInsertedLineEnd;
 
355
    };
 
356
    
 
357
    CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
 
358
        return maybeInsertedBrackets > 0 &&
 
359
            cursor.row === maybeInsertedRow &&
 
360
            line.substr(cursor.column) === maybeInsertedLineEnd &&
 
361
            line.substr(0, cursor.column) == maybeInsertedLineStart;
 
362
    };
 
363
    
 
364
    CstyleBehaviour.popAutoInsertedClosing = function() {
 
365
        autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
 
366
        autoInsertedBrackets--;
 
367
    };
 
368
    
 
369
    CstyleBehaviour.clearMaybeInsertedClosing = function() {
 
370
        maybeInsertedBrackets = 0;
 
371
        maybeInsertedRow = -1;
 
372
    };
 
373
 
 
374
    this.add("braces", "insertion", function (state, action, editor, session, text) {
 
375
        var cursor = editor.getCursorPosition();
 
376
        var line = session.doc.getLine(cursor.row);
 
377
        if (text == '{') {
 
378
            var selection = editor.getSelectionRange();
 
379
            var selected = session.doc.getTextRange(selection);
 
380
            if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
 
381
                return {
 
382
                    text: '{' + selected + '}',
 
383
                    selection: false
 
384
                };
 
385
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
 
386
                if (/[\]\}\)]/.test(line[cursor.column])) {
 
387
                    CstyleBehaviour.recordAutoInsert(editor, session, "}");
 
388
                    return {
 
389
                        text: '{}',
 
390
                        selection: [1, 1]
 
391
                    };
 
392
                } else {
 
393
                    CstyleBehaviour.recordMaybeInsert(editor, session, "{");
 
394
                    return {
 
395
                        text: '{',
 
396
                        selection: [1, 1]
 
397
                    };
 
398
                }
 
399
            }
 
400
        } else if (text == '}') {
 
401
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
402
            if (rightChar == '}') {
 
403
                var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
 
404
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
 
405
                    CstyleBehaviour.popAutoInsertedClosing();
 
406
                    return {
 
407
                        text: '',
 
408
                        selection: [1, 1]
 
409
                    };
 
410
                }
 
411
            }
 
412
        } else if (text == "\n" || text == "\r\n") {
 
413
            var closing = "";
 
414
            if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
 
415
                closing = lang.stringRepeat("}", maybeInsertedBrackets);
 
416
                CstyleBehaviour.clearMaybeInsertedClosing();
 
417
            }
 
418
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
419
            if (rightChar == '}' || closing !== "") {
 
420
                var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
 
421
                if (!openBracePos)
 
422
                     return null;
 
423
 
 
424
                var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
 
425
                var next_indent = this.$getIndent(line);
 
426
 
 
427
                return {
 
428
                    text: '\n' + indent + '\n' + next_indent + closing,
 
429
                    selection: [1, indent.length, 1, indent.length]
 
430
                };
 
431
            }
 
432
        }
 
433
    });
 
434
 
 
435
    this.add("braces", "deletion", function (state, action, editor, session, range) {
 
436
        var selected = session.doc.getTextRange(range);
 
437
        if (!range.isMultiLine() && selected == '{') {
 
438
            var line = session.doc.getLine(range.start.row);
 
439
            var rightChar = line.substring(range.end.column, range.end.column + 1);
 
440
            if (rightChar == '}') {
 
441
                range.end.column++;
 
442
                return range;
 
443
            } else {
 
444
                maybeInsertedBrackets--;
 
445
            }
 
446
        }
 
447
    });
 
448
 
 
449
    this.add("parens", "insertion", function (state, action, editor, session, text) {
 
450
        if (text == '(') {
 
451
            var selection = editor.getSelectionRange();
 
452
            var selected = session.doc.getTextRange(selection);
 
453
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
 
454
                return {
 
455
                    text: '(' + selected + ')',
 
456
                    selection: false
 
457
                };
 
458
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
 
459
                CstyleBehaviour.recordAutoInsert(editor, session, ")");
 
460
                return {
 
461
                    text: '()',
 
462
                    selection: [1, 1]
 
463
                };
 
464
            }
 
465
        } else if (text == ')') {
 
466
            var cursor = editor.getCursorPosition();
 
467
            var line = session.doc.getLine(cursor.row);
 
468
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
469
            if (rightChar == ')') {
 
470
                var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
 
471
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
 
472
                    CstyleBehaviour.popAutoInsertedClosing();
 
473
                    return {
 
474
                        text: '',
 
475
                        selection: [1, 1]
 
476
                    };
 
477
                }
 
478
            }
 
479
        }
 
480
    });
 
481
 
 
482
    this.add("parens", "deletion", function (state, action, editor, session, range) {
 
483
        var selected = session.doc.getTextRange(range);
 
484
        if (!range.isMultiLine() && selected == '(') {
 
485
            var line = session.doc.getLine(range.start.row);
 
486
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
 
487
            if (rightChar == ')') {
 
488
                range.end.column++;
 
489
                return range;
 
490
            }
 
491
        }
 
492
    });
 
493
 
 
494
    this.add("brackets", "insertion", function (state, action, editor, session, text) {
 
495
        if (text == '[') {
 
496
            var selection = editor.getSelectionRange();
 
497
            var selected = session.doc.getTextRange(selection);
 
498
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
 
499
                return {
 
500
                    text: '[' + selected + ']',
 
501
                    selection: false
 
502
                };
 
503
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
 
504
                CstyleBehaviour.recordAutoInsert(editor, session, "]");
 
505
                return {
 
506
                    text: '[]',
 
507
                    selection: [1, 1]
 
508
                };
 
509
            }
 
510
        } else if (text == ']') {
 
511
            var cursor = editor.getCursorPosition();
 
512
            var line = session.doc.getLine(cursor.row);
 
513
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
514
            if (rightChar == ']') {
 
515
                var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
 
516
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
 
517
                    CstyleBehaviour.popAutoInsertedClosing();
 
518
                    return {
 
519
                        text: '',
 
520
                        selection: [1, 1]
 
521
                    };
 
522
                }
 
523
            }
 
524
        }
 
525
    });
 
526
 
 
527
    this.add("brackets", "deletion", function (state, action, editor, session, range) {
 
528
        var selected = session.doc.getTextRange(range);
 
529
        if (!range.isMultiLine() && selected == '[') {
 
530
            var line = session.doc.getLine(range.start.row);
 
531
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
 
532
            if (rightChar == ']') {
 
533
                range.end.column++;
 
534
                return range;
 
535
            }
 
536
        }
 
537
    });
 
538
 
 
539
    this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
 
540
        if (text == '"' || text == "'") {
 
541
            var quote = text;
 
542
            var selection = editor.getSelectionRange();
 
543
            var selected = session.doc.getTextRange(selection);
 
544
            if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
 
545
                return {
 
546
                    text: quote + selected + quote,
 
547
                    selection: false
 
548
                };
 
549
            } else {
 
550
                var cursor = editor.getCursorPosition();
 
551
                var line = session.doc.getLine(cursor.row);
 
552
                var leftChar = line.substring(cursor.column-1, cursor.column);
 
553
                if (leftChar == '\\') {
 
554
                    return null;
 
555
                }
 
556
                var tokens = session.getTokens(selection.start.row);
 
557
                var col = 0, token;
 
558
                var quotepos = -1; // Track whether we're inside an open quote.
 
559
 
 
560
                for (var x = 0; x < tokens.length; x++) {
 
561
                    token = tokens[x];
 
562
                    if (token.type == "string") {
 
563
                      quotepos = -1;
 
564
                    } else if (quotepos < 0) {
 
565
                      quotepos = token.value.indexOf(quote);
 
566
                    }
 
567
                    if ((token.value.length + col) > selection.start.column) {
 
568
                        break;
 
569
                    }
 
570
                    col += tokens[x].value.length;
 
571
                }
 
572
                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)))) {
 
573
                    if (!CstyleBehaviour.isSaneInsertion(editor, session))
 
574
                        return;
 
575
                    return {
 
576
                        text: quote + quote,
 
577
                        selection: [1,1]
 
578
                    };
 
579
                } else if (token && token.type === "string") {
 
580
                    var rightChar = line.substring(cursor.column, cursor.column + 1);
 
581
                    if (rightChar == quote) {
 
582
                        return {
 
583
                            text: '',
 
584
                            selection: [1, 1]
 
585
                        };
 
586
                    }
 
587
                }
 
588
            }
 
589
        }
 
590
    });
 
591
 
 
592
    this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
 
593
        var selected = session.doc.getTextRange(range);
 
594
        if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
 
595
            var line = session.doc.getLine(range.start.row);
 
596
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
 
597
            if (rightChar == selected) {
 
598
                range.end.column++;
 
599
                return range;
 
600
            }
 
601
        }
 
602
    });
 
603
 
 
604
};
 
605
 
 
606
oop.inherits(CstyleBehaviour, Behaviour);
 
607
 
 
608
exports.CstyleBehaviour = CstyleBehaviour;
 
609
});
 
610
 
 
611
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) {
 
612
 
 
613
 
 
614
var oop = require("../../lib/oop");
 
615
var lang = require("../../lib/lang");
 
616
var Range = require("../../range").Range;
 
617
var BaseFoldMode = require("./fold_mode").FoldMode;
 
618
var TokenIterator = require("../../token_iterator").TokenIterator;
 
619
 
 
620
var FoldMode = exports.FoldMode = function(voidElements) {
 
621
    BaseFoldMode.call(this);
 
622
    this.voidElements = voidElements || {};
 
623
};
 
624
oop.inherits(FoldMode, BaseFoldMode);
 
625
 
 
626
(function() {
 
627
 
 
628
    this.getFoldWidget = function(session, foldStyle, row) {
 
629
        var tag = this._getFirstTagInLine(session, row);
 
630
 
 
631
        if (tag.closing)
 
632
            return foldStyle == "markbeginend" ? "end" : "";
 
633
 
 
634
        if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
 
635
            return "";
 
636
 
 
637
        if (tag.selfClosing)
 
638
            return "";
 
639
 
 
640
        if (tag.value.indexOf("/" + tag.tagName) !== -1)
 
641
            return "";
 
642
 
 
643
        return "start";
 
644
    };
 
645
    
 
646
    this._getFirstTagInLine = function(session, row) {
 
647
        var tokens = session.getTokens(row);
 
648
        var value = "";
 
649
        for (var i = 0; i < tokens.length; i++) {
 
650
            var token = tokens[i];
 
651
            if (token.type.indexOf("meta.tag") === 0)
 
652
                value += token.value;
 
653
            else
 
654
                value += lang.stringRepeat(" ", token.value.length);
 
655
        }
 
656
        
 
657
        return this._parseTag(value);
 
658
    };
 
659
 
 
660
    this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
 
661
    this._parseTag = function(tag) {
 
662
        
 
663
        var match = this.tagRe.exec(tag);
 
664
        var column = this.tagRe.lastIndex || 0;
 
665
        this.tagRe.lastIndex = 0;
 
666
 
 
667
        return {
 
668
            value: tag,
 
669
            match: match ? match[2] : "",
 
670
            closing: match ? !!match[3] : false,
 
671
            selfClosing: match ? !!match[5] || match[2] == "/>" : false,
 
672
            tagName: match ? match[4] : "",
 
673
            column: match[1] ? column + match[1].length : column
 
674
        };
 
675
    };
 
676
    this._readTagForward = function(iterator) {
 
677
        var token = iterator.getCurrentToken();
 
678
        if (!token)
 
679
            return null;
 
680
            
 
681
        var value = "";
 
682
        var start;
 
683
        
 
684
        do {
 
685
            if (token.type.indexOf("meta.tag") === 0) {
 
686
                if (!start) {
 
687
                    var start = {
 
688
                        row: iterator.getCurrentTokenRow(),
 
689
                        column: iterator.getCurrentTokenColumn()
 
690
                    };
 
691
                }
 
692
                value += token.value;
 
693
                if (value.indexOf(">") !== -1) {
 
694
                    var tag = this._parseTag(value);
 
695
                    tag.start = start;
 
696
                    tag.end = {
 
697
                        row: iterator.getCurrentTokenRow(),
 
698
                        column: iterator.getCurrentTokenColumn() + token.value.length
 
699
                    };
 
700
                    iterator.stepForward();
 
701
                    return tag;
 
702
                }
 
703
            }
 
704
        } while(token = iterator.stepForward());
 
705
        
 
706
        return null;
 
707
    };
 
708
    
 
709
    this._readTagBackward = function(iterator) {
 
710
        var token = iterator.getCurrentToken();
 
711
        if (!token)
 
712
            return null;
 
713
            
 
714
        var value = "";
 
715
        var end;
 
716
 
 
717
        do {
 
718
            if (token.type.indexOf("meta.tag") === 0) {
 
719
                if (!end) {
 
720
                    end = {
 
721
                        row: iterator.getCurrentTokenRow(),
 
722
                        column: iterator.getCurrentTokenColumn() + token.value.length
 
723
                    };
 
724
                }
 
725
                value = token.value + value;
 
726
                if (value.indexOf("<") !== -1) {
 
727
                    var tag = this._parseTag(value);
 
728
                    tag.end = end;
 
729
                    tag.start = {
 
730
                        row: iterator.getCurrentTokenRow(),
 
731
                        column: iterator.getCurrentTokenColumn()
 
732
                    };
 
733
                    iterator.stepBackward();
 
734
                    return tag;
 
735
                }
 
736
            }
 
737
        } while(token = iterator.stepBackward());
 
738
        
 
739
        return null;
 
740
    };
 
741
    
 
742
    this._pop = function(stack, tag) {
 
743
        while (stack.length) {
 
744
            
 
745
            var top = stack[stack.length-1];
 
746
            if (!tag || top.tagName == tag.tagName) {
 
747
                return stack.pop();
 
748
            }
 
749
            else if (this.voidElements[tag.tagName]) {
 
750
                return;
 
751
            }
 
752
            else if (this.voidElements[top.tagName]) {
 
753
                stack.pop();
 
754
                continue;
 
755
            } else {
 
756
                return null;
 
757
            }
 
758
        }
 
759
    };
 
760
    
 
761
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
762
        var firstTag = this._getFirstTagInLine(session, row);
 
763
        
 
764
        if (!firstTag.match)
 
765
            return null;
 
766
        
 
767
        var isBackward = firstTag.closing || firstTag.selfClosing;
 
768
        var stack = [];
 
769
        var tag;
 
770
        
 
771
        if (!isBackward) {
 
772
            var iterator = new TokenIterator(session, row, firstTag.column);
 
773
            var start = {
 
774
                row: row,
 
775
                column: firstTag.column + firstTag.tagName.length + 2
 
776
            };
 
777
            while (tag = this._readTagForward(iterator)) {
 
778
                if (tag.selfClosing) {
 
779
                    if (!stack.length) {
 
780
                        tag.start.column += tag.tagName.length + 2;
 
781
                        tag.end.column -= 2;
 
782
                        return Range.fromPoints(tag.start, tag.end);
 
783
                    } else
 
784
                        continue;
 
785
                }
 
786
                
 
787
                if (tag.closing) {
 
788
                    this._pop(stack, tag);
 
789
                    if (stack.length == 0)
 
790
                        return Range.fromPoints(start, tag.start);
 
791
                }
 
792
                else {
 
793
                    stack.push(tag)
 
794
                }
 
795
            }
 
796
        }
 
797
        else {
 
798
            var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
 
799
            var end = {
 
800
                row: row,
 
801
                column: firstTag.column
 
802
            };
 
803
            
 
804
            while (tag = this._readTagBackward(iterator)) {
 
805
                if (tag.selfClosing) {
 
806
                    if (!stack.length) {
 
807
                        tag.start.column += tag.tagName.length + 2;
 
808
                        tag.end.column -= 2;
 
809
                        return Range.fromPoints(tag.start, tag.end);
 
810
                    } else
 
811
                        continue;
 
812
                }
 
813
                
 
814
                if (!tag.closing) {
 
815
                    this._pop(stack, tag);
 
816
                    if (stack.length == 0) {
 
817
                        tag.start.column += tag.tagName.length + 2;
 
818
                        return Range.fromPoints(tag.start, end);
 
819
                    }
 
820
                }
 
821
                else {
 
822
                    stack.push(tag)
 
823
                }
 
824
            }
 
825
        }
 
826
        
 
827
    };
 
828
 
 
829
}).call(FoldMode.prototype);
 
830
 
 
831
});
 
832
 
 
833
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) {
 
834
 
 
835
 
 
836
var oop = require("../lib/oop");
 
837
var TextMode = require("./text").Mode;
 
838
var Tokenizer = require("../tokenizer").Tokenizer;
 
839
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
 
840
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
 
841
var Range = require("../range").Range;
 
842
var WorkerClient = require("../worker/worker_client").WorkerClient;
 
843
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
 
844
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
 
845
 
 
846
var Mode = function() {
 
847
    this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
 
848
    this.$outdent = new MatchingBraceOutdent();
 
849
    this.$behaviour = new CstyleBehaviour();
 
850
    this.foldingRules = new CStyleFoldMode();
 
851
};
 
852
oop.inherits(Mode, TextMode);
 
853
 
 
854
(function() {
 
855
 
 
856
    this.lineCommentStart = "//";
 
857
    this.blockComment = {start: "/*", end: "*/"};
 
858
 
 
859
    this.getNextLineIndent = function(state, line, tab) {
 
860
        var indent = this.$getIndent(line);
 
861
 
 
862
        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
 
863
        var tokens = tokenizedLine.tokens;
 
864
        var endState = tokenizedLine.state;
 
865
 
 
866
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
 
867
            return indent;
 
868
        }
 
869
 
 
870
        if (state == "start" || state == "no_regex") {
 
871
            var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
 
872
            if (match) {
 
873
                indent += tab;
 
874
            }
 
875
        } else if (state == "doc-start") {
 
876
            if (endState == "start" || endState == "no_regex") {
 
877
                return "";
 
878
            }
 
879
            var match = line.match(/^\s*(\/?)\*/);
 
880
            if (match) {
 
881
                if (match[1]) {
 
882
                    indent += " ";
 
883
                }
 
884
                indent += "* ";
 
885
            }
 
886
        }
 
887
 
 
888
        return indent;
 
889
    };
 
890
 
 
891
    this.checkOutdent = function(state, line, input) {
 
892
        return this.$outdent.checkOutdent(line, input);
 
893
    };
 
894
 
 
895
    this.autoOutdent = function(state, doc, row) {
 
896
        this.$outdent.autoOutdent(doc, row);
 
897
    };
 
898
 
 
899
    this.createWorker = function(session) {
 
900
        var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
 
901
        worker.attachToDocument(session.getDocument());
 
902
 
 
903
        worker.on("jslint", function(results) {
 
904
            session.setAnnotations(results.data);
 
905
        });
 
906
 
 
907
        worker.on("terminate", function() {
 
908
            session.clearAnnotations();
 
909
        });
 
910
 
 
911
        return worker;
 
912
    };
 
913
 
 
914
}).call(Mode.prototype);
 
915
 
 
916
exports.Mode = Mode;
 
917
});
 
918
 
 
919
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) {
 
920
 
 
921
 
 
922
var oop = require("../lib/oop");
 
923
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
 
924
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
925
 
 
926
var JavaScriptHighlightRules = function() {
 
927
    var keywordMapper = this.createKeywordMapper({
 
928
        "variable.language":
 
929
            "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|"  + // Constructors
 
930
            "Namespace|QName|XML|XMLList|"                                             + // E4X
 
931
            "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|"   +
 
932
            "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|"                    +
 
933
            "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|"   + // Errors
 
934
            "SyntaxError|TypeError|URIError|"                                          +
 
935
            "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
 
936
            "isNaN|parseFloat|parseInt|"                                               +
 
937
            "JSON|Math|"                                                               + // Other
 
938
            "this|arguments|prototype|window|document"                                 , // Pseudo
 
939
        "keyword":
 
940
            "const|yield|import|get|set|" +
 
941
            "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
 
942
            "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
 
943
            "__parent__|__count__|escape|unescape|with|__proto__|" +
 
944
            "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
 
945
        "storage.type":
 
946
            "const|let|var|function",
 
947
        "constant.language":
 
948
            "null|Infinity|NaN|undefined",
 
949
        "support.function":
 
950
            "alert",
 
951
        "constant.language.boolean": "true|false"
 
952
    }, "identifier");
 
953
    var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
 
954
    var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
 
955
 
 
956
    var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
 
957
        "u[0-9a-fA-F]{4}|" + // unicode
 
958
        "[0-2][0-7]{0,2}|" + // oct
 
959
        "3[0-6][0-7]?|" + // oct
 
960
        "37[0-7]?|" + // oct
 
961
        "[4-7][0-7]?|" + //oct
 
962
        ".)";
 
963
 
 
964
    this.$rules = {
 
965
        "no_regex" : [
 
966
            {
 
967
                token : "comment",
 
968
                regex : /\/\/.*$/
 
969
            },
 
970
            DocCommentHighlightRules.getStartRule("doc-start"),
 
971
            {
 
972
                token : "comment", // multi line comment
 
973
                regex : /\/\*/,
 
974
                next : "comment"
 
975
            }, {
 
976
                token : "string",
 
977
                regex : "'(?=.)",
 
978
                next  : "qstring"
 
979
            }, {
 
980
                token : "string",
 
981
                regex : '"(?=.)',
 
982
                next  : "qqstring"
 
983
            }, {
 
984
                token : "constant.numeric", // hex
 
985
                regex : /0[xX][0-9a-fA-F]+\b/
 
986
            }, {
 
987
                token : "constant.numeric", // float
 
988
                regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
 
989
            }, {
 
990
                token : [
 
991
                    "storage.type", "punctuation.operator", "support.function",
 
992
                    "punctuation.operator", "entity.name.function", "text","keyword.operator"
 
993
                ],
 
994
                regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
 
995
                next: "function_arguments"
 
996
            }, {
 
997
                token : [
 
998
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
 
999
                    "keyword.operator", "text", "storage.type", "text", "paren.lparen"
 
1000
                ],
 
1001
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
 
1002
                next: "function_arguments"
 
1003
            }, {
 
1004
                token : [
 
1005
                    "entity.name.function", "text", "keyword.operator", "text", "storage.type",
 
1006
                    "text", "paren.lparen"
 
1007
                ],
 
1008
                regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
 
1009
                next: "function_arguments"
 
1010
            }, {
 
1011
                token : [
 
1012
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
 
1013
                    "keyword.operator", "text",
 
1014
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
 
1015
                ],
 
1016
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
 
1017
                next: "function_arguments"
 
1018
            }, {
 
1019
                token : [
 
1020
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
 
1021
                ],
 
1022
                regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
 
1023
                next: "function_arguments"
 
1024
            }, {
 
1025
                token : [
 
1026
                    "entity.name.function", "text", "punctuation.operator",
 
1027
                    "text", "storage.type", "text", "paren.lparen"
 
1028
                ],
 
1029
                regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
 
1030
                next: "function_arguments"
 
1031
            }, {
 
1032
                token : [
 
1033
                    "text", "text", "storage.type", "text", "paren.lparen"
 
1034
                ],
 
1035
                regex : "(:)(\\s*)(function)(\\s*)(\\()",
 
1036
                next: "function_arguments"
 
1037
            }, {
 
1038
                token : "keyword",
 
1039
                regex : "(?:" + kwBeforeRe + ")\\b",
 
1040
                next : "start"
 
1041
            }, {
 
1042
                token : ["punctuation.operator", "support.function"],
 
1043
                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(?=\()/
 
1044
            }, {
 
1045
                token : ["punctuation.operator", "support.function.dom"],
 
1046
                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(?=\()/
 
1047
            }, {
 
1048
                token : ["punctuation.operator", "support.constant"],
 
1049
                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/
 
1050
            }, {
 
1051
                token : ["storage.type", "punctuation.operator", "support.function.firebug"],
 
1052
                regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
 
1053
            }, {
 
1054
                token : keywordMapper,
 
1055
                regex : identifierRe
 
1056
            }, {
 
1057
                token : "keyword.operator",
 
1058
                regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
 
1059
                next  : "start"
 
1060
            }, {
 
1061
                token : "punctuation.operator",
 
1062
                regex : /\?|\:|\,|\;|\./,
 
1063
                next  : "start"
 
1064
            }, {
 
1065
                token : "paren.lparen",
 
1066
                regex : /[\[({]/,
 
1067
                next  : "start"
 
1068
            }, {
 
1069
                token : "paren.rparen",
 
1070
                regex : /[\])}]/
 
1071
            }, {
 
1072
                token : "keyword.operator",
 
1073
                regex : /\/=?/,
 
1074
                next  : "start"
 
1075
            }, {
 
1076
                token: "comment",
 
1077
                regex: /^#!.*$/
 
1078
            }
 
1079
        ],
 
1080
        "start": [
 
1081
            DocCommentHighlightRules.getStartRule("doc-start"),
 
1082
            {
 
1083
                token : "comment", // multi line comment
 
1084
                regex : "\\/\\*",
 
1085
                next : "comment_regex_allowed"
 
1086
            }, {
 
1087
                token : "comment",
 
1088
                regex : "\\/\\/.*$",
 
1089
                next : "start"
 
1090
            }, {
 
1091
                token: "string.regexp",
 
1092
                regex: "\\/",
 
1093
                next: "regex",
 
1094
            }, {
 
1095
                token : "text",
 
1096
                regex : "\\s+|^$",
 
1097
                next : "start"
 
1098
            }, {
 
1099
                token: "empty",
 
1100
                regex: "",
 
1101
                next: "no_regex"
 
1102
            }
 
1103
        ],
 
1104
        "regex": [
 
1105
            {
 
1106
                token: "regexp.keyword.operator",
 
1107
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
 
1108
            }, {
 
1109
                token: "string.regexp",
 
1110
                regex: "/\\w*",
 
1111
                next: "no_regex",
 
1112
            }, {
 
1113
                token : "invalid",
 
1114
                regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
 
1115
            }, {
 
1116
                token : "constant.language.escape",
 
1117
                regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
 
1118
            }, {
 
1119
                token : "constant.language.delimiter",
 
1120
                regex: /\|/
 
1121
            }, {
 
1122
                token: "constant.language.escape",
 
1123
                regex: /\[\^?/,
 
1124
                next: "regex_character_class",
 
1125
            }, {
 
1126
                token: "empty",
 
1127
                regex: "$",
 
1128
                next: "no_regex"
 
1129
            }, {
 
1130
                defaultToken: "string.regexp"
 
1131
            }
 
1132
        ],
 
1133
        "regex_character_class": [
 
1134
            {
 
1135
                token: "regexp.keyword.operator",
 
1136
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
 
1137
            }, {
 
1138
                token: "constant.language.escape",
 
1139
                regex: "]",
 
1140
                next: "regex",
 
1141
            }, {
 
1142
                token: "constant.language.escape",
 
1143
                regex: "-"
 
1144
            }, {
 
1145
                token: "empty",
 
1146
                regex: "$",
 
1147
                next: "no_regex"
 
1148
            }, {
 
1149
                defaultToken: "string.regexp.charachterclass"
 
1150
            }
 
1151
        ],
 
1152
        "function_arguments": [
 
1153
            {
 
1154
                token: "variable.parameter",
 
1155
                regex: identifierRe
 
1156
            }, {
 
1157
                token: "punctuation.operator",
 
1158
                regex: "[, ]+",
 
1159
            }, {
 
1160
                token: "punctuation.operator",
 
1161
                regex: "$",
 
1162
            }, {
 
1163
                token: "empty",
 
1164
                regex: "",
 
1165
                next: "no_regex"
 
1166
            }
 
1167
        ],
 
1168
        "comment_regex_allowed" : [
 
1169
            {token : "comment", regex : "\\*\\/", next : "start"},
 
1170
            {defaultToken : "comment"}
 
1171
        ],
 
1172
        "comment" : [
 
1173
            {token : "comment", regex : "\\*\\/", next : "no_regex"},
 
1174
            {defaultToken : "comment"}
 
1175
        ],
 
1176
        "qqstring" : [
 
1177
            {
 
1178
                token : "constant.language.escape",
 
1179
                regex : escapedRe
 
1180
            }, {
 
1181
                token : "string",
 
1182
                regex : "\\\\$",
 
1183
                next  : "qqstring",
 
1184
            }, {
 
1185
                token : "string",
 
1186
                regex : '"|$',
 
1187
                next  : "no_regex",
 
1188
            }, {
 
1189
                defaultToken: "string"
 
1190
            }
 
1191
        ],
 
1192
        "qstring" : [
 
1193
            {
 
1194
                token : "constant.language.escape",
 
1195
                regex : escapedRe
 
1196
            }, {
 
1197
                token : "string",
 
1198
                regex : "\\\\$",
 
1199
                next  : "qstring",
 
1200
            }, {
 
1201
                token : "string",
 
1202
                regex : "'|$",
 
1203
                next  : "no_regex",
 
1204
            }, {
 
1205
                defaultToken: "string"
 
1206
            }
 
1207
        ]
 
1208
    };
 
1209
 
 
1210
    this.embedRules(DocCommentHighlightRules, "doc-",
 
1211
        [ DocCommentHighlightRules.getEndRule("no_regex") ]);
 
1212
};
 
1213
 
 
1214
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
 
1215
 
 
1216
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
 
1217
});
 
1218
 
 
1219
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
1220
 
 
1221
 
 
1222
var oop = require("../lib/oop");
 
1223
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
1224
 
 
1225
var DocCommentHighlightRules = function() {
 
1226
 
 
1227
    this.$rules = {
 
1228
        "start" : [ {
 
1229
            token : "comment.doc.tag",
 
1230
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
 
1231
        }, {
 
1232
            token : "comment.doc.tag",
 
1233
            regex : "\\bTODO\\b"
 
1234
        }, {
 
1235
            defaultToken : "comment.doc"
 
1236
        }]
 
1237
    };
 
1238
};
 
1239
 
 
1240
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
 
1241
 
 
1242
DocCommentHighlightRules.getStartRule = function(start) {
 
1243
    return {
 
1244
        token : "comment.doc", // doc comment
 
1245
        regex : "\\/\\*(?=\\*)",
 
1246
        next  : start
 
1247
    };
 
1248
};
 
1249
 
 
1250
DocCommentHighlightRules.getEndRule = function (start) {
 
1251
    return {
 
1252
        token : "comment.doc", // closing comment
 
1253
        regex : "\\*\\/",
 
1254
        next  : start
 
1255
    };
 
1256
};
 
1257
 
 
1258
 
 
1259
exports.DocCommentHighlightRules = DocCommentHighlightRules;
 
1260
 
 
1261
});
 
1262
 
 
1263
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
 
1264
 
 
1265
 
 
1266
var Range = require("../range").Range;
 
1267
 
 
1268
var MatchingBraceOutdent = function() {};
 
1269
 
 
1270
(function() {
 
1271
 
 
1272
    this.checkOutdent = function(line, input) {
 
1273
        if (! /^\s+$/.test(line))
 
1274
            return false;
 
1275
 
 
1276
        return /^\s*\}/.test(input);
 
1277
    };
 
1278
 
 
1279
    this.autoOutdent = function(doc, row) {
 
1280
        var line = doc.getLine(row);
 
1281
        var match = line.match(/^(\s*\})/);
 
1282
 
 
1283
        if (!match) return 0;
 
1284
 
 
1285
        var column = match[1].length;
 
1286
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
 
1287
 
 
1288
        if (!openBracePos || openBracePos.row == row) return 0;
 
1289
 
 
1290
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
 
1291
        doc.replace(new Range(row, 0, row, column-1), indent);
 
1292
    };
 
1293
 
 
1294
    this.$getIndent = function(line) {
 
1295
        return line.match(/^\s*/)[0];
 
1296
    };
 
1297
 
 
1298
}).call(MatchingBraceOutdent.prototype);
 
1299
 
 
1300
exports.MatchingBraceOutdent = MatchingBraceOutdent;
 
1301
});
 
1302
 
 
1303
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
 
1304
 
 
1305
 
 
1306
var oop = require("../../lib/oop");
 
1307
var Range = require("../../range").Range;
 
1308
var BaseFoldMode = require("./fold_mode").FoldMode;
 
1309
 
 
1310
var FoldMode = exports.FoldMode = function(commentRegex) {
 
1311
    if (commentRegex) {
 
1312
        this.foldingStartMarker = new RegExp(
 
1313
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
 
1314
        );
 
1315
        this.foldingStopMarker = new RegExp(
 
1316
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
 
1317
        );
 
1318
    }
 
1319
};
 
1320
oop.inherits(FoldMode, BaseFoldMode);
 
1321
 
 
1322
(function() {
 
1323
 
 
1324
    this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
 
1325
    this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
 
1326
 
 
1327
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
1328
        var line = session.getLine(row);
 
1329
        var match = line.match(this.foldingStartMarker);
 
1330
        if (match) {
 
1331
            var i = match.index;
 
1332
 
 
1333
            if (match[1])
 
1334
                return this.openingBracketBlock(session, match[1], row, i);
 
1335
 
 
1336
            return session.getCommentFoldRange(row, i + match[0].length, 1);
 
1337
        }
 
1338
 
 
1339
        if (foldStyle !== "markbeginend")
 
1340
            return;
 
1341
 
 
1342
        var match = line.match(this.foldingStopMarker);
 
1343
        if (match) {
 
1344
            var i = match.index + match[0].length;
 
1345
 
 
1346
            if (match[1])
 
1347
                return this.closingBracketBlock(session, match[1], row, i);
 
1348
 
 
1349
            return session.getCommentFoldRange(row, i, -1);
 
1350
        }
 
1351
    };
 
1352
 
 
1353
}).call(FoldMode.prototype);
 
1354
 
 
1355
});
 
1356
 
 
1357
define('ace/mode/svg_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules', 'ace/mode/xml_util'], function(require, exports, module) {
 
1358
 
 
1359
 
 
1360
var oop = require("../lib/oop");
 
1361
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
 
1362
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
 
1363
var xmlUtil = require("./xml_util");
 
1364
 
 
1365
var SvgHighlightRules = function() {
 
1366
    XmlHighlightRules.call(this);
 
1367
 
 
1368
    this.$rules.start.splice(3, 0, {
 
1369
        token : "meta.tag",
 
1370
        regex : "<(?=script)",
 
1371
        next : "script"
 
1372
    });
 
1373
    
 
1374
    xmlUtil.tag(this.$rules, "script", "js-start");
 
1375
    
 
1376
    this.embedRules(JavaScriptHighlightRules, "js-", [{
 
1377
        token: "comment",
 
1378
        regex: "\\/\\/.*(?=<\\/script>)",
 
1379
        next: "tag"
 
1380
    }, {
 
1381
        token: "meta.tag",
 
1382
        regex: "<\\/(?=script)",
 
1383
        next: "tag"
 
1384
    }]);
 
1385
};
 
1386
 
 
1387
oop.inherits(SvgHighlightRules, XmlHighlightRules);
 
1388
 
 
1389
exports.SvgHighlightRules = SvgHighlightRules;
 
1390
});
 
1391
 
 
1392
define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
 
1393
 
 
1394
 
 
1395
var oop = require("../../lib/oop");
 
1396
var BaseFoldMode = require("./fold_mode").FoldMode;
 
1397
 
 
1398
var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
 
1399
    this.defaultMode = defaultMode;
 
1400
    this.subModes = subModes;
 
1401
};
 
1402
oop.inherits(FoldMode, BaseFoldMode);
 
1403
 
 
1404
(function() {
 
1405
 
 
1406
 
 
1407
    this.$getMode = function(state) {
 
1408
        for (var key in this.subModes) {
 
1409
            if (state.indexOf(key) === 0)
 
1410
                return this.subModes[key];
 
1411
        }
 
1412
        return null;
 
1413
    };
 
1414
    
 
1415
    this.$tryMode = function(state, session, foldStyle, row) {
 
1416
        var mode = this.$getMode(state);
 
1417
        return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
 
1418
    };
 
1419
 
 
1420
    this.getFoldWidget = function(session, foldStyle, row) {
 
1421
        return (
 
1422
            this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
 
1423
            this.$tryMode(session.getState(row), session, foldStyle, row) ||
 
1424
            this.defaultMode.getFoldWidget(session, foldStyle, row)
 
1425
        );
 
1426
    };
 
1427
 
 
1428
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
1429
        var mode = this.$getMode(session.getState(row-1));
 
1430
        
 
1431
        if (!mode || !mode.getFoldWidget(session, foldStyle, row))
 
1432
            mode = this.$getMode(session.getState(row));
 
1433
        
 
1434
        if (!mode || !mode.getFoldWidget(session, foldStyle, row))
 
1435
            mode = this.defaultMode;
 
1436
        
 
1437
        return mode.getFoldWidgetRange(session, foldStyle, row);
 
1438
    };
 
1439
 
 
1440
}).call(FoldMode.prototype);
 
1441
 
 
1442
});