3078a3b7f66272ada3e5d065827dfceb.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. 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";
  2. var oop = require("../../lib/oop");
  3. var Range = require("../../range").Range;
  4. var BaseFoldMode = require("./fold_mode").FoldMode;
  5. var FoldMode = exports.FoldMode = function (commentRegex) {
  6. if (commentRegex) {
  7. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  8. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  9. }
  10. };
  11. oop.inherits(FoldMode, BaseFoldMode);
  12. (function () {
  13. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  14. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  15. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  16. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  17. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  18. this._getFoldWidgetBase = this.getFoldWidget;
  19. this.getFoldWidget = function (session, foldStyle, row) {
  20. var line = session.getLine(row);
  21. if (this.singleLineBlockCommentRe.test(line)) {
  22. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  23. return "";
  24. }
  25. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  26. if (!fw && this.startRegionRe.test(line))
  27. return "start"; // lineCommentRegionStart
  28. return fw;
  29. };
  30. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  31. var line = session.getLine(row);
  32. if (this.startRegionRe.test(line))
  33. return this.getCommentRegionBlock(session, line, row);
  34. var match = line.match(this.foldingStartMarker);
  35. if (match) {
  36. var i = match.index;
  37. if (match[1])
  38. return this.openingBracketBlock(session, match[1], row, i);
  39. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  40. if (range && !range.isMultiLine()) {
  41. if (forceMultiline) {
  42. range = this.getSectionRange(session, row);
  43. }
  44. else if (foldStyle != "all")
  45. range = null;
  46. }
  47. return range;
  48. }
  49. if (foldStyle === "markbegin")
  50. return;
  51. var match = line.match(this.foldingStopMarker);
  52. if (match) {
  53. var i = match.index + match[0].length;
  54. if (match[1])
  55. return this.closingBracketBlock(session, match[1], row, i);
  56. return session.getCommentFoldRange(row, i, -1);
  57. }
  58. };
  59. this.getSectionRange = function (session, row) {
  60. var line = session.getLine(row);
  61. var startIndent = line.search(/\S/);
  62. var startRow = row;
  63. var startColumn = line.length;
  64. row = row + 1;
  65. var endRow = row;
  66. var maxRow = session.getLength();
  67. while (++row < maxRow) {
  68. line = session.getLine(row);
  69. var indent = line.search(/\S/);
  70. if (indent === -1)
  71. continue;
  72. if (startIndent > indent)
  73. break;
  74. var subRange = this.getFoldWidgetRange(session, "all", row);
  75. if (subRange) {
  76. if (subRange.start.row <= startRow) {
  77. break;
  78. }
  79. else if (subRange.isMultiLine()) {
  80. row = subRange.end.row;
  81. }
  82. else if (startIndent == indent) {
  83. break;
  84. }
  85. }
  86. endRow = row;
  87. }
  88. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  89. };
  90. this.getCommentRegionBlock = function (session, line, row) {
  91. var startColumn = line.search(/\s*$/);
  92. var maxRow = session.getLength();
  93. var startRow = row;
  94. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  95. var depth = 1;
  96. while (++row < maxRow) {
  97. line = session.getLine(row);
  98. var m = re.exec(line);
  99. if (!m)
  100. continue;
  101. if (m[1])
  102. depth--;
  103. else
  104. depth++;
  105. if (!depth)
  106. break;
  107. }
  108. var endRow = row;
  109. if (endRow > startRow) {
  110. return new Range(startRow, startColumn, endRow, line.length);
  111. }
  112. };
  113. }).call(FoldMode.prototype);
  114. });
  115. ace.define("ace/mode/tcl_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  116. var oop = require("../lib/oop");
  117. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  118. var TclHighlightRules = function () {
  119. this.$rules = {
  120. "start": [
  121. {
  122. token: "comment",
  123. regex: "#.*\\\\$",
  124. next: "commentfollow"
  125. }, {
  126. token: "comment",
  127. regex: "#.*$"
  128. }, {
  129. token: "support.function",
  130. regex: '[\\\\]$',
  131. next: "splitlineStart"
  132. }, {
  133. token: "text",
  134. regex: /\\(?:["{}\[\]$\\])/
  135. }, {
  136. token: "text",
  137. regex: '^|[^{][;][^}]|[/\r/]',
  138. next: "commandItem"
  139. }, {
  140. token: "string",
  141. regex: '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  142. }, {
  143. token: "string",
  144. regex: '[ ]*["]',
  145. next: "qqstring"
  146. }, {
  147. token: "variable.instance",
  148. regex: "[$]",
  149. next: "variable"
  150. }, {
  151. token: "support.function",
  152. regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::"
  153. }, {
  154. token: "identifier",
  155. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  156. }, {
  157. token: "paren.lparen",
  158. regex: "[[{]",
  159. next: "commandItem"
  160. }, {
  161. token: "paren.lparen",
  162. regex: "[(]"
  163. }, {
  164. token: "paren.rparen",
  165. regex: "[\\])}]"
  166. }, {
  167. token: "text",
  168. regex: "\\s+"
  169. }
  170. ],
  171. "commandItem": [
  172. {
  173. token: "comment",
  174. regex: "#.*\\\\$",
  175. next: "commentfollow"
  176. }, {
  177. token: "comment",
  178. regex: "#.*$",
  179. next: "start"
  180. }, {
  181. token: "string",
  182. regex: '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  183. }, {
  184. token: "variable.instance",
  185. regex: "[$]",
  186. next: "variable"
  187. }, {
  188. token: "support.function",
  189. regex: "(?:[:][:])[a-zA-Z0-9_/]+(?:[:][:])",
  190. next: "commandItem"
  191. }, {
  192. token: "support.function",
  193. regex: "[a-zA-Z0-9_/]+(?:[:][:])",
  194. next: "commandItem"
  195. }, {
  196. token: "support.function",
  197. regex: "(?:[:][:])",
  198. next: "commandItem"
  199. }, {
  200. token: "paren.rparen",
  201. regex: "[\\])}]"
  202. }, {
  203. token: "paren.lparen",
  204. regex: "[[({]"
  205. }, {
  206. token: "support.function",
  207. regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::"
  208. }, {
  209. token: "keyword",
  210. regex: "[a-zA-Z0-9_/]+",
  211. next: "start"
  212. }
  213. ],
  214. "commentfollow": [
  215. {
  216. token: "comment",
  217. regex: ".*\\\\$",
  218. next: "commentfollow"
  219. }, {
  220. token: "comment",
  221. regex: '.+',
  222. next: "start"
  223. }
  224. ],
  225. "splitlineStart": [
  226. {
  227. token: "text",
  228. regex: "^.",
  229. next: "start"
  230. }
  231. ],
  232. "variable": [
  233. {
  234. token: "variable.instance",
  235. regex: "[a-zA-Z_\\d]+(?:[(][a-zA-Z_\\d]+[)])?",
  236. next: "start"
  237. }, {
  238. token: "variable.instance",
  239. regex: "{?[a-zA-Z_\\d]+}?",
  240. next: "start"
  241. }
  242. ],
  243. "qqstring": [{
  244. token: "string",
  245. regex: '(?:[^\\\\]|\\\\.)*?["]',
  246. next: "start"
  247. }, {
  248. token: "string",
  249. regex: '.+'
  250. }]
  251. };
  252. };
  253. oop.inherits(TclHighlightRules, TextHighlightRules);
  254. exports.TclHighlightRules = TclHighlightRules;
  255. });
  256. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  257. var Range = require("../range").Range;
  258. var MatchingBraceOutdent = function () { };
  259. (function () {
  260. this.checkOutdent = function (line, input) {
  261. if (!/^\s+$/.test(line))
  262. return false;
  263. return /^\s*\}/.test(input);
  264. };
  265. this.autoOutdent = function (doc, row) {
  266. var line = doc.getLine(row);
  267. var match = line.match(/^(\s*\})/);
  268. if (!match)
  269. return 0;
  270. var column = match[1].length;
  271. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  272. if (!openBracePos || openBracePos.row == row)
  273. return 0;
  274. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  275. doc.replace(new Range(row, 0, row, column - 1), indent);
  276. };
  277. this.$getIndent = function (line) {
  278. return line.match(/^\s*/)[0];
  279. };
  280. }).call(MatchingBraceOutdent.prototype);
  281. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  282. });
  283. ace.define("ace/mode/tcl",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/folding/cstyle","ace/mode/tcl_highlight_rules","ace/mode/matching_brace_outdent","ace/range"], function(require, exports, module){"use strict";
  284. var oop = require("../lib/oop");
  285. var TextMode = require("./text").Mode;
  286. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  287. var TclHighlightRules = require("./tcl_highlight_rules").TclHighlightRules;
  288. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  289. var Range = require("../range").Range;
  290. var Mode = function () {
  291. this.HighlightRules = TclHighlightRules;
  292. this.$outdent = new MatchingBraceOutdent();
  293. this.foldingRules = new CStyleFoldMode();
  294. this.$behaviour = this.$defaultBehaviour;
  295. };
  296. oop.inherits(Mode, TextMode);
  297. (function () {
  298. this.lineCommentStart = "#";
  299. this.getNextLineIndent = function (state, line, tab) {
  300. var indent = this.$getIndent(line);
  301. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  302. var tokens = tokenizedLine.tokens;
  303. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  304. return indent;
  305. }
  306. if (state == "start") {
  307. var match = line.match(/^.*[\{\(\[]\s*$/);
  308. if (match) {
  309. indent += tab;
  310. }
  311. }
  312. return indent;
  313. };
  314. this.checkOutdent = function (state, line, input) {
  315. return this.$outdent.checkOutdent(line, input);
  316. };
  317. this.autoOutdent = function (state, doc, row) {
  318. this.$outdent.autoOutdent(doc, row);
  319. };
  320. this.$id = "ace/mode/tcl";
  321. this.snippetFileId = "ace/snippets/tcl";
  322. }).call(Mode.prototype);
  323. exports.Mode = Mode;
  324. }); (function() {
  325. ace.require(["ace/mode/tcl"], function(m) {
  326. if (typeof module == "object" && typeof exports == "object" && module) {
  327. module.exports = m;
  328. }
  329. });
  330. })();