Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mode-mask.js 79KB

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