설명 없음
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-svg.js 67KB

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