8e158f69acdb73029247c5a269a566df.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  2. var Range = require("../range").Range;
  3. var MatchingBraceOutdent = function () { };
  4. (function () {
  5. this.checkOutdent = function (line, input) {
  6. if (!/^\s+$/.test(line))
  7. return false;
  8. return /^\s*\}/.test(input);
  9. };
  10. this.autoOutdent = function (doc, row) {
  11. var line = doc.getLine(row);
  12. var match = line.match(/^(\s*\})/);
  13. if (!match)
  14. return 0;
  15. var column = match[1].length;
  16. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  17. if (!openBracePos || openBracePos.row == row)
  18. return 0;
  19. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  20. doc.replace(new Range(row, 0, row, column - 1), indent);
  21. };
  22. this.$getIndent = function (line) {
  23. return line.match(/^\s*/)[0];
  24. };
  25. }).call(MatchingBraceOutdent.prototype);
  26. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  27. });
  28. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  29. var oop = require("../lib/oop");
  30. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  31. var DocCommentHighlightRules = function () {
  32. this.$rules = {
  33. "start": [{
  34. token: "comment.doc.tag",
  35. regex: "@[\\w\\d_]+" // TODO: fix email addresses
  36. },
  37. DocCommentHighlightRules.getTagRule(),
  38. {
  39. defaultToken: "comment.doc",
  40. caseInsensitive: true
  41. }]
  42. };
  43. };
  44. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  45. DocCommentHighlightRules.getTagRule = function (start) {
  46. return {
  47. token: "comment.doc.tag.storage.type",
  48. regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  49. };
  50. };
  51. DocCommentHighlightRules.getStartRule = function (start) {
  52. return {
  53. token: "comment.doc",
  54. regex: "\\/\\*(?=\\*)",
  55. next: start
  56. };
  57. };
  58. DocCommentHighlightRules.getEndRule = function (start) {
  59. return {
  60. token: "comment.doc",
  61. regex: "\\*\\/",
  62. next: start
  63. };
  64. };
  65. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  66. });
  67. ace.define("ace/mode/dot_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/doc_comment_highlight_rules"], function(require, exports, module){"use strict";
  68. var oop = require("../lib/oop");
  69. var lang = require("../lib/lang");
  70. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  71. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  72. var DotHighlightRules = function () {
  73. var keywords = lang.arrayToMap(("strict|node|edge|graph|digraph|subgraph").split("|"));
  74. var attributes = lang.arrayToMap(("damping|k|url|area|arrowhead|arrowsize|arrowtail|aspect|bb|bgcolor|center|charset|clusterrank|color|colorscheme|comment|compound|concentrate|constraint|decorate|defaultdist|dim|dimen|dir|diredgeconstraints|distortion|dpi|edgeurl|edgehref|edgetarget|edgetooltip|epsilon|esep|fillcolor|fixedsize|fontcolor|fontname|fontnames|fontpath|fontsize|forcelabels|gradientangle|group|headurl|head_lp|headclip|headhref|headlabel|headport|headtarget|headtooltip|height|href|id|image|imagepath|imagescale|label|labelurl|label_scheme|labelangle|labeldistance|labelfloat|labelfontcolor|labelfontname|labelfontsize|labelhref|labeljust|labelloc|labeltarget|labeltooltip|landscape|layer|layerlistsep|layers|layerselect|layersep|layout|len|levels|levelsgap|lhead|lheight|lp|ltail|lwidth|margin|maxiter|mclimit|mindist|minlen|mode|model|mosek|nodesep|nojustify|normalize|nslimit|nslimit1|ordering|orientation|outputorder|overlap|overlap_scaling|pack|packmode|pad|page|pagedir|pencolor|penwidth|peripheries|pin|pos|quadtree|quantum|rank|rankdir|ranksep|ratio|rects|regular|remincross|repulsiveforce|resolution|root|rotate|rotation|samehead|sametail|samplepoints|scale|searchsize|sep|shape|shapefile|showboxes|sides|size|skew|smoothing|sortv|splines|start|style|stylesheet|tailurl|tail_lp|tailclip|tailhref|taillabel|tailport|tailtarget|tailtooltip|target|tooltip|truecolor|vertices|viewport|voro_margin|weight|width|xlabel|xlp|z").split("|"));
  75. this.$rules = {
  76. "start": [
  77. {
  78. token: "comment",
  79. regex: /\/\/.*$/
  80. }, {
  81. token: "comment",
  82. regex: /#.*$/
  83. }, {
  84. token: "comment",
  85. merge: true,
  86. regex: /\/\*/,
  87. next: "comment"
  88. }, {
  89. token: "string",
  90. regex: "'(?=.)",
  91. next: "qstring"
  92. }, {
  93. token: "string",
  94. regex: '"(?=.)',
  95. next: "qqstring"
  96. }, {
  97. token: "constant.numeric",
  98. regex: /[+\-]?\d+(?:(?:\.\d*)?(?:[eE][+\-]?\d+)?)?\b/
  99. }, {
  100. token: "keyword.operator",
  101. regex: /\+|=|\->/
  102. }, {
  103. token: "punctuation.operator",
  104. regex: /,|;/
  105. }, {
  106. token: "paren.lparen",
  107. regex: /[\[{]/
  108. }, {
  109. token: "paren.rparen",
  110. regex: /[\]}]/
  111. }, {
  112. token: "comment",
  113. regex: /^#!.*$/
  114. }, {
  115. token: function (value) {
  116. if (keywords.hasOwnProperty(value.toLowerCase())) {
  117. return "keyword";
  118. }
  119. else if (attributes.hasOwnProperty(value.toLowerCase())) {
  120. return "variable";
  121. }
  122. else {
  123. return "text";
  124. }
  125. },
  126. regex: "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  127. }
  128. ],
  129. "comment": [
  130. {
  131. token: "comment",
  132. regex: "\\*\\/",
  133. next: "start"
  134. }, {
  135. defaultToken: "comment"
  136. }
  137. ],
  138. "qqstring": [
  139. {
  140. token: "string",
  141. regex: '[^"\\\\]+',
  142. merge: true
  143. }, {
  144. token: "string",
  145. regex: "\\\\$",
  146. next: "qqstring",
  147. merge: true
  148. }, {
  149. token: "string",
  150. regex: '"|$',
  151. next: "start",
  152. merge: true
  153. }
  154. ],
  155. "qstring": [
  156. {
  157. token: "string",
  158. regex: "[^'\\\\]+",
  159. merge: true
  160. }, {
  161. token: "string",
  162. regex: "\\\\$",
  163. next: "qstring",
  164. merge: true
  165. }, {
  166. token: "string",
  167. regex: "'|$",
  168. next: "start",
  169. merge: true
  170. }
  171. ]
  172. };
  173. };
  174. oop.inherits(DotHighlightRules, TextHighlightRules);
  175. exports.DotHighlightRules = DotHighlightRules;
  176. });
  177. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  178. var oop = require("../../lib/oop");
  179. var Range = require("../../range").Range;
  180. var BaseFoldMode = require("./fold_mode").FoldMode;
  181. var FoldMode = exports.FoldMode = function (commentRegex) {
  182. if (commentRegex) {
  183. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  184. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  185. }
  186. };
  187. oop.inherits(FoldMode, BaseFoldMode);
  188. (function () {
  189. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  190. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  191. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  192. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  193. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  194. this._getFoldWidgetBase = this.getFoldWidget;
  195. this.getFoldWidget = function (session, foldStyle, row) {
  196. var line = session.getLine(row);
  197. if (this.singleLineBlockCommentRe.test(line)) {
  198. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  199. return "";
  200. }
  201. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  202. if (!fw && this.startRegionRe.test(line))
  203. return "start"; // lineCommentRegionStart
  204. return fw;
  205. };
  206. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  207. var line = session.getLine(row);
  208. if (this.startRegionRe.test(line))
  209. return this.getCommentRegionBlock(session, line, row);
  210. var match = line.match(this.foldingStartMarker);
  211. if (match) {
  212. var i = match.index;
  213. if (match[1])
  214. return this.openingBracketBlock(session, match[1], row, i);
  215. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  216. if (range && !range.isMultiLine()) {
  217. if (forceMultiline) {
  218. range = this.getSectionRange(session, row);
  219. }
  220. else if (foldStyle != "all")
  221. range = null;
  222. }
  223. return range;
  224. }
  225. if (foldStyle === "markbegin")
  226. return;
  227. var match = line.match(this.foldingStopMarker);
  228. if (match) {
  229. var i = match.index + match[0].length;
  230. if (match[1])
  231. return this.closingBracketBlock(session, match[1], row, i);
  232. return session.getCommentFoldRange(row, i, -1);
  233. }
  234. };
  235. this.getSectionRange = function (session, row) {
  236. var line = session.getLine(row);
  237. var startIndent = line.search(/\S/);
  238. var startRow = row;
  239. var startColumn = line.length;
  240. row = row + 1;
  241. var endRow = row;
  242. var maxRow = session.getLength();
  243. while (++row < maxRow) {
  244. line = session.getLine(row);
  245. var indent = line.search(/\S/);
  246. if (indent === -1)
  247. continue;
  248. if (startIndent > indent)
  249. break;
  250. var subRange = this.getFoldWidgetRange(session, "all", row);
  251. if (subRange) {
  252. if (subRange.start.row <= startRow) {
  253. break;
  254. }
  255. else if (subRange.isMultiLine()) {
  256. row = subRange.end.row;
  257. }
  258. else if (startIndent == indent) {
  259. break;
  260. }
  261. }
  262. endRow = row;
  263. }
  264. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  265. };
  266. this.getCommentRegionBlock = function (session, line, row) {
  267. var startColumn = line.search(/\s*$/);
  268. var maxRow = session.getLength();
  269. var startRow = row;
  270. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  271. var depth = 1;
  272. while (++row < maxRow) {
  273. line = session.getLine(row);
  274. var m = re.exec(line);
  275. if (!m)
  276. continue;
  277. if (m[1])
  278. depth--;
  279. else
  280. depth++;
  281. if (!depth)
  282. break;
  283. }
  284. var endRow = row;
  285. if (endRow > startRow) {
  286. return new Range(startRow, startColumn, endRow, line.length);
  287. }
  288. };
  289. }).call(FoldMode.prototype);
  290. });
  291. ace.define("ace/mode/dot",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/matching_brace_outdent","ace/mode/dot_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  292. var oop = require("../lib/oop");
  293. var TextMode = require("./text").Mode;
  294. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  295. var DotHighlightRules = require("./dot_highlight_rules").DotHighlightRules;
  296. var DotFoldMode = require("./folding/cstyle").FoldMode;
  297. var Mode = function () {
  298. this.HighlightRules = DotHighlightRules;
  299. this.$outdent = new MatchingBraceOutdent();
  300. this.foldingRules = new DotFoldMode();
  301. this.$behaviour = this.$defaultBehaviour;
  302. };
  303. oop.inherits(Mode, TextMode);
  304. (function () {
  305. this.lineCommentStart = ["//", "#"];
  306. this.blockComment = { start: "/*", end: "*/" };
  307. this.getNextLineIndent = function (state, line, tab) {
  308. var indent = this.$getIndent(line);
  309. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  310. var tokens = tokenizedLine.tokens;
  311. var endState = tokenizedLine.state;
  312. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  313. return indent;
  314. }
  315. if (state == "start") {
  316. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  317. if (match) {
  318. indent += tab;
  319. }
  320. }
  321. return indent;
  322. };
  323. this.checkOutdent = function (state, line, input) {
  324. return this.$outdent.checkOutdent(line, input);
  325. };
  326. this.autoOutdent = function (state, doc, row) {
  327. this.$outdent.autoOutdent(doc, row);
  328. };
  329. this.$id = "ace/mode/dot";
  330. }).call(Mode.prototype);
  331. exports.Mode = Mode;
  332. }); (function() {
  333. ace.require(["ace/mode/dot"], function(m) {
  334. if (typeof module == "object" && typeof exports == "object" && module) {
  335. module.exports = m;
  336. }
  337. });
  338. })();