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