mode-diff.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. define("ace/mode/diff_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  2. "use strict";
  3. var oop = ace_require("../lib/oop");
  4. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  5. var DiffHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [{
  8. regex: "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
  9. token: "punctuation.definition.separator.diff",
  10. "name": "keyword"
  11. }, { //diff.range.unified
  12. regex: "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
  13. token: [
  14. "constant",
  15. "constant.numeric",
  16. "constant",
  17. "comment.doc.tag"
  18. ]
  19. }, { //diff.range.normal
  20. regex: "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
  21. token: [
  22. "constant.numeric",
  23. "punctuation.definition.range.diff",
  24. "constant.function",
  25. "constant.numeric",
  26. "punctuation.definition.range.diff",
  27. "invalid"
  28. ],
  29. "name": "meta."
  30. }, {
  31. regex: "^(\\-{3}|\\+{3}|\\*{3})( .+)$",
  32. token: [
  33. "constant.numeric",
  34. "meta.tag"
  35. ]
  36. }, { // added
  37. regex: "^([!+>])(.*?)(\\s*)$",
  38. token: [
  39. "support.constant",
  40. "text",
  41. "invalid"
  42. ]
  43. }, { // removed
  44. regex: "^([<\\-])(.*?)(\\s*)$",
  45. token: [
  46. "support.function",
  47. "string",
  48. "invalid"
  49. ]
  50. }, {
  51. regex: "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
  52. token: ["variable", "variable", "keyword", "variable"]
  53. }, {
  54. regex: "^Index.+$",
  55. token: "variable"
  56. }, {
  57. regex: "^\\s+$",
  58. token: "text"
  59. }, {
  60. regex: "\\s*$",
  61. token: "invalid"
  62. }, {
  63. defaultToken: "invisible",
  64. caseInsensitive: true
  65. }
  66. ]
  67. };
  68. };
  69. oop.inherits(DiffHighlightRules, TextHighlightRules);
  70. exports.DiffHighlightRules = DiffHighlightRules;
  71. });
  72. define("ace/mode/folding/diff",["ace_require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(ace_require, exports, module) {
  73. "use strict";
  74. var oop = ace_require("../../lib/oop");
  75. var BaseFoldMode = ace_require("./fold_mode").FoldMode;
  76. var Range = ace_require("../../range").Range;
  77. var FoldMode = exports.FoldMode = function(levels, flag) {
  78. this.regExpList = levels;
  79. this.flag = flag;
  80. this.foldingStartMarker = RegExp("^(" + levels.join("|") + ")", this.flag);
  81. };
  82. oop.inherits(FoldMode, BaseFoldMode);
  83. (function() {
  84. this.getFoldWidgetRange = function(session, foldStyle, row) {
  85. var line = session.getLine(row);
  86. var start = {row: row, column: line.length};
  87. var regList = this.regExpList;
  88. for (var i = 1; i <= regList.length; i++) {
  89. var re = RegExp("^(" + regList.slice(0, i).join("|") + ")", this.flag);
  90. if (re.test(line))
  91. break;
  92. }
  93. for (var l = session.getLength(); ++row < l; ) {
  94. line = session.getLine(row);
  95. if (re.test(line))
  96. break;
  97. }
  98. if (row == start.row + 1)
  99. return;
  100. return new Range(start.row, start.column, row - 1, line.length);
  101. };
  102. }).call(FoldMode.prototype);
  103. });
  104. define("ace/mode/diff",["ace_require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/diff_highlight_rules","ace/mode/folding/diff"], function(ace_require, exports, module) {
  105. "use strict";
  106. var oop = ace_require("../lib/oop");
  107. var TextMode = ace_require("./text").Mode;
  108. var HighlightRules = ace_require("./diff_highlight_rules").DiffHighlightRules;
  109. var FoldMode = ace_require("./folding/diff").FoldMode;
  110. var Mode = function() {
  111. this.HighlightRules = HighlightRules;
  112. this.foldingRules = new FoldMode(["diff", "@@|\\*{5}"], "i");
  113. };
  114. oop.inherits(Mode, TextMode);
  115. (function() {
  116. this.$id = "ace/mode/diff";
  117. this.snippetFileId = "ace/snippets/diff";
  118. }).call(Mode.prototype);
  119. exports.Mode = Mode;
  120. }); (function() {
  121. window.ace_require(["ace/mode/diff"], function(m) {
  122. if (typeof module == "object" && typeof exports == "object" && module) {
  123. module.exports = m;
  124. }
  125. });
  126. })();