1
/* ***** BEGIN LICENSE BLOCK *****
2
* Distributed under the BSD license:
4
* Copyright (c) 2012, Ajax.org B.V.
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.
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.
32
* Libo Cannici <libo AT zendesk DOT com>
36
* ***** END LICENSE BLOCK ***** */
37
define('ace/mode/curly', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html', 'ace/tokenizer', 'ace/mode/matching_brace_outdent', 'ace/mode/html_highlight_rules', 'ace/mode/folding/html', 'ace/mode/curly_highlight_rules'], function(require, exports, module) {
40
var oop = require("../lib/oop");
41
var HtmlMode = require("./html").Mode;
42
var Tokenizer = require("../tokenizer").Tokenizer;
43
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
44
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
45
var HtmlFoldMode = require("./folding/html").FoldMode;
46
var CurlyHighlightRules = require("./curly_highlight_rules").CurlyHighlightRules;
48
var Mode = function() {
49
var highlighter = new CurlyHighlightRules();
50
this.$outdent = new MatchingBraceOutdent();
51
this.foldingRules = new HtmlFoldMode();
53
this.$tokenizer = new Tokenizer(highlighter.getRules());
55
oop.inherits(Mode, HtmlMode);
58
}).call(Mode.prototype);
63
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) {
66
var oop = require("../lib/oop");
67
var TextMode = require("./text").Mode;
68
var JavaScriptMode = require("./javascript").Mode;
69
var CssMode = require("./css").Mode;
70
var Tokenizer = require("../tokenizer").Tokenizer;
71
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
72
var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
73
var HtmlFoldMode = require("./folding/html").FoldMode;
75
var Mode = function() {
76
var highlighter = new HtmlHighlightRules();
77
this.$tokenizer = new Tokenizer(highlighter.getRules());
78
this.$behaviour = new HtmlBehaviour();
80
this.$embeds = highlighter.getEmbeds();
81
this.createModeDelegates({
82
"js-": JavaScriptMode,
86
this.foldingRules = new HtmlFoldMode();
88
oop.inherits(Mode, TextMode);
92
this.blockComment = {start: "<!--", end: "-->"};
94
this.getNextLineIndent = function(state, line, tab) {
95
return this.$getIndent(line);
98
this.checkOutdent = function(state, line, input) {
102
}).call(Mode.prototype);
107
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) {
110
var oop = require("../lib/oop");
111
var TextMode = require("./text").Mode;
112
var Tokenizer = require("../tokenizer").Tokenizer;
113
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
114
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
115
var Range = require("../range").Range;
116
var WorkerClient = require("../worker/worker_client").WorkerClient;
117
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
118
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
120
var Mode = function() {
121
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
122
this.$outdent = new MatchingBraceOutdent();
123
this.$behaviour = new CstyleBehaviour();
124
this.foldingRules = new CStyleFoldMode();
126
oop.inherits(Mode, TextMode);
130
this.lineCommentStart = "//";
131
this.blockComment = {start: "/*", end: "*/"};
133
this.getNextLineIndent = function(state, line, tab) {
134
var indent = this.$getIndent(line);
136
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
137
var tokens = tokenizedLine.tokens;
138
var endState = tokenizedLine.state;
140
if (tokens.length && tokens[tokens.length-1].type == "comment") {
144
if (state == "start" || state == "no_regex") {
145
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
149
} else if (state == "doc-start") {
150
if (endState == "start" || endState == "no_regex") {
153
var match = line.match(/^\s*(\/?)\*/);
165
this.checkOutdent = function(state, line, input) {
166
return this.$outdent.checkOutdent(line, input);
169
this.autoOutdent = function(state, doc, row) {
170
this.$outdent.autoOutdent(doc, row);
173
this.createWorker = function(session) {
174
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
175
worker.attachToDocument(session.getDocument());
177
worker.on("jslint", function(results) {
178
session.setAnnotations(results.data);
181
worker.on("terminate", function() {
182
session.clearAnnotations();
188
}).call(Mode.prototype);
193
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) {
196
var oop = require("../lib/oop");
197
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
198
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
200
var JavaScriptHighlightRules = function() {
201
var keywordMapper = this.createKeywordMapper({
203
"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
204
"Namespace|QName|XML|XMLList|" + // E4X
205
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
206
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
207
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
208
"SyntaxError|TypeError|URIError|" +
209
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
210
"isNaN|parseFloat|parseInt|" +
211
"JSON|Math|" + // Other
212
"this|arguments|prototype|window|document" , // Pseudo
214
"const|yield|import|get|set|" +
215
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
216
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
217
"__parent__|__count__|escape|unescape|with|__proto__|" +
218
"class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
220
"const|let|var|function",
222
"null|Infinity|NaN|undefined",
225
"constant.language.boolean": "true|false"
227
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
228
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
230
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
231
"u[0-9a-fA-F]{4}|" + // unicode
232
"[0-2][0-7]{0,2}|" + // oct
233
"3[0-6][0-7]?|" + // oct
235
"[4-7][0-7]?|" + //oct
244
DocCommentHighlightRules.getStartRule("doc-start"),
246
token : "comment", // multi line comment
258
token : "constant.numeric", // hex
259
regex : /0[xX][0-9a-fA-F]+\b/
261
token : "constant.numeric", // float
262
regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
265
"storage.type", "punctuation.operator", "support.function",
266
"punctuation.operator", "entity.name.function", "text","keyword.operator"
268
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
269
next: "function_arguments"
272
"storage.type", "punctuation.operator", "entity.name.function", "text",
273
"keyword.operator", "text", "storage.type", "text", "paren.lparen"
275
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
276
next: "function_arguments"
279
"entity.name.function", "text", "keyword.operator", "text", "storage.type",
280
"text", "paren.lparen"
282
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
283
next: "function_arguments"
286
"storage.type", "punctuation.operator", "entity.name.function", "text",
287
"keyword.operator", "text",
288
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
290
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
291
next: "function_arguments"
294
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
296
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
297
next: "function_arguments"
300
"entity.name.function", "text", "punctuation.operator",
301
"text", "storage.type", "text", "paren.lparen"
303
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
304
next: "function_arguments"
307
"text", "text", "storage.type", "text", "paren.lparen"
309
regex : "(:)(\\s*)(function)(\\s*)(\\()",
310
next: "function_arguments"
313
regex : "(?:" + kwBeforeRe + ")\\b",
316
token : ["punctuation.operator", "support.function"],
317
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
319
token : ["punctuation.operator", "support.function.dom"],
320
regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
322
token : ["punctuation.operator", "support.constant"],
323
regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
325
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
326
regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
328
token : keywordMapper,
331
token : "keyword.operator",
332
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
335
token : "punctuation.operator",
336
regex : /\?|\:|\,|\;|\./,
339
token : "paren.lparen",
343
token : "paren.rparen",
346
token : "keyword.operator",
355
DocCommentHighlightRules.getStartRule("doc-start"),
357
token : "comment", // multi line comment
359
next : "comment_regex_allowed"
365
token: "string.regexp",
380
token: "regexp.keyword.operator",
381
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
383
token: "string.regexp",
388
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
390
token : "constant.language.escape",
391
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
393
token : "constant.language.delimiter",
396
token: "constant.language.escape",
398
next: "regex_character_class",
404
defaultToken: "string.regexp"
407
"regex_character_class": [
409
token: "regexp.keyword.operator",
410
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
412
token: "constant.language.escape",
416
token: "constant.language.escape",
423
defaultToken: "string.regexp.charachterclass"
426
"function_arguments": [
428
token: "variable.parameter",
431
token: "punctuation.operator",
434
token: "punctuation.operator",
442
"comment_regex_allowed" : [
443
{token : "comment", regex : "\\*\\/", next : "start"},
444
{defaultToken : "comment"}
447
{token : "comment", regex : "\\*\\/", next : "no_regex"},
448
{defaultToken : "comment"}
452
token : "constant.language.escape",
463
defaultToken: "string"
468
token : "constant.language.escape",
479
defaultToken: "string"
484
this.embedRules(DocCommentHighlightRules, "doc-",
485
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
488
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
490
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
493
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
496
var oop = require("../lib/oop");
497
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
499
var DocCommentHighlightRules = function() {
503
token : "comment.doc.tag",
504
regex : "@[\\w\\d_]+" // TODO: fix email addresses
506
token : "comment.doc.tag",
509
defaultToken : "comment.doc"
514
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
516
DocCommentHighlightRules.getStartRule = function(start) {
518
token : "comment.doc", // doc comment
519
regex : "\\/\\*(?=\\*)",
524
DocCommentHighlightRules.getEndRule = function (start) {
526
token : "comment.doc", // closing comment
533
exports.DocCommentHighlightRules = DocCommentHighlightRules;
537
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
540
var Range = require("../range").Range;
542
var MatchingBraceOutdent = function() {};
546
this.checkOutdent = function(line, input) {
547
if (! /^\s+$/.test(line))
550
return /^\s*\}/.test(input);
553
this.autoOutdent = function(doc, row) {
554
var line = doc.getLine(row);
555
var match = line.match(/^(\s*\})/);
557
if (!match) return 0;
559
var column = match[1].length;
560
var openBracePos = doc.findMatchingBracket({row: row, column: column});
562
if (!openBracePos || openBracePos.row == row) return 0;
564
var indent = this.$getIndent(doc.getLine(openBracePos.row));
565
doc.replace(new Range(row, 0, row, column-1), indent);
568
this.$getIndent = function(line) {
569
return line.match(/^\s*/)[0];
572
}).call(MatchingBraceOutdent.prototype);
574
exports.MatchingBraceOutdent = MatchingBraceOutdent;
577
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
580
var oop = require("../../lib/oop");
581
var Behaviour = require("../behaviour").Behaviour;
582
var TokenIterator = require("../../token_iterator").TokenIterator;
583
var lang = require("../../lib/lang");
585
var SAFE_INSERT_IN_TOKENS =
586
["text", "paren.rparen", "punctuation.operator"];
587
var SAFE_INSERT_BEFORE_TOKENS =
588
["text", "paren.rparen", "punctuation.operator", "comment"];
591
var autoInsertedBrackets = 0;
592
var autoInsertedRow = -1;
593
var autoInsertedLineEnd = "";
594
var maybeInsertedBrackets = 0;
595
var maybeInsertedRow = -1;
596
var maybeInsertedLineStart = "";
597
var maybeInsertedLineEnd = "";
599
var CstyleBehaviour = function () {
601
CstyleBehaviour.isSaneInsertion = function(editor, session) {
602
var cursor = editor.getCursorPosition();
603
var iterator = new TokenIterator(session, cursor.row, cursor.column);
604
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
605
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
606
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
609
iterator.stepForward();
610
return iterator.getCurrentTokenRow() !== cursor.row ||
611
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
614
CstyleBehaviour.$matchTokenType = function(token, types) {
615
return types.indexOf(token.type || token) > -1;
618
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
619
var cursor = editor.getCursorPosition();
620
var line = session.doc.getLine(cursor.row);
621
if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
622
autoInsertedBrackets = 0;
623
autoInsertedRow = cursor.row;
624
autoInsertedLineEnd = bracket + line.substr(cursor.column);
625
autoInsertedBrackets++;
628
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
629
var cursor = editor.getCursorPosition();
630
var line = session.doc.getLine(cursor.row);
631
if (!this.isMaybeInsertedClosing(cursor, line))
632
maybeInsertedBrackets = 0;
633
maybeInsertedRow = cursor.row;
634
maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
635
maybeInsertedLineEnd = line.substr(cursor.column);
636
maybeInsertedBrackets++;
639
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
640
return autoInsertedBrackets > 0 &&
641
cursor.row === autoInsertedRow &&
642
bracket === autoInsertedLineEnd[0] &&
643
line.substr(cursor.column) === autoInsertedLineEnd;
646
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
647
return maybeInsertedBrackets > 0 &&
648
cursor.row === maybeInsertedRow &&
649
line.substr(cursor.column) === maybeInsertedLineEnd &&
650
line.substr(0, cursor.column) == maybeInsertedLineStart;
653
CstyleBehaviour.popAutoInsertedClosing = function() {
654
autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
655
autoInsertedBrackets--;
658
CstyleBehaviour.clearMaybeInsertedClosing = function() {
659
maybeInsertedBrackets = 0;
660
maybeInsertedRow = -1;
663
this.add("braces", "insertion", function (state, action, editor, session, text) {
664
var cursor = editor.getCursorPosition();
665
var line = session.doc.getLine(cursor.row);
667
var selection = editor.getSelectionRange();
668
var selected = session.doc.getTextRange(selection);
669
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
671
text: '{' + selected + '}',
674
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
675
if (/[\]\}\)]/.test(line[cursor.column])) {
676
CstyleBehaviour.recordAutoInsert(editor, session, "}");
682
CstyleBehaviour.recordMaybeInsert(editor, session, "{");
689
} else if (text == '}') {
690
var rightChar = line.substring(cursor.column, cursor.column + 1);
691
if (rightChar == '}') {
692
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
693
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
694
CstyleBehaviour.popAutoInsertedClosing();
701
} else if (text == "\n" || text == "\r\n") {
703
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
704
closing = lang.stringRepeat("}", maybeInsertedBrackets);
705
CstyleBehaviour.clearMaybeInsertedClosing();
707
var rightChar = line.substring(cursor.column, cursor.column + 1);
708
if (rightChar == '}' || closing !== "") {
709
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
713
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
714
var next_indent = this.$getIndent(line);
717
text: '\n' + indent + '\n' + next_indent + closing,
718
selection: [1, indent.length, 1, indent.length]
724
this.add("braces", "deletion", function (state, action, editor, session, range) {
725
var selected = session.doc.getTextRange(range);
726
if (!range.isMultiLine() && selected == '{') {
727
var line = session.doc.getLine(range.start.row);
728
var rightChar = line.substring(range.end.column, range.end.column + 1);
729
if (rightChar == '}') {
733
maybeInsertedBrackets--;
738
this.add("parens", "insertion", function (state, action, editor, session, text) {
740
var selection = editor.getSelectionRange();
741
var selected = session.doc.getTextRange(selection);
742
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
744
text: '(' + selected + ')',
747
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
748
CstyleBehaviour.recordAutoInsert(editor, session, ")");
754
} else if (text == ')') {
755
var cursor = editor.getCursorPosition();
756
var line = session.doc.getLine(cursor.row);
757
var rightChar = line.substring(cursor.column, cursor.column + 1);
758
if (rightChar == ')') {
759
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
760
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
761
CstyleBehaviour.popAutoInsertedClosing();
771
this.add("parens", "deletion", function (state, action, editor, session, range) {
772
var selected = session.doc.getTextRange(range);
773
if (!range.isMultiLine() && selected == '(') {
774
var line = session.doc.getLine(range.start.row);
775
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
776
if (rightChar == ')') {
783
this.add("brackets", "insertion", function (state, action, editor, session, text) {
785
var selection = editor.getSelectionRange();
786
var selected = session.doc.getTextRange(selection);
787
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
789
text: '[' + selected + ']',
792
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
793
CstyleBehaviour.recordAutoInsert(editor, session, "]");
799
} else if (text == ']') {
800
var cursor = editor.getCursorPosition();
801
var line = session.doc.getLine(cursor.row);
802
var rightChar = line.substring(cursor.column, cursor.column + 1);
803
if (rightChar == ']') {
804
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
805
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
806
CstyleBehaviour.popAutoInsertedClosing();
816
this.add("brackets", "deletion", function (state, action, editor, session, range) {
817
var selected = session.doc.getTextRange(range);
818
if (!range.isMultiLine() && selected == '[') {
819
var line = session.doc.getLine(range.start.row);
820
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
821
if (rightChar == ']') {
828
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
829
if (text == '"' || text == "'") {
831
var selection = editor.getSelectionRange();
832
var selected = session.doc.getTextRange(selection);
833
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
835
text: quote + selected + quote,
839
var cursor = editor.getCursorPosition();
840
var line = session.doc.getLine(cursor.row);
841
var leftChar = line.substring(cursor.column-1, cursor.column);
842
if (leftChar == '\\') {
845
var tokens = session.getTokens(selection.start.row);
847
var quotepos = -1; // Track whether we're inside an open quote.
849
for (var x = 0; x < tokens.length; x++) {
851
if (token.type == "string") {
853
} else if (quotepos < 0) {
854
quotepos = token.value.indexOf(quote);
856
if ((token.value.length + col) > selection.start.column) {
859
col += tokens[x].value.length;
861
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)))) {
862
if (!CstyleBehaviour.isSaneInsertion(editor, session))
868
} else if (token && token.type === "string") {
869
var rightChar = line.substring(cursor.column, cursor.column + 1);
870
if (rightChar == quote) {
881
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
882
var selected = session.doc.getTextRange(range);
883
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
884
var line = session.doc.getLine(range.start.row);
885
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
886
if (rightChar == selected) {
895
oop.inherits(CstyleBehaviour, Behaviour);
897
exports.CstyleBehaviour = CstyleBehaviour;
900
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
903
var oop = require("../../lib/oop");
904
var Range = require("../../range").Range;
905
var BaseFoldMode = require("./fold_mode").FoldMode;
907
var FoldMode = exports.FoldMode = function(commentRegex) {
909
this.foldingStartMarker = new RegExp(
910
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
912
this.foldingStopMarker = new RegExp(
913
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
917
oop.inherits(FoldMode, BaseFoldMode);
921
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
922
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
924
this.getFoldWidgetRange = function(session, foldStyle, row) {
925
var line = session.getLine(row);
926
var match = line.match(this.foldingStartMarker);
931
return this.openingBracketBlock(session, match[1], row, i);
933
return session.getCommentFoldRange(row, i + match[0].length, 1);
936
if (foldStyle !== "markbeginend")
939
var match = line.match(this.foldingStopMarker);
941
var i = match.index + match[0].length;
944
return this.closingBracketBlock(session, match[1], row, i);
946
return session.getCommentFoldRange(row, i, -1);
950
}).call(FoldMode.prototype);
954
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) {
957
var oop = require("../lib/oop");
958
var TextMode = require("./text").Mode;
959
var Tokenizer = require("../tokenizer").Tokenizer;
960
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
961
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
962
var WorkerClient = require("../worker/worker_client").WorkerClient;
963
var CssBehaviour = require("./behaviour/css").CssBehaviour;
964
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
966
var Mode = function() {
967
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
968
this.$outdent = new MatchingBraceOutdent();
969
this.$behaviour = new CssBehaviour();
970
this.foldingRules = new CStyleFoldMode();
972
oop.inherits(Mode, TextMode);
976
this.foldingRules = "cStyle";
977
this.blockComment = {start: "/*", end: "*/"};
979
this.getNextLineIndent = function(state, line, tab) {
980
var indent = this.$getIndent(line);
981
var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
982
if (tokens.length && tokens[tokens.length-1].type == "comment") {
986
var match = line.match(/^.*\{\s*$/);
994
this.checkOutdent = function(state, line, input) {
995
return this.$outdent.checkOutdent(line, input);
998
this.autoOutdent = function(state, doc, row) {
999
this.$outdent.autoOutdent(doc, row);
1002
this.createWorker = function(session) {
1003
var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
1004
worker.attachToDocument(session.getDocument());
1006
worker.on("csslint", function(e) {
1007
session.setAnnotations(e.data);
1010
worker.on("terminate", function() {
1011
session.clearAnnotations();
1017
}).call(Mode.prototype);
1019
exports.Mode = Mode;
1023
define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1026
var oop = require("../lib/oop");
1027
var lang = require("../lib/lang");
1028
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1029
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";
1030
var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
1031
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";
1032
var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
1033
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";
1035
var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
1036
var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
1037
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";
1039
var CssHighlightRules = function() {
1041
var keywordMapper = this.createKeywordMapper({
1042
"support.function": supportFunction,
1043
"support.constant": supportConstant,
1044
"support.type": supportType,
1045
"support.constant.color": supportConstantColor,
1046
"support.constant.fonts": supportConstantFonts
1049
var base_ruleset = [
1051
token : "comment", // multi line comment
1053
next : "ruleset_comment"
1055
token : "string", // single line
1056
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
1058
token : "string", // single line
1059
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
1061
token : ["constant.numeric", "keyword"],
1062
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|%)"
1064
token : "constant.numeric",
1067
token : "constant.numeric", // hex6 color
1068
regex : "#[a-f0-9]{6}"
1070
token : "constant.numeric", // hex3 color
1071
regex : "#[a-f0-9]{3}"
1073
token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
1074
regex : pseudoElements
1076
token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
1077
regex : pseudoClasses
1079
token : ["support.function", "string", "support.function"],
1080
regex : "(url\\()(.*)(\\))"
1082
token : keywordMapper,
1083
regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
1085
caseInsensitive: true
1089
var ruleset = lang.copyArray(base_ruleset);
1091
token : "paren.rparen",
1096
var media_ruleset = lang.copyArray( base_ruleset );
1097
media_ruleset.unshift({
1098
token : "paren.rparen",
1103
var base_comment = [{
1104
token : "comment", // comment spanning whole line
1108
var comment = lang.copyArray(base_comment);
1110
token : "comment", // closing comment
1111
regex : ".*?\\*\\/",
1115
var media_comment = lang.copyArray(base_comment);
1116
media_comment.unshift({
1117
token : "comment", // closing comment
1118
regex : ".*?\\*\\/",
1122
var ruleset_comment = lang.copyArray(base_comment);
1123
ruleset_comment.unshift({
1124
token : "comment", // closing comment
1125
regex : ".*?\\*\\/",
1131
token : "comment", // multi line comment
1135
token: "paren.lparen",
1144
regex: "#[a-z0-9-_]+"
1147
regex: "\\.[a-z0-9-_]+"
1150
regex: ":[a-z0-9-_]+"
1153
regex: "[a-z0-9-_]+"
1155
caseInsensitive: true
1159
token : "comment", // multi line comment
1161
next : "media_comment"
1163
token: "paren.lparen",
1165
next: "media_ruleset"
1172
regex: "#[a-z0-9-_]+"
1175
regex: "\\.[a-z0-9-_]+"
1178
regex: ":[a-z0-9-_]+"
1181
regex: "[a-z0-9-_]+"
1183
caseInsensitive: true
1186
"comment" : comment,
1188
"ruleset" : ruleset,
1189
"ruleset_comment" : ruleset_comment,
1191
"media_ruleset" : media_ruleset,
1192
"media_comment" : media_comment
1196
oop.inherits(CssHighlightRules, TextHighlightRules);
1198
exports.CssHighlightRules = CssHighlightRules;
1202
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) {
1205
var oop = require("../../lib/oop");
1206
var Behaviour = require("../behaviour").Behaviour;
1207
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1208
var TokenIterator = require("../../token_iterator").TokenIterator;
1210
var CssBehaviour = function () {
1212
this.inherit(CstyleBehaviour);
1214
this.add("colon", "insertion", function (state, action, editor, session, text) {
1216
var cursor = editor.getCursorPosition();
1217
var iterator = new TokenIterator(session, cursor.row, cursor.column);
1218
var token = iterator.getCurrentToken();
1219
if (token && token.value.match(/\s+/)) {
1220
token = iterator.stepBackward();
1222
if (token && token.type === 'support.type') {
1223
var line = session.doc.getLine(cursor.row);
1224
var rightChar = line.substring(cursor.column, cursor.column + 1);
1225
if (rightChar === ':') {
1231
if (!line.substring(cursor.column).match(/^\s*;/)) {
1241
this.add("colon", "deletion", function (state, action, editor, session, range) {
1242
var selected = session.doc.getTextRange(range);
1243
if (!range.isMultiLine() && selected === ':') {
1244
var cursor = editor.getCursorPosition();
1245
var iterator = new TokenIterator(session, cursor.row, cursor.column);
1246
var token = iterator.getCurrentToken();
1247
if (token && token.value.match(/\s+/)) {
1248
token = iterator.stepBackward();
1250
if (token && token.type === 'support.type') {
1251
var line = session.doc.getLine(range.start.row);
1252
var rightChar = line.substring(range.end.column, range.end.column + 1);
1253
if (rightChar === ';') {
1254
range.end.column ++;
1261
this.add("semicolon", "insertion", function (state, action, editor, session, text) {
1263
var cursor = editor.getCursorPosition();
1264
var line = session.doc.getLine(cursor.row);
1265
var rightChar = line.substring(cursor.column, cursor.column + 1);
1266
if (rightChar === ';') {
1276
oop.inherits(CssBehaviour, CstyleBehaviour);
1278
exports.CssBehaviour = CssBehaviour;
1281
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) {
1284
var oop = require("../lib/oop");
1285
var lang = require("../lib/lang");
1286
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1287
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1288
var xmlUtil = require("./xml_util");
1289
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1291
var tagMap = lang.createMap({
1310
var HtmlHighlightRules = function() {
1314
regex : "<\\!\\[CDATA\\[",
1318
regex : "<\\?.*?\\?>"
1328
regex : "<(?=script\\b)",
1332
regex : "<(?=style\\b)",
1335
token : "meta.tag", // opening tag
1342
token : "constant.character.entity",
1343
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1357
defaultToken : "comment"
1361
xmlUtil.tag(this.$rules, "tag", "start", tagMap);
1362
xmlUtil.tag(this.$rules, "style", "css-start", tagMap);
1363
xmlUtil.tag(this.$rules, "script", "js-start", tagMap);
1365
this.embedRules(JavaScriptHighlightRules, "js-", [{
1367
regex: "\\/\\/.*(?=<\\/script>)",
1371
regex: "<\\/(?=script)",
1375
this.embedRules(CssHighlightRules, "css-", [{
1377
regex: "<\\/(?=style)",
1382
oop.inherits(HtmlHighlightRules, TextHighlightRules);
1384
exports.HtmlHighlightRules = HtmlHighlightRules;
1387
define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
1390
function string(state) {
1394
next : state + "_qqstring"
1398
next : state + "_qstring"
1402
function multiLineString(quote, state) {
1404
{token : "string", regex : quote, next : state},
1406
token : "constant.language.escape",
1407
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1409
{defaultToken : "string"}
1413
exports.tag = function(states, name, nextState, tagMap) {
1419
token : !tagMap ? "meta.tag.tag-name" : function(value) {
1421
return "meta.tag.tag-name." + tagMap[value];
1423
return "meta.tag.tag-name";
1425
regex : "[-_a-zA-Z0-9:]+",
1426
next : name + "_embed_attribute_list"
1430
next : name + "_embed_attribute_list"
1433
states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
1434
states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
1436
states[name + "_embed_attribute_list"] = [{
1437
token : "meta.tag.r",
1441
token : "keyword.operator",
1444
token : "entity.other.attribute-name",
1445
regex : "[-_a-zA-Z0-9:]+"
1447
token : "constant.numeric", // float
1448
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
1452
}].concat(string(name));
1457
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) {
1460
var oop = require("../../lib/oop");
1461
var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
1462
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1463
var TokenIterator = require("../../token_iterator").TokenIterator;
1464
var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
1466
function hasType(token, type) {
1468
var typeList = token.type.split('.');
1469
var needleList = type.split('.');
1470
needleList.forEach(function(needle){
1471
if (typeList.indexOf(needle) == -1) {
1479
var HtmlBehaviour = function () {
1481
this.inherit(XmlBehaviour); // Get xml behaviour
1483
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1485
var position = editor.getCursorPosition();
1486
var iterator = new TokenIterator(session, position.row, position.column);
1487
var token = iterator.getCurrentToken();
1488
var atCursor = false;
1489
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1491
token = iterator.stepBackward();
1492
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1496
if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1499
var element = token.value;
1501
var element = element.substring(0, position.column - token.start);
1503
if (voidElements.indexOf(element) !== -1){
1507
text: '>' + '</' + element + '>',
1513
oop.inherits(HtmlBehaviour, XmlBehaviour);
1515
exports.HtmlBehaviour = HtmlBehaviour;
1518
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) {
1521
var oop = require("../../lib/oop");
1522
var Behaviour = require("../behaviour").Behaviour;
1523
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1524
var TokenIterator = require("../../token_iterator").TokenIterator;
1526
function hasType(token, type) {
1528
var typeList = token.type.split('.');
1529
var needleList = type.split('.');
1530
needleList.forEach(function(needle){
1531
if (typeList.indexOf(needle) == -1) {
1539
var XmlBehaviour = function () {
1541
this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
1543
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1545
var position = editor.getCursorPosition();
1546
var iterator = new TokenIterator(session, position.row, position.column);
1547
var token = iterator.getCurrentToken();
1548
var atCursor = false;
1549
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1551
token = iterator.stepBackward();
1552
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1556
if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1559
var tag = token.value;
1561
var tag = tag.substring(0, position.column - token.start);
1565
text: '>' + '</' + tag + '>',
1571
this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
1573
var cursor = editor.getCursorPosition();
1574
var line = session.doc.getLine(cursor.row);
1575
var rightChars = line.substring(cursor.column, cursor.column + 2);
1576
if (rightChars == '</') {
1577
var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
1578
var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
1581
text: '\n' + indent + '\n' + next_indent,
1582
selection: [1, indent.length, 1, indent.length]
1589
oop.inherits(XmlBehaviour, Behaviour);
1591
exports.XmlBehaviour = XmlBehaviour;
1594
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) {
1597
var oop = require("../../lib/oop");
1598
var MixedFoldMode = require("./mixed").FoldMode;
1599
var XmlFoldMode = require("./xml").FoldMode;
1600
var CStyleFoldMode = require("./cstyle").FoldMode;
1602
var FoldMode = exports.FoldMode = function() {
1603
MixedFoldMode.call(this, new XmlFoldMode({
1632
"js-": new CStyleFoldMode(),
1633
"css-": new CStyleFoldMode()
1637
oop.inherits(FoldMode, MixedFoldMode);
1641
define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1644
var oop = require("../../lib/oop");
1645
var BaseFoldMode = require("./fold_mode").FoldMode;
1647
var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
1648
this.defaultMode = defaultMode;
1649
this.subModes = subModes;
1651
oop.inherits(FoldMode, BaseFoldMode);
1656
this.$getMode = function(state) {
1657
for (var key in this.subModes) {
1658
if (state.indexOf(key) === 0)
1659
return this.subModes[key];
1664
this.$tryMode = function(state, session, foldStyle, row) {
1665
var mode = this.$getMode(state);
1666
return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1669
this.getFoldWidget = function(session, foldStyle, row) {
1671
this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
1672
this.$tryMode(session.getState(row), session, foldStyle, row) ||
1673
this.defaultMode.getFoldWidget(session, foldStyle, row)
1677
this.getFoldWidgetRange = function(session, foldStyle, row) {
1678
var mode = this.$getMode(session.getState(row-1));
1680
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1681
mode = this.$getMode(session.getState(row));
1683
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1684
mode = this.defaultMode;
1686
return mode.getFoldWidgetRange(session, foldStyle, row);
1689
}).call(FoldMode.prototype);
1693
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) {
1696
var oop = require("../../lib/oop");
1697
var lang = require("../../lib/lang");
1698
var Range = require("../../range").Range;
1699
var BaseFoldMode = require("./fold_mode").FoldMode;
1700
var TokenIterator = require("../../token_iterator").TokenIterator;
1702
var FoldMode = exports.FoldMode = function(voidElements) {
1703
BaseFoldMode.call(this);
1704
this.voidElements = voidElements || {};
1706
oop.inherits(FoldMode, BaseFoldMode);
1710
this.getFoldWidget = function(session, foldStyle, row) {
1711
var tag = this._getFirstTagInLine(session, row);
1714
return foldStyle == "markbeginend" ? "end" : "";
1716
if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
1719
if (tag.selfClosing)
1722
if (tag.value.indexOf("/" + tag.tagName) !== -1)
1728
this._getFirstTagInLine = function(session, row) {
1729
var tokens = session.getTokens(row);
1731
for (var i = 0; i < tokens.length; i++) {
1732
var token = tokens[i];
1733
if (token.type.indexOf("meta.tag") === 0)
1734
value += token.value;
1736
value += lang.stringRepeat(" ", token.value.length);
1739
return this._parseTag(value);
1742
this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
1743
this._parseTag = function(tag) {
1745
var match = this.tagRe.exec(tag);
1746
var column = this.tagRe.lastIndex || 0;
1747
this.tagRe.lastIndex = 0;
1751
match: match ? match[2] : "",
1752
closing: match ? !!match[3] : false,
1753
selfClosing: match ? !!match[5] || match[2] == "/>" : false,
1754
tagName: match ? match[4] : "",
1755
column: match[1] ? column + match[1].length : column
1758
this._readTagForward = function(iterator) {
1759
var token = iterator.getCurrentToken();
1767
if (token.type.indexOf("meta.tag") === 0) {
1770
row: iterator.getCurrentTokenRow(),
1771
column: iterator.getCurrentTokenColumn()
1774
value += token.value;
1775
if (value.indexOf(">") !== -1) {
1776
var tag = this._parseTag(value);
1779
row: iterator.getCurrentTokenRow(),
1780
column: iterator.getCurrentTokenColumn() + token.value.length
1782
iterator.stepForward();
1786
} while(token = iterator.stepForward());
1791
this._readTagBackward = function(iterator) {
1792
var token = iterator.getCurrentToken();
1800
if (token.type.indexOf("meta.tag") === 0) {
1803
row: iterator.getCurrentTokenRow(),
1804
column: iterator.getCurrentTokenColumn() + token.value.length
1807
value = token.value + value;
1808
if (value.indexOf("<") !== -1) {
1809
var tag = this._parseTag(value);
1812
row: iterator.getCurrentTokenRow(),
1813
column: iterator.getCurrentTokenColumn()
1815
iterator.stepBackward();
1819
} while(token = iterator.stepBackward());
1824
this._pop = function(stack, tag) {
1825
while (stack.length) {
1827
var top = stack[stack.length-1];
1828
if (!tag || top.tagName == tag.tagName) {
1831
else if (this.voidElements[tag.tagName]) {
1834
else if (this.voidElements[top.tagName]) {
1843
this.getFoldWidgetRange = function(session, foldStyle, row) {
1844
var firstTag = this._getFirstTagInLine(session, row);
1846
if (!firstTag.match)
1849
var isBackward = firstTag.closing || firstTag.selfClosing;
1854
var iterator = new TokenIterator(session, row, firstTag.column);
1857
column: firstTag.column + firstTag.tagName.length + 2
1859
while (tag = this._readTagForward(iterator)) {
1860
if (tag.selfClosing) {
1861
if (!stack.length) {
1862
tag.start.column += tag.tagName.length + 2;
1863
tag.end.column -= 2;
1864
return Range.fromPoints(tag.start, tag.end);
1870
this._pop(stack, tag);
1871
if (stack.length == 0)
1872
return Range.fromPoints(start, tag.start);
1880
var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
1883
column: firstTag.column
1886
while (tag = this._readTagBackward(iterator)) {
1887
if (tag.selfClosing) {
1888
if (!stack.length) {
1889
tag.start.column += tag.tagName.length + 2;
1890
tag.end.column -= 2;
1891
return Range.fromPoints(tag.start, tag.end);
1897
this._pop(stack, tag);
1898
if (stack.length == 0) {
1899
tag.start.column += tag.tagName.length + 2;
1900
return Range.fromPoints(tag.start, end);
1911
}).call(FoldMode.prototype);
1914
define('ace/mode/curly_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html_highlight_rules'], function(require, exports, module) {
1917
var oop = require("../lib/oop");
1918
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
1921
var CurlyHighlightRules = function() {
1940
var htmlRules = new HtmlHighlightRules().getRules();
1941
htmlRules.start = CurlyRules.start.concat(htmlRules.start);
1942
htmlRules.curly_mode = CurlyRules.curly_mode;
1943
this.$rules = htmlRules;
1946
oop.inherits(CurlyHighlightRules, HtmlHighlightRules);
1948
exports.CurlyHighlightRules = CurlyHighlightRules;