Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. ace.define("ace/mode/c9search_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var lang = require("../lib/lang");
  5. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  6. function safeCreateRegexp(source, flag) {
  7. try {
  8. return new RegExp(source, flag);
  9. } catch(e) {}
  10. }
  11. var C9SearchHighlightRules = function() {
  12. this.$rules = {
  13. "start" : [
  14. {
  15. tokenNames : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text", "c9searchresults.keyword"],
  16. regex : "(^\\s+[0-9]+)(:\\s)(.+)",
  17. onMatch : function(val, state, stack) {
  18. var values = this.splitRegex.exec(val);
  19. var types = this.tokenNames;
  20. var tokens = [{
  21. type: types[0],
  22. value: values[1]
  23. },{
  24. type: types[1],
  25. value: values[2]
  26. }];
  27. var regex = stack[1];
  28. var str = values[3];
  29. var m;
  30. var last = 0;
  31. if (regex && regex.exec) {
  32. regex.lastIndex = 0;
  33. while (m = regex.exec(str)) {
  34. var skipped = str.substring(last, m.index);
  35. last = regex.lastIndex;
  36. if (skipped)
  37. tokens.push({type: types[2], value: skipped});
  38. if (m[0])
  39. tokens.push({type: types[3], value: m[0]});
  40. else if (!skipped)
  41. break;
  42. }
  43. }
  44. if (last < str.length)
  45. tokens.push({type: types[2], value: str.substr(last)});
  46. return tokens;
  47. }
  48. },
  49. {
  50. token : ["string", "text"], // single line
  51. regex : "(\\S.*)(:$)"
  52. },
  53. {
  54. regex : "Searching for .*$",
  55. onMatch: function(val, state, stack) {
  56. var parts = val.split("\x01");
  57. if (parts.length < 3)
  58. return "text";
  59. var options, search, replace;
  60. var i = 0;
  61. var tokens = [{
  62. value: parts[i++] + "'",
  63. type: "text"
  64. }, {
  65. value: search = parts[i++],
  66. type: "text" // "c9searchresults.keyword"
  67. }, {
  68. value: "'" + parts[i++],
  69. type: "text"
  70. }];
  71. if (parts[2] !== " in") {
  72. replace = parts[i];
  73. tokens.push({
  74. value: "'" + parts[i++] + "'",
  75. type: "text"
  76. }, {
  77. value: parts[i++],
  78. type: "text"
  79. });
  80. }
  81. tokens.push({
  82. value: " " + parts[i++] + " ",
  83. type: "text"
  84. });
  85. if (parts[i+1]) {
  86. options = parts[i+1];
  87. tokens.push({
  88. value: "(" + parts[i+1] + ")",
  89. type: "text"
  90. });
  91. i += 1;
  92. } else {
  93. i -= 1;
  94. }
  95. while (i++ < parts.length) {
  96. parts[i] && tokens.push({
  97. value: parts[i],
  98. type: "text"
  99. });
  100. }
  101. if (replace) {
  102. search = replace;
  103. options = "";
  104. }
  105. if (search) {
  106. if (!/regex/.test(options))
  107. search = lang.escapeRegExp(search);
  108. if (/whole/.test(options))
  109. search = "\\b" + search + "\\b";
  110. }
  111. var regex = search && safeCreateRegexp(
  112. "(" + search + ")",
  113. / sensitive/.test(options) ? "g" : "ig"
  114. );
  115. if (regex) {
  116. stack[0] = state;
  117. stack[1] = regex;
  118. }
  119. return tokens;
  120. }
  121. },
  122. {
  123. regex : "\\d+",
  124. token: "constant.numeric"
  125. }
  126. ]
  127. };
  128. };
  129. oop.inherits(C9SearchHighlightRules, TextHighlightRules);
  130. exports.C9SearchHighlightRules = C9SearchHighlightRules;
  131. });
  132. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  133. "use strict";
  134. var Range = require("../range").Range;
  135. var MatchingBraceOutdent = function() {};
  136. (function() {
  137. this.checkOutdent = function(line, input) {
  138. if (! /^\s+$/.test(line))
  139. return false;
  140. return /^\s*\}/.test(input);
  141. };
  142. this.autoOutdent = function(doc, row) {
  143. var line = doc.getLine(row);
  144. var match = line.match(/^(\s*\})/);
  145. if (!match) return 0;
  146. var column = match[1].length;
  147. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  148. if (!openBracePos || openBracePos.row == row) return 0;
  149. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  150. doc.replace(new Range(row, 0, row, column-1), indent);
  151. };
  152. this.$getIndent = function(line) {
  153. return line.match(/^\s*/)[0];
  154. };
  155. }).call(MatchingBraceOutdent.prototype);
  156. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  157. });
  158. ace.define("ace/mode/folding/c9search",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  159. "use strict";
  160. var oop = require("../../lib/oop");
  161. var Range = require("../../range").Range;
  162. var BaseFoldMode = require("./fold_mode").FoldMode;
  163. var FoldMode = exports.FoldMode = function() {};
  164. oop.inherits(FoldMode, BaseFoldMode);
  165. (function() {
  166. this.foldingStartMarker = /^(\S.*\:|Searching for.*)$/;
  167. this.foldingStopMarker = /^(\s+|Found.*)$/;
  168. this.getFoldWidgetRange = function(session, foldStyle, row) {
  169. var lines = session.doc.getAllLines(row);
  170. var line = lines[row];
  171. var level1 = /^(Found.*|Searching for.*)$/;
  172. var level2 = /^(\S.*\:|\s*)$/;
  173. var re = level1.test(line) ? level1 : level2;
  174. var startRow = row;
  175. var endRow = row;
  176. if (this.foldingStartMarker.test(line)) {
  177. for (var i = row + 1, l = session.getLength(); i < l; i++) {
  178. if (re.test(lines[i]))
  179. break;
  180. }
  181. endRow = i;
  182. }
  183. else if (this.foldingStopMarker.test(line)) {
  184. for (var i = row - 1; i >= 0; i--) {
  185. line = lines[i];
  186. if (re.test(line))
  187. break;
  188. }
  189. startRow = i;
  190. }
  191. if (startRow != endRow) {
  192. var col = line.length;
  193. if (re === level1)
  194. col = line.search(/\(Found[^)]+\)$|$/);
  195. return new Range(startRow, col, endRow, 0);
  196. }
  197. };
  198. }).call(FoldMode.prototype);
  199. });
  200. ace.define("ace/mode/c9search",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c9search_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/c9search"], function(require, exports, module) {
  201. "use strict";
  202. var oop = require("../lib/oop");
  203. var TextMode = require("./text").Mode;
  204. var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules;
  205. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  206. var C9StyleFoldMode = require("./folding/c9search").FoldMode;
  207. var Mode = function() {
  208. this.HighlightRules = C9SearchHighlightRules;
  209. this.$outdent = new MatchingBraceOutdent();
  210. this.foldingRules = new C9StyleFoldMode();
  211. };
  212. oop.inherits(Mode, TextMode);
  213. (function() {
  214. this.getNextLineIndent = function(state, line, tab) {
  215. var indent = this.$getIndent(line);
  216. return indent;
  217. };
  218. this.checkOutdent = function(state, line, input) {
  219. return this.$outdent.checkOutdent(line, input);
  220. };
  221. this.autoOutdent = function(state, doc, row) {
  222. this.$outdent.autoOutdent(doc, row);
  223. };
  224. this.$id = "ace/mode/c9search";
  225. }).call(Mode.prototype);
  226. exports.Mode = Mode;
  227. });