5adf5687c0c3588532b6d8157a3b2a3f.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
  2. var oop = require("../../lib/oop");
  3. var BaseFoldMode = require("./fold_mode").FoldMode;
  4. var Range = require("../../range").Range;
  5. var FoldMode = exports.FoldMode = function () { };
  6. oop.inherits(FoldMode, BaseFoldMode);
  7. (function () {
  8. this.getFoldWidgetRange = function (session, foldStyle, row) {
  9. var range = this.indentationBlock(session, row);
  10. if (range)
  11. return range;
  12. var re = /\S/;
  13. var line = session.getLine(row);
  14. var startLevel = line.search(re);
  15. if (startLevel == -1 || line[startLevel] != "#")
  16. return;
  17. var startColumn = line.length;
  18. var maxRow = session.getLength();
  19. var startRow = row;
  20. var endRow = row;
  21. while (++row < maxRow) {
  22. line = session.getLine(row);
  23. var level = line.search(re);
  24. if (level == -1)
  25. continue;
  26. if (line[level] != "#")
  27. break;
  28. endRow = row;
  29. }
  30. if (endRow > startRow) {
  31. var endColumn = session.getLine(endRow).length;
  32. return new Range(startRow, startColumn, endRow, endColumn);
  33. }
  34. };
  35. this.getFoldWidget = function (session, foldStyle, row) {
  36. var line = session.getLine(row);
  37. var indent = line.search(/\S/);
  38. var next = session.getLine(row + 1);
  39. var prev = session.getLine(row - 1);
  40. var prevIndent = prev.search(/\S/);
  41. var nextIndent = next.search(/\S/);
  42. if (indent == -1) {
  43. session.foldWidgets[row - 1] = prevIndent != -1 && prevIndent < nextIndent ? "start" : "";
  44. return "";
  45. }
  46. if (prevIndent == -1) {
  47. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  48. session.foldWidgets[row - 1] = "";
  49. session.foldWidgets[row + 1] = "";
  50. return "start";
  51. }
  52. }
  53. else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  54. if (session.getLine(row - 2).search(/\S/) == -1) {
  55. session.foldWidgets[row - 1] = "start";
  56. session.foldWidgets[row + 1] = "";
  57. return "";
  58. }
  59. }
  60. if (prevIndent != -1 && prevIndent < indent)
  61. session.foldWidgets[row - 1] = "start";
  62. else
  63. session.foldWidgets[row - 1] = "";
  64. if (indent < nextIndent)
  65. return "start";
  66. else
  67. return "";
  68. };
  69. }).call(FoldMode.prototype);
  70. });
  71. ace.define("ace/mode/snippets",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/text_highlight_rules","ace/mode/folding/coffee"], function(require, exports, module){"use strict";
  72. var oop = require("../lib/oop");
  73. var TextMode = require("./text").Mode;
  74. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  75. var SnippetHighlightRules = function () {
  76. var builtins = "SELECTION|CURRENT_WORD|SELECTED_TEXT|CURRENT_LINE|LINE_INDEX|" +
  77. "LINE_NUMBER|SOFT_TABS|TAB_SIZE|FILENAME|FILEPATH|FULLNAME";
  78. this.$rules = {
  79. "start": [
  80. { token: "constant.language.escape", regex: /\\[\$}`\\]/ },
  81. { token: "keyword", regex: "\\$(?:TM_)?(?:" + builtins + ")\\b" },
  82. { token: "variable", regex: "\\$\\w+" },
  83. { onMatch: function (value, state, stack) {
  84. if (stack[1])
  85. stack[1]++;
  86. else
  87. stack.unshift(state, 1);
  88. return this.tokenName;
  89. }, tokenName: "markup.list", regex: "\\${", next: "varDecl" },
  90. { onMatch: function (value, state, stack) {
  91. if (!stack[1])
  92. return "text";
  93. stack[1]--;
  94. if (!stack[1])
  95. stack.splice(0, 2);
  96. return this.tokenName;
  97. }, tokenName: "markup.list", regex: "}" },
  98. { token: "doc.comment", regex: /^\${2}-{5,}$/ }
  99. ],
  100. "varDecl": [
  101. { regex: /\d+\b/, token: "constant.numeric" },
  102. { token: "keyword", regex: "(?:TM_)?(?:" + builtins + ")\\b" },
  103. { token: "variable", regex: "\\w+" },
  104. { regex: /:/, token: "punctuation.operator", next: "start" },
  105. { regex: /\//, token: "string.regex", next: "regexp" },
  106. { regex: "", next: "start" }
  107. ],
  108. "regexp": [
  109. { regex: /\\./, token: "escape" },
  110. { regex: /\[/, token: "regex.start", next: "charClass" },
  111. { regex: "/", token: "string.regex", next: "format" },
  112. { "token": "string.regex", regex: "." }
  113. ],
  114. charClass: [
  115. { regex: "\\.", token: "escape" },
  116. { regex: "\\]", token: "regex.end", next: "regexp" },
  117. { "token": "string.regex", regex: "." }
  118. ],
  119. "format": [
  120. { regex: /\\[ulULE]/, token: "keyword" },
  121. { regex: /\$\d+/, token: "variable" },
  122. { regex: "/[gim]*:?", token: "string.regex", next: "start" },
  123. { "token": "string", regex: "." }
  124. ]
  125. };
  126. };
  127. oop.inherits(SnippetHighlightRules, TextHighlightRules);
  128. exports.SnippetHighlightRules = SnippetHighlightRules;
  129. var SnippetGroupHighlightRules = function () {
  130. this.$rules = {
  131. "start": [
  132. { token: "text", regex: "^\\t", next: "sn-start" },
  133. { token: "invalid", regex: /^ \s*/ },
  134. { token: "comment", regex: /^#.*/ },
  135. { token: "constant.language.escape", regex: "^regex ", next: "regex" },
  136. { token: "constant.language.escape", regex: "^(trigger|endTrigger|name|snippet|guard|endGuard|tabTrigger|key)\\b" }
  137. ],
  138. "regex": [
  139. { token: "text", regex: "\\." },
  140. { token: "keyword", regex: "/" },
  141. { token: "empty", regex: "$", next: "start" }
  142. ]
  143. };
  144. this.embedRules(SnippetHighlightRules, "sn-", [
  145. { token: "text", regex: "^\\t", next: "sn-start" },
  146. { onMatch: function (value, state, stack) {
  147. stack.splice(stack.length);
  148. return this.tokenName;
  149. }, tokenName: "text", regex: "^(?!\t)", next: "start" }
  150. ]);
  151. };
  152. oop.inherits(SnippetGroupHighlightRules, TextHighlightRules);
  153. exports.SnippetGroupHighlightRules = SnippetGroupHighlightRules;
  154. var FoldMode = require("./folding/coffee").FoldMode;
  155. var Mode = function () {
  156. this.HighlightRules = SnippetGroupHighlightRules;
  157. this.foldingRules = new FoldMode();
  158. this.$behaviour = this.$defaultBehaviour;
  159. };
  160. oop.inherits(Mode, TextMode);
  161. (function () {
  162. this.$indentWithTabs = true;
  163. this.lineCommentStart = "#";
  164. this.$id = "ace/mode/snippets";
  165. this.snippetFileId = "ace/snippets/snippets";
  166. }).call(Mode.prototype);
  167. exports.Mode = Mode;
  168. }); (function() {
  169. ace.require(["ace/mode/snippets"], function(m) {
  170. if (typeof module == "object" && typeof exports == "object" && module) {
  171. module.exports = m;
  172. }
  173. });
  174. })();